Cleaned up debugging code and added the main loop bugfix to the README.
This commit is contained in:
parent
0c209a8277
commit
fc243aed00
|
@ -7,6 +7,9 @@ This README is being written.<br>
|
||||||
|
|
||||||
## Announcements
|
## Announcements
|
||||||
|
|
||||||
|
* **<codedate**
|
||||||
|
* `uiWindowSetContentSize()` on Unix no longer needs to call up the GTK+ main loop. As a result, bugs related to strange behavior using that function (and the now-deleted `uiWindowSetPosition()` and `uiWindowCenter()`) should go away. I'll need to go through the bugs to verify as much, though.
|
||||||
|
|
||||||
* **22 October 2016**
|
* **22 October 2016**
|
||||||
* Due to being unable to guarantee they will work (especially as we move toward capability-driven window systems like Wayland), or being unable to work without hacking that breaks other things, the following functions have been removed: `uiWindowPosition()`, `uiWindowSetPosition()`, `uiWindowCenter()`, and `uiWindowOnPositionChanged()`. Centering may come back at some point in the future, albeit in a possibly restricted form. A function to initiate a user move when a part of a uiArea is clicked will be provided soon.
|
* Due to being unable to guarantee they will work (especially as we move toward capability-driven window systems like Wayland), or being unable to work without hacking that breaks other things, the following functions have been removed: `uiWindowPosition()`, `uiWindowSetPosition()`, `uiWindowCenter()`, and `uiWindowOnPositionChanged()`. Centering may come back at some point in the future, albeit in a possibly restricted form. A function to initiate a user move when a part of a uiArea is clicked will be provided soon.
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ static void updatesize(uiWindow *w)
|
||||||
|
|
||||||
void onSize(uiWindow *w, void *data)
|
void onSize(uiWindow *w, void *data)
|
||||||
{
|
{
|
||||||
//TODO_REINSTATE printf("size\n");
|
printf("size\n");
|
||||||
updatesize(w);
|
updatesize(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,27 +24,9 @@ struct uiWindow {
|
||||||
void *onClosingData;
|
void *onClosingData;
|
||||||
void (*onContentSizeChanged)(uiWindow *, void *);
|
void (*onContentSizeChanged)(uiWindow *, void *);
|
||||||
void *onContentSizeChangedData;
|
void *onContentSizeChangedData;
|
||||||
gboolean changingSize;
|
|
||||||
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);
|
||||||
|
@ -60,12 +42,8 @@ static void onSizeAllocate(GtkWidget *widget, GdkRectangle *allocation, gpointer
|
||||||
{
|
{
|
||||||
uiWindow *w = uiWindow(data);
|
uiWindow *w = uiWindow(data);
|
||||||
|
|
||||||
dbgPrintSizes(w, "SIZE-ALLOCATE");
|
// TODO deal with spurious size-allocates
|
||||||
|
(*(w->onContentSizeChanged))(w, w->onContentSizeChangedData);
|
||||||
if (w->changingSize)
|
|
||||||
w->changingSize = FALSE;
|
|
||||||
else
|
|
||||||
(*(w->onContentSizeChanged))(w, w->onContentSizeChangedData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int defaultOnClosing(uiWindow *w, void *data)
|
static int defaultOnClosing(uiWindow *w, void *data)
|
||||||
|
@ -151,13 +129,9 @@ 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");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiWindowSetContentSize(uiWindow *w, int width, int height)
|
void uiWindowSetContentSize(uiWindow *w, int width, int height)
|
||||||
|
@ -165,8 +139,6 @@ void uiWindowSetContentSize(uiWindow *w, int width, int height)
|
||||||
GtkAllocation childAlloc;
|
GtkAllocation childAlloc;
|
||||||
gint winWidth, winHeight;
|
gint winWidth, winHeight;
|
||||||
|
|
||||||
dbgPrintSizes(w, "BEFORE SET");
|
|
||||||
|
|
||||||
// we need to resize the child holder widget to the given size
|
// we need to resize the child holder widget to the given size
|
||||||
// we can't resize that without running the event loop
|
// we can't resize that without running the event loop
|
||||||
// but we can do gtk_window_set_size()
|
// but we can do gtk_window_set_size()
|
||||||
|
@ -191,8 +163,6 @@ void uiWindowSetContentSize(uiWindow *w, int width, int height)
|
||||||
// and set it
|
// and set it
|
||||||
// this will not move the window in my tests, so we're good
|
// this will not move the window in my tests, so we're good
|
||||||
gtk_window_resize(w->window, winWidth, winHeight);
|
gtk_window_resize(w->window, winWidth, winHeight);
|
||||||
|
|
||||||
dbgPrintSizes(w, "AFTER SET");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int uiWindowFullscreen(uiWindow *w)
|
int uiWindowFullscreen(uiWindow *w)
|
||||||
|
@ -259,16 +229,6 @@ 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;
|
||||||
|
@ -315,7 +275,5 @@ 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