Let's experiment with making uiWindowSetSize() not require an event loop.
This commit is contained in:
parent
0870a3065e
commit
e17e69f2ad
|
@ -37,7 +37,7 @@ static void updatesize(uiWindow *w)
|
||||||
|
|
||||||
void onSize(uiWindow *w, void *data)
|
void onSize(uiWindow *w, void *data)
|
||||||
{
|
{
|
||||||
printf("size\n");
|
//TODO_REINSTATE printf("size\n");
|
||||||
updatesize(w);
|
updatesize(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,23 @@ struct uiWindow {
|
||||||
gboolean fullscreen;
|
gboolean fullscreen;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void dbgPrintSizes(uiWindow *w, const char *prefix)
|
||||||
|
{
|
||||||
|
#if 1
|
||||||
|
GtkAllocation a;
|
||||||
|
gint ww, wh;
|
||||||
|
|
||||||
|
gtk_widget_get_allocation(w->widget, &a);
|
||||||
|
g_print("%-14s| window width %d height %d\n", prefix, a.width, a.height);
|
||||||
|
gtk_widget_get_allocation(w->childHolderWidget, &a);
|
||||||
|
g_print("%-14s| client width %d height %d\n", prefix, a.width, a.height);
|
||||||
|
gtk_window_get_size(w->window, &ww, &wh);
|
||||||
|
g_print("%-14s| winsiz width %d height %d\n", prefix, ww, wh);
|
||||||
|
#else
|
||||||
|
#error forgot to remove dbgPrintSizes() (TODO)
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean onClosing(GtkWidget *win, GdkEvent *e, gpointer data)
|
static gboolean onClosing(GtkWidget *win, GdkEvent *e, gpointer data)
|
||||||
{
|
{
|
||||||
uiWindow *w = uiWindow(data);
|
uiWindow *w = uiWindow(data);
|
||||||
|
@ -43,6 +60,8 @@ static void onSizeAllocate(GtkWidget *widget, GdkRectangle *allocation, gpointer
|
||||||
{
|
{
|
||||||
uiWindow *w = uiWindow(data);
|
uiWindow *w = uiWindow(data);
|
||||||
|
|
||||||
|
dbgPrintSizes(w, "SIZE-ALLOCATE");
|
||||||
|
|
||||||
if (w->changingSize)
|
if (w->changingSize)
|
||||||
w->changingSize = FALSE;
|
w->changingSize = FALSE;
|
||||||
else
|
else
|
||||||
|
@ -132,9 +151,13 @@ void uiWindowContentSize(uiWindow *w, int *width, int *height)
|
||||||
{
|
{
|
||||||
GtkAllocation allocation;
|
GtkAllocation allocation;
|
||||||
|
|
||||||
|
dbgPrintSizes(w, "BEFORE GET");
|
||||||
|
|
||||||
gtk_widget_get_allocation(w->childHolderWidget, &allocation);
|
gtk_widget_get_allocation(w->childHolderWidget, &allocation);
|
||||||
*width = allocation.width;
|
*width = allocation.width;
|
||||||
*height = allocation.height;
|
*height = allocation.height;
|
||||||
|
|
||||||
|
dbgPrintSizes(w, "AFTER GET");
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO what happens if the size is already the current one?
|
// TODO what happens if the size is already the current one?
|
||||||
|
@ -142,6 +165,8 @@ void uiWindowContentSize(uiWindow *w, int *width, int *height)
|
||||||
// TODO can't reduce the size this way
|
// TODO can't reduce the size this way
|
||||||
void uiWindowSetContentSize(uiWindow *w, int width, int height)
|
void uiWindowSetContentSize(uiWindow *w, int width, int height)
|
||||||
{
|
{
|
||||||
|
dbgPrintSizes(w, "BEFORE SET");
|
||||||
|
|
||||||
w->changingSize = TRUE;
|
w->changingSize = TRUE;
|
||||||
gtk_widget_set_size_request(w->childHolderWidget, width, height);
|
gtk_widget_set_size_request(w->childHolderWidget, width, height);
|
||||||
// MAJOR TODO REMOVE THIS.
|
// MAJOR TODO REMOVE THIS.
|
||||||
|
@ -149,6 +174,8 @@ void uiWindowSetContentSize(uiWindow *w, int width, int height)
|
||||||
if (!uiMainStep(1))
|
if (!uiMainStep(1))
|
||||||
break; // stop early if uiQuit() called
|
break; // stop early if uiQuit() called
|
||||||
gtk_widget_set_size_request(w->childHolderWidget, -1, -1);
|
gtk_widget_set_size_request(w->childHolderWidget, -1, -1);
|
||||||
|
|
||||||
|
dbgPrintSizes(w, "AFTER SET");
|
||||||
}
|
}
|
||||||
|
|
||||||
int uiWindowFullscreen(uiWindow *w)
|
int uiWindowFullscreen(uiWindow *w)
|
||||||
|
@ -215,6 +242,16 @@ void uiWindowSetMargined(uiWindow *w, int margined)
|
||||||
setMargined(w->childHolderContainer, w->margined);
|
setMargined(w->childHolderContainer, w->margined);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean TODO_REMOVE(GtkWidget *win, GdkEvent *e, gpointer data)
|
||||||
|
{
|
||||||
|
uiWindow *w = uiWindow(data);
|
||||||
|
|
||||||
|
dbgPrintSizes(w, "CONFIGURE");
|
||||||
|
|
||||||
|
// always continue handling
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
|
uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
|
||||||
{
|
{
|
||||||
uiWindow *w;
|
uiWindow *w;
|
||||||
|
@ -261,5 +298,7 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
|
||||||
// TODO we really need to clean this up, especially since see uiWindowDestroy() above
|
// TODO we really need to clean this up, especially since see uiWindowDestroy() above
|
||||||
g_object_ref(w->widget);
|
g_object_ref(w->widget);
|
||||||
|
|
||||||
|
g_signal_connect(w->widget, "configure-event", G_CALLBACK(TODO_REMOVE), w);
|
||||||
|
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue