Cleaned up debugging code and added the main loop bugfix to the README.

This commit is contained in:
Pietro Gagliardi 2016-10-24 17:47:23 -04:00
parent 0c209a8277
commit fc243aed00
3 changed files with 6 additions and 45 deletions

View File

@ -7,6 +7,9 @@ This README is being written.<br>
## 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**
* 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.

View File

@ -37,7 +37,7 @@ static void updatesize(uiWindow *w)
void onSize(uiWindow *w, void *data)
{
//TODO_REINSTATE printf("size\n");
printf("size\n");
updatesize(w);
}

View File

@ -24,27 +24,9 @@ struct uiWindow {
void *onClosingData;
void (*onContentSizeChanged)(uiWindow *, void *);
void *onContentSizeChangedData;
gboolean changingSize;
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)
{
uiWindow *w = uiWindow(data);
@ -60,11 +42,7 @@ static void onSizeAllocate(GtkWidget *widget, GdkRectangle *allocation, gpointer
{
uiWindow *w = uiWindow(data);
dbgPrintSizes(w, "SIZE-ALLOCATE");
if (w->changingSize)
w->changingSize = FALSE;
else
// TODO deal with spurious size-allocates
(*(w->onContentSizeChanged))(w, w->onContentSizeChangedData);
}
@ -151,13 +129,9 @@ void uiWindowContentSize(uiWindow *w, int *width, int *height)
{
GtkAllocation allocation;
dbgPrintSizes(w, "BEFORE GET");
gtk_widget_get_allocation(w->childHolderWidget, &allocation);
*width = allocation.width;
*height = allocation.height;
dbgPrintSizes(w, "AFTER GET");
}
void uiWindowSetContentSize(uiWindow *w, int width, int height)
@ -165,8 +139,6 @@ void uiWindowSetContentSize(uiWindow *w, int width, int height)
GtkAllocation childAlloc;
gint winWidth, winHeight;
dbgPrintSizes(w, "BEFORE SET");
// we need to resize the child holder widget to the given size
// we can't resize that without running the event loop
// but we can do gtk_window_set_size()
@ -191,8 +163,6 @@ void uiWindowSetContentSize(uiWindow *w, int width, int height)
// and set it
// this will not move the window in my tests, so we're good
gtk_window_resize(w->window, winWidth, winHeight);
dbgPrintSizes(w, "AFTER SET");
}
int uiWindowFullscreen(uiWindow *w)
@ -259,16 +229,6 @@ void uiWindowSetMargined(uiWindow *w, int 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 *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
g_object_ref(w->widget);
g_signal_connect(w->widget, "configure-event", G_CALLBACK(TODO_REMOVE), w);
return w;
}