Fixed initial (and future) window redraw issues on Windows.
This commit is contained in:
parent
b95975302e
commit
2e9ff88561
|
@ -82,3 +82,19 @@ void resize(uiControl *control, HWND parent, RECT r)
|
||||||
logLastError("error releasing DC in resize()");
|
logLastError("error releasing DC in resize()");
|
||||||
(*(control->resize))(control, r.left, r.top, r.right - r.left, r.bottom - r.top, &d);
|
(*(control->resize))(control, r.left, r.top, r.right - r.left, r.bottom - r.top, &d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateParent(uintptr_t h)
|
||||||
|
{
|
||||||
|
HWND hwnd;
|
||||||
|
RECT r;
|
||||||
|
|
||||||
|
if (h == 0) // no parent
|
||||||
|
return;
|
||||||
|
hwnd = (HWND) h;
|
||||||
|
// TODO is there a better way?
|
||||||
|
if (GetWindowRect(hwnd, &r) == 0)
|
||||||
|
logLastError("error getting window rect for dummy move in updateParent()");
|
||||||
|
if (MoveWindow(hwnd, r.left, r.top, r.right - r.left, r.bottom - r.top, TRUE) == 0)
|
||||||
|
logLastError("error moving window in updateParent()");
|
||||||
|
// TODO invalidate rect?
|
||||||
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ struct uiSingleHWNDControl {
|
||||||
void *onCommandNotifyDestroyData;
|
void *onCommandNotifyDestroyData;
|
||||||
void (*preferredSize)(uiControl *, int, int, LONG, intmax_t *, intmax_t *);
|
void (*preferredSize)(uiControl *, int, int, LONG, intmax_t *, intmax_t *);
|
||||||
void *data;
|
void *data;
|
||||||
|
uintptr_t parent;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define S(c) ((uiSingleHWNDControl *) (c))
|
#define S(c) ((uiSingleHWNDControl *) (c))
|
||||||
|
@ -28,10 +29,17 @@ static uintptr_t singleHandle(uiControl *c)
|
||||||
return (uintptr_t) (S(c)->hwnd);
|
return (uintptr_t) (S(c)->hwnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void singleSetParent(uiControl *c, uintptr_t parentHWND)
|
static void singleSetParent(uiControl *c, uintptr_t parent)
|
||||||
{
|
{
|
||||||
if (SetParent(S(c)->hwnd, (HWND) parentHWND) == NULL)
|
uiSingleHWNDControl *s = S(c);
|
||||||
|
uintptr_t oldparent;
|
||||||
|
|
||||||
|
oldparent = s->parent;
|
||||||
|
s->parent = parent;
|
||||||
|
if (SetParent(s->hwnd, (HWND) (s->parent)) == NULL)
|
||||||
logLastError("error changing control parent in singleSetParent()");
|
logLastError("error changing control parent in singleSetParent()");
|
||||||
|
updateParent(oldparent);
|
||||||
|
updateParent(s->parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uiSize singlePreferredSize(uiControl *c, uiSizing *d)
|
static uiSize singlePreferredSize(uiControl *c, uiSizing *d)
|
||||||
|
|
11
stack.c
11
stack.c
|
@ -38,11 +38,16 @@ static uintptr_t stackHandle(uiControl *c)
|
||||||
|
|
||||||
static void stackSetParent(uiControl *c, uintptr_t parent)
|
static void stackSetParent(uiControl *c, uintptr_t parent)
|
||||||
{
|
{
|
||||||
|
stack *s = S(c);
|
||||||
uintmax_t i;
|
uintmax_t i;
|
||||||
|
uintptr_t oldparent;
|
||||||
|
|
||||||
S(c)->parent = parent;
|
oldparent = s->parent;
|
||||||
|
s->parent = parent;
|
||||||
for (i = 0; i < S(c)->len; i++)
|
for (i = 0; i < S(c)->len; i++)
|
||||||
(*(S(c)->controls[i]->setParent))(S(c)->controls[i], S(c)->parent);
|
(*(s->controls[i]->setParent))(s->controls[i], s->parent);
|
||||||
|
updateParent(oldparent);
|
||||||
|
updateParent(s->parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uiSize stackPreferredSize(uiControl *c, uiSizing *d)
|
static uiSize stackPreferredSize(uiControl *c, uiSizing *d)
|
||||||
|
@ -213,5 +218,5 @@ void uiStackAdd(uiControl *st, uiControl *c, int stretchy)
|
||||||
if (s->parent != 0)
|
if (s->parent != 0)
|
||||||
(*(s->controls[s->len]->setParent))(s->controls[s->len], s->parent);
|
(*(s->controls[s->len]->setParent))(s->controls[s->len], s->parent);
|
||||||
s->len++;
|
s->len++;
|
||||||
// TODO queue reposition
|
updateParent(s->parent);
|
||||||
}
|
}
|
||||||
|
|
2
uipriv.h
2
uipriv.h
|
@ -25,3 +25,5 @@ extern void *uiAlloc(size_t, const char *);
|
||||||
#define uiNew(T) ((T *) uiAlloc(sizeof (T), #T ))
|
#define uiNew(T) ((T *) uiAlloc(sizeof (T), #T ))
|
||||||
extern void *uiRealloc(void *, size_t, const char *);
|
extern void *uiRealloc(void *, size_t, const char *);
|
||||||
extern void uiFree(void *);
|
extern void uiFree(void *);
|
||||||
|
|
||||||
|
extern void updateParent(uintptr_t);
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
// 6 april 2015
|
// 6 april 2015
|
||||||
#include "uipriv_windows.h"
|
#include "uipriv_windows.h"
|
||||||
|
|
||||||
// TODOs:
|
|
||||||
// - child not set to fit initial size
|
|
||||||
|
|
||||||
struct uiWindow {
|
struct uiWindow {
|
||||||
HWND hwnd;
|
HWND hwnd;
|
||||||
uiControl *child;
|
uiControl *child;
|
||||||
|
|
Loading…
Reference in New Issue