+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
}
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
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);
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);
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);
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
*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