diff options
author | Tor Lillqvist <tml@novell.com> | 2008-03-10 15:48:06 +0000 |
---|---|---|
committer | Tor Lillqvist <tml@src.gnome.org> | 2008-03-10 15:48:06 +0000 |
commit | 0f7099e308b98c84cf1bd64e59d511c4db750f4b (patch) | |
tree | 685810dbe188dcd528078fc3ae5dab9752de7aa2 | |
parent | a0d427dd996ca49d75be04ff384422e56db2a841 (diff) | |
download | gtk+-0f7099e308b98c84cf1bd64e59d511c4db750f4b.tar.gz |
Bug 520286 - Non-deletable window has no minimize / maximize buttons
2008-03-10 Tor Lillqvist <tml@novell.com>
Bug 520286 - Non-deletable window has no minimize / maximize buttons
* gdk/win32/gdkmain-win32.c (_gdk_win32_window_style_to_string):
New debugging output function that decodes a set of WS_* bits.
* gdk/win32/gdkprivate-win32.h: Declare it.
* gdk/win32/gdkwindow-win32.c (update_single_system_menu_entry):
New function that enables or disables one menu entry in the system
menu of a top-level window. (The corresponding decoration will
then also be enabled or disabled (grayed).)
(update_style_bits): Do as the comment says and don't try to
update the window style based on the GdkWMFunctions set for the
window.
(update_system_menu): New function that enables or disables the
system menu entries based on a window's stored set of
GdkWMFunctions.
(gdk_window_set_functions): Call update_system_menu() instead of
update_style_bits().
svn path=/trunk/; revision=19743
-rw-r--r-- | ChangeLog | 25 | ||||
-rw-r--r-- | gdk/win32/gdkmain-win32.c | 42 | ||||
-rw-r--r-- | gdk/win32/gdkprivate-win32.h | 1 | ||||
-rw-r--r-- | gdk/win32/gdkwindow-win32.c | 74 |
4 files changed, 119 insertions, 23 deletions
@@ -1,3 +1,28 @@ +2008-03-10 Tor Lillqvist <tml@novell.com> + + Bug 520286 - Non-deletable window has no minimize / maximize buttons + + * gdk/win32/gdkmain-win32.c (_gdk_win32_window_style_to_string): + New debugging output function that decodes a set of WS_* bits. + + * gdk/win32/gdkprivate-win32.h: Declare it. + + * gdk/win32/gdkwindow-win32.c (update_single_system_menu_entry): + New function that enables or disables one menu entry in the system + menu of a top-level window. (The corresponding decoration will + then also be enabled or disabled (grayed).) + + (update_style_bits): Do as the comment says and don't try to + update the window style based on the GdkWMFunctions set for the + window. + + (update_system_menu): New function that enables or disables the + system menu entries based on a window's stored set of + GdkWMFunctions. + + (gdk_window_set_functions): Call update_system_menu() instead of + update_style_bits(). + 2008-03-10 Emmanuele Bassi <ebassi@gnome.org> * README.in: Reword the 2.14 release notes entry about the diff --git a/gdk/win32/gdkmain-win32.c b/gdk/win32/gdkmain-win32.c index 1e86f395e4..f156c0ca84 100644 --- a/gdk/win32/gdkmain-win32.c +++ b/gdk/win32/gdkmain-win32.c @@ -544,6 +544,48 @@ _gdk_win32_window_state_to_string (GdkWindowState state) } gchar * +_gdk_win32_window_style_to_string (LONG style) +{ + gchar buf[1000]; + gchar *bufp = buf; + gchar *s = ""; + + buf[0] = '\0'; + +#define BIT(x) \ + if (style & WS_ ## x) \ + (bufp += sprintf (bufp, "%s" #x, s), s = "|") + + /* Note that many of the WS_* macros are in face several bits. + * Handle just the individual bits here. Sort as in w32api's + * winuser.h. + */ + BIT (BORDER); + BIT (CHILD); + BIT (CLIPCHILDREN); + BIT (CLIPSIBLINGS); + BIT (DISABLED); + BIT (DLGFRAME); + BIT (GROUP); + BIT (HSCROLL); + BIT (ICONIC); + BIT (MAXIMIZE); + BIT (MAXIMIZEBOX); + BIT (MINIMIZE); + BIT (MINIMIZEBOX); + BIT (POPUP); + BIT (SIZEBOX); + BIT (SYSMENU); + BIT (TABSTOP); + BIT (THICKFRAME); + BIT (VISIBLE); + BIT (VSCROLL); +#undef BIT + + return static_printf ("%s", buf); +} + +gchar * _gdk_win32_rop2_to_string (int rop2) { switch (rop2) diff --git a/gdk/win32/gdkprivate-win32.h b/gdk/win32/gdkprivate-win32.h index 46c3348b1e..8c720083d1 100644 --- a/gdk/win32/gdkprivate-win32.h +++ b/gdk/win32/gdkprivate-win32.h @@ -296,6 +296,7 @@ gchar *_gdk_win32_join_style_to_string (GdkJoinStyle join_style); gchar *_gdk_win32_line_style_to_string (GdkLineStyle line_style); gchar *_gdk_win32_gcvalues_mask_to_string (GdkGCValuesMask mask); gchar *_gdk_win32_window_state_to_string (GdkWindowState state); +gchar *_gdk_win32_window_style_to_string (LONG style); gchar *_gdk_win32_drawable_description (GdkDrawable *d); gchar *_gdk_win32_rop2_to_string (int rop2); diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c index 4586edb1ea..19762350bc 100644 --- a/gdk/win32/gdkwindow-win32.c +++ b/gdk/win32/gdkwindow-win32.c @@ -2867,14 +2867,15 @@ gdk_window_set_group (GdkWindow *window, } static void -update_single_bit (LONG *style, - BOOL all, - int gdk_bit, - int style_bit) -{ - /* all controls the interpretation of gdk_bit -- if all is true, gdk_bit - indicates whether style_bit is off; if all is false, gdk bit indicate whether - style_bit is on */ +update_single_bit (LONG *style, + gboolean all, + int gdk_bit, + int style_bit) +{ + /* all controls the interpretation of gdk_bit -- if all is TRUE, + * gdk_bit indicates whether style_bit is off; if all is FALSE, gdk + * bit indicate whether style_bit is on + */ if ((!all && gdk_bit) || (all && !gdk_bit)) *style |= style_bit; else @@ -2885,9 +2886,8 @@ static void update_style_bits (GdkWindow *window) { GdkWMDecoration decorations; - GdkWMFunction functions; LONG style, exstyle; - BOOL all; + gboolean all; RECT rect, before, after; style = GetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE); @@ -2897,6 +2897,8 @@ update_style_bits (GdkWindow *window) after = before; AdjustWindowRectEx (&before, style, FALSE, exstyle); + GDK_NOTE (MISC, g_print ("update_style_bits: style: %s", _gdk_win32_window_style_to_string (style))); + if (get_effective_window_decorations (window, &decorations)) { all = (decorations & GDK_DECOR_ALL); @@ -2908,18 +2910,8 @@ update_style_bits (GdkWindow *window) update_single_bit (&style, all, decorations & GDK_DECOR_MAXIMIZE, WS_MAXIMIZEBOX); } - /* XXX this is actually incorrect. The menu entries should be added or removed - from the system menu without affecting the window style. */ - if (_gdk_window_get_functions (window, &functions)) - { - all = (functions & GDK_DECOR_ALL); - update_single_bit (&style, all, functions & GDK_FUNC_RESIZE, WS_THICKFRAME); - update_single_bit (&style, all, functions & GDK_FUNC_MOVE, WS_THICKFRAME | WS_SYSMENU); - update_single_bit (&style, all, functions & GDK_FUNC_MINIMIZE, WS_MINIMIZE); - update_single_bit (&style, all, functions & GDK_FUNC_MOVE, WS_MAXIMIZE); - update_single_bit (&style, all, functions & GDK_FUNC_CLOSE, WS_SYSMENU); - } - + GDK_NOTE (MISC, g_print (" => %s\n", _gdk_win32_window_style_to_string (style))); + SetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE, style); AdjustWindowRectEx (&after, style, FALSE, exstyle); @@ -2935,6 +2927,42 @@ update_style_bits (GdkWindow *window) rect.right - rect.left, rect.bottom - rect.top, SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOREPOSITION | SWP_NOZORDER); + +} + +static void +update_single_system_menu_entry (HMENU hmenu, + gboolean all, + int gdk_bit, + int menu_entry) +{ + /* all controls the interpretation of gdk_bit -- if all is TRUE, + * gdk_bit indicates whether menu entry is disabled; if all is + * FALSE, gdk bit indicate whether menu entry is enabled + */ + if ((!all && gdk_bit) || (all && !gdk_bit)) + EnableMenuItem (hmenu, menu_entry, MF_BYCOMMAND | MF_ENABLED); + else + EnableMenuItem (hmenu, menu_entry, MF_BYCOMMAND | MF_GRAYED); +} + +static void +update_system_menu (GdkWindow *window) +{ + GdkWMFunction functions; + BOOL all; + + if (_gdk_window_get_functions (window, &functions)) + { + HMENU hmenu = GetSystemMenu (GDK_WINDOW_HWND (window), FALSE); + + all = (functions & GDK_DECOR_ALL); + update_single_system_menu_entry (hmenu, all, functions & GDK_FUNC_RESIZE, SC_SIZE); + update_single_system_menu_entry (hmenu, all, functions & GDK_FUNC_MOVE, SC_MOVE); + update_single_system_menu_entry (hmenu, all, functions & GDK_FUNC_MINIMIZE, SC_MINIMIZE); + update_single_system_menu_entry (hmenu, all, functions & GDK_FUNC_MAXIMIZE, SC_MAXIMIZE); + update_single_system_menu_entry (hmenu, all, functions & GDK_FUNC_CLOSE, SC_CLOSE); + } } static GQuark @@ -3020,7 +3048,7 @@ gdk_window_set_functions (GdkWindow *window, *functions_copy = functions; g_object_set_qdata_full (G_OBJECT (window), get_functions_quark (), functions_copy, g_free); - update_style_bits (window); + update_system_menu (window); } gboolean |