From 9acd99d409bac5b94c5fa87cde0cd5cbb68a14c2 Mon Sep 17 00:00:00 2001 From: edyfox Date: Thu, 24 Sep 2009 02:32:05 +0000 Subject: [PATCH] Merged from the latest developing branch. git-svn-id: https://vim.svn.sourceforge.net/svnroot/vim/trunk@1615 2a77ed30-b011-0410-a7ad-c7884a0aa172 --- src/gui.c | 33 +++++++++++++++++++++++++++++++-- src/gui_gtk_x11.c | 40 +++++++++++++++++++++++++++++++++++----- src/proto/gui_gtk_x11.pro | 2 ++ src/version.c | 4 ++++ 4 files changed, 72 insertions(+), 7 deletions(-) diff --git a/src/gui.c b/src/gui.c index c25f760e..48e7b0fb 100644 --- a/src/gui.c +++ b/src/gui.c @@ -1386,6 +1386,10 @@ gui_set_shellsize(mustset, fit_to_display, direction) int min_height; int screen_w; int screen_h; +#ifdef HAVE_GTK2 + int un_maximize = mustset; + int did_adjust = 0; +#endif if (!gui.shell_created) return; @@ -1425,22 +1429,47 @@ gui_set_shellsize(mustset, fit_to_display, direction) if (Columns < MIN_COLUMNS) Columns = MIN_COLUMNS; width = Columns * gui.char_width + base_width; +#ifdef HAVE_GTK2 + ++did_adjust; +#endif } if ((direction & RESIZE_VERT) && height > screen_h) { Rows = (screen_h - base_height) / gui.char_height; check_shellsize(); height = Rows * gui.char_height + base_height; +#ifdef HAVE_GTK2 + ++did_adjust; +#endif } +#ifdef HAVE_GTK2 + if (did_adjust == 2 || (width + gui.char_width >= screen_w + && height + gui.char_height >= screen_h)) + /* don't unmaximize if at maximum size */ + un_maximize = FALSE; +#endif } gui.num_cols = Columns; gui.num_rows = Rows; min_width = base_width + MIN_COLUMNS * gui.char_width; min_height = base_height + MIN_LINES * gui.char_height; -# ifdef FEAT_WINDOWS +#ifdef FEAT_WINDOWS min_height += tabline_height() * gui.char_height; -# endif +#endif + +#ifdef HAVE_GTK2 + if (un_maximize) + { + /* If the window size is smaller than the screen unmaximize the + * window, otherwise resizing won't work. */ + gui_mch_get_screen_dimensions(&screen_w, &screen_h); + if ((width + gui.char_width < screen_w + || height + gui.char_height * 2 < screen_h) + && gui_mch_maximized()) + gui_mch_unmaximize(); + } +#endif gui_mch_set_shellsize(width, height, min_width, min_height, base_width, base_height, direction); diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c index 5281453d..ad6fc25e 100644 --- a/src/gui_gtk_x11.c +++ b/src/gui_gtk_x11.c @@ -4066,6 +4066,8 @@ gui_mch_open(void) { guicolor_T fg_pixel = INVALCOLOR; guicolor_T bg_pixel = INVALCOLOR; + guint pixel_width; + guint pixel_height; #ifdef HAVE_GTK2 /* @@ -4106,8 +4108,6 @@ gui_mch_open(void) unsigned int w, h; int x = 0; int y = 0; - guint pixel_width; - guint pixel_height; mask = XParseGeometry((char *)gui.geom, &x, &y, &w, &h); @@ -4160,9 +4160,16 @@ gui_mch_open(void) } } - gtk_form_set_size(GTK_FORM(gui.formwin), - (guint)(gui_get_base_width() + Columns * gui.char_width), - (guint)(gui_get_base_height() + Rows * gui.char_height)); + pixel_width = (guint)(gui_get_base_width() + Columns * gui.char_width); + pixel_height = (guint)(gui_get_base_height() + Rows * gui.char_height); +#ifdef HAVE_GTK2 + /* For GTK2 changing the size of the form widget doesn't cause window + * resizing. */ + if (gtk_socket_id == 0) + gtk_window_resize(GTK_WINDOW(gui.mainwin), pixel_width, pixel_height); +#else + gtk_form_set_size(GTK_FORM(gui.formwin), pixel_width, pixel_height); +#endif update_window_manager_hints(0, 0); if (foreground_argument != NULL) @@ -4369,6 +4376,29 @@ force_shell_resize_idle(gpointer data) #endif #endif /* HAVE_GTK2 */ +#if defined(HAVE_GTK2) || defined(PROTO) +/* + * Return TRUE if the main window is maximized. + */ + int +gui_mch_maximized() +{ + return (gui.mainwin != NULL && gui.mainwin->window != NULL + && (gdk_window_get_state(gui.mainwin->window) + & GDK_WINDOW_STATE_MAXIMIZED)); +} + +/* + * Unmaximize the main window + */ + void +gui_mch_unmaximize() +{ + if (gui.mainwin != NULL) + gtk_window_unmaximize(GTK_WINDOW(gui.mainwin)); +} +#endif + /* * Set the windows size. */ diff --git a/src/proto/gui_gtk_x11.pro b/src/proto/gui_gtk_x11.pro index 87ff6da4..93b65bf7 100644 --- a/src/proto/gui_gtk_x11.pro +++ b/src/proto/gui_gtk_x11.pro @@ -16,6 +16,8 @@ int gui_mch_open __ARGS((void)); void gui_mch_exit __ARGS((int rc)); int gui_mch_get_winpos __ARGS((int *x, int *y)); void gui_mch_set_winpos __ARGS((int x, int y)); +int gui_mch_maximized __ARGS((void)); +void gui_mch_unmaximize __ARGS((void)); void gui_mch_set_shellsize __ARGS((int width, int height, int min_width, int min_height, int base_width, int base_height, int direction)); void gui_mch_get_screen_dimensions __ARGS((int *screen_w, int *screen_h)); void gui_mch_settitle __ARGS((char_u *title, char_u *icon)); diff --git a/src/version.c b/src/version.c index ae540d7d..3633057d 100644 --- a/src/version.c +++ b/src/version.c @@ -677,6 +677,10 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 264, +/**/ + 263, +/**/ 262, /**/ 261, -- 2.11.4.GIT