From 89d3e0d8ef2a9886e3e769a159401e46c601dcfe Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Sat, 15 Apr 2000 20:08:04 +0000 Subject: [PATCH] after resizing the display, check if the window manager placed it 2000-04-15 Michael Natterer * app/gdisplay_ops.c (gdisplay_shrink_wrap): after resizing the display, check if the window manager placed it offscreen and center it in that case. --- ChangeLog | 6 ++++++ app/display/gimpdisplay-ops.c | 17 +++++++++++++++++ app/gdisplay_ops.c | 17 +++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/ChangeLog b/ChangeLog index c877b2a896..5bb5699cc6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2000-04-15 Michael Natterer + + * app/gdisplay_ops.c (gdisplay_shrink_wrap): after resizing the + display, check if the window manager placed it offscreen and + center it in that case. + 2000-04-15 Michael Natterer * app/disp_callbacks.c: s/0/FALSE/ diff --git a/app/display/gimpdisplay-ops.c b/app/display/gimpdisplay-ops.c index 580e7525ff..208abb0c05 100644 --- a/app/display/gimpdisplay-ops.c +++ b/app/display/gimpdisplay-ops.c @@ -151,6 +151,7 @@ gdisplay_shrink_wrap (GDisplay *gdisp) GtkAllocation allocation; gint disp_width, disp_height; gint width, height; + gint shell_x, shell_y; gint shell_width, shell_height; gint max_auto_width, max_auto_height; gint border_x, border_y; @@ -251,6 +252,22 @@ gdisplay_shrink_wrap (GDisplay *gdisp) else gdisplay_expose_full (gdisp); + /* let Gtk/X/WM position the window */ + while (gtk_events_pending ()) + gtk_main_iteration (); + + gdk_window_get_origin (gdisp->shell->window, &shell_x, &shell_y); + + /* if the window is offscreen, center it... */ + if (shell_x > s_width || shell_y > s_height || + (shell_x + width + border_x) < 0 || (shell_y + height + border_y) < 0) + { + shell_x = (s_width - width - border_x) >> 1; + shell_y = (s_height - height - border_y) >> 1; + + gdk_window_move (gdisp->shell->window, shell_x, shell_y); + } + /* If the width or height of the display has changed, recalculate * the display offsets... */ diff --git a/app/gdisplay_ops.c b/app/gdisplay_ops.c index 580e7525ff..208abb0c05 100644 --- a/app/gdisplay_ops.c +++ b/app/gdisplay_ops.c @@ -151,6 +151,7 @@ gdisplay_shrink_wrap (GDisplay *gdisp) GtkAllocation allocation; gint disp_width, disp_height; gint width, height; + gint shell_x, shell_y; gint shell_width, shell_height; gint max_auto_width, max_auto_height; gint border_x, border_y; @@ -251,6 +252,22 @@ gdisplay_shrink_wrap (GDisplay *gdisp) else gdisplay_expose_full (gdisp); + /* let Gtk/X/WM position the window */ + while (gtk_events_pending ()) + gtk_main_iteration (); + + gdk_window_get_origin (gdisp->shell->window, &shell_x, &shell_y); + + /* if the window is offscreen, center it... */ + if (shell_x > s_width || shell_y > s_height || + (shell_x + width + border_x) < 0 || (shell_y + height + border_y) < 0) + { + shell_x = (s_width - width - border_x) >> 1; + shell_y = (s_height - height - border_y) >> 1; + + gdk_window_move (gdisp->shell->window, shell_x, shell_y); + } + /* If the width or height of the display has changed, recalculate * the display offsets... */