More removal.
This commit is contained in:
parent
edd70b9fa5
commit
57fbf78ef3
|
@ -22,9 +22,6 @@ struct uiWindow {
|
|||
|
||||
int (*onClosing)(uiWindow *, void *);
|
||||
void *onClosingData;
|
||||
void (*onPositionChanged)(uiWindow *, void *);
|
||||
void *onPositionChangedData;
|
||||
gboolean changingPosition;
|
||||
void (*onContentSizeChanged)(uiWindow *, void *);
|
||||
void *onContentSizeChangedData;
|
||||
gboolean changingSize;
|
||||
|
@ -42,19 +39,6 @@ static gboolean onClosing(GtkWidget *win, GdkEvent *e, gpointer data)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean onConfigure(GtkWidget *win, GdkEvent *e, gpointer data)
|
||||
{
|
||||
uiWindow *w = uiWindow(data);
|
||||
|
||||
// there doesn't seem to be a way to determine if only moving or only resizing is happening :/
|
||||
if (w->changingPosition)
|
||||
w->changingPosition = FALSE;
|
||||
else
|
||||
(*(w->onPositionChanged))(w, w->onPositionChangedData);
|
||||
// always continue handling
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void onSizeAllocate(GtkWidget *widget, GdkRectangle *allocation, gpointer data)
|
||||
{
|
||||
uiWindow *w = uiWindow(data);
|
||||
|
@ -144,56 +128,6 @@ void uiWindowSetTitle(uiWindow *w, const char *title)
|
|||
gtk_window_set_title(w->window, title);
|
||||
}
|
||||
|
||||
// TODO allow specifying either as NULL on all platforms
|
||||
void uiWindowPosition(uiWindow *w, int *x, int *y)
|
||||
{
|
||||
gint rx, ry;
|
||||
|
||||
gtk_window_get_position(w->window, &rx, &ry);
|
||||
*x = rx;
|
||||
*y = ry;
|
||||
}
|
||||
|
||||
void uiWindowSetPosition(uiWindow *w, int x, int y)
|
||||
{
|
||||
w->changingPosition = TRUE;
|
||||
gtk_window_move(w->window, x, y);
|
||||
// gtk_window_move() is asynchronous
|
||||
// we need to wait for a configure-event
|
||||
// thanks to hergertme in irc.gimp.net/#gtk+
|
||||
while (w->changingPosition)
|
||||
if (!uiMainStep(1))
|
||||
break; // stop early if uiQuit() called
|
||||
}
|
||||
|
||||
void uiWindowCenter(uiWindow *w)
|
||||
{
|
||||
gint x, y;
|
||||
GtkAllocation winalloc;
|
||||
GdkWindow *gdkwin;
|
||||
GdkScreen *screen;
|
||||
GdkRectangle workarea;
|
||||
|
||||
gtk_widget_get_allocation(w->widget, &winalloc);
|
||||
gdkwin = gtk_widget_get_window(w->widget);
|
||||
screen = gdk_window_get_screen(gdkwin);
|
||||
gdk_screen_get_monitor_workarea(screen,
|
||||
gdk_screen_get_monitor_at_window(screen, gdkwin),
|
||||
&workarea);
|
||||
|
||||
x = (workarea.width - winalloc.width) / 2;
|
||||
y = (workarea.height - winalloc.height) / 2;
|
||||
// TODO move up slightly? see what Mutter or GNOME Shell or GNOME Terminal do(es)?
|
||||
uiWindowSetPosition(w, x, y);
|
||||
}
|
||||
|
||||
// TODO this and size changed get set during uiWindowDestroy
|
||||
void uiWindowOnPositionChanged(uiWindow *w, void (*f)(uiWindow *, void *), void *data)
|
||||
{
|
||||
w->onPositionChanged = f;
|
||||
w->onPositionChangedData = data;
|
||||
}
|
||||
|
||||
void uiWindowContentSize(uiWindow *w, int *width, int *height)
|
||||
{
|
||||
GtkAllocation allocation;
|
||||
|
@ -210,6 +144,7 @@ void uiWindowSetContentSize(uiWindow *w, int width, int height)
|
|||
{
|
||||
w->changingSize = TRUE;
|
||||
gtk_widget_set_size_request(w->childHolderWidget, width, height);
|
||||
// MAJOR TODO REMOVE THIS.
|
||||
while (w->changingSize)
|
||||
if (!uiMainStep(1))
|
||||
break; // stop early if uiQuit() called
|
||||
|
@ -223,6 +158,7 @@ int uiWindowFullscreen(uiWindow *w)
|
|||
|
||||
// TODO use window-state-event to track
|
||||
// TODO does this send an extra size changed?
|
||||
// TODO what behavior do we want?
|
||||
void uiWindowSetFullscreen(uiWindow *w, int fullscreen)
|
||||
{
|
||||
w->fullscreen = fullscreen;
|
||||
|
@ -317,10 +253,8 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
|
|||
|
||||
// and connect our events
|
||||
g_signal_connect(w->widget, "delete-event", G_CALLBACK(onClosing), w);
|
||||
g_signal_connect(w->widget, "configure-event", G_CALLBACK(onConfigure), w);
|
||||
g_signal_connect(w->childHolderWidget, "size-allocate", G_CALLBACK(onSizeAllocate), w);
|
||||
uiWindowOnClosing(w, defaultOnClosing, NULL);
|
||||
uiWindowOnPositionChanged(w, defaultOnPositionContentSizeChanged, NULL);
|
||||
uiWindowOnContentSizeChanged(w, defaultOnPositionContentSizeChanged, NULL);
|
||||
|
||||
// normally it's SetParent() that does this, but we can't call SetParent() on a uiWindow
|
||||
|
|
|
@ -387,6 +387,8 @@ int uiWindowBorderless(uiWindow *w)
|
|||
return w->borderless;
|
||||
}
|
||||
|
||||
// TODO window should move to the old client position and should not have the extra space the borders left behind
|
||||
// TODO extract the relevant styles from WS_OVERLAPPEDWINDOW?
|
||||
void uiWindowSetBorderless(uiWindow *w, int borderless)
|
||||
{
|
||||
w->borderless = borderless;
|
||||
|
|
Loading…
Reference in New Issue