gtk+ r19743 - in trunk: . gdk/win32
- From: tml svn gnome org
- To: svn-commits-list gnome org
- Subject: gtk+ r19743 - in trunk: . gdk/win32
- Date: Mon, 10 Mar 2008 15:48:07 +0000 (GMT)
Author: tml
Date: Mon Mar 10 15:48:06 2008
New Revision: 19743
URL: http://svn.gnome.org/viewvc/gtk+?rev=19743&view=rev
Log:
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().
Modified:
trunk/ChangeLog
trunk/gdk/win32/gdkmain-win32.c
trunk/gdk/win32/gdkprivate-win32.h
trunk/gdk/win32/gdkwindow-win32.c
Modified: trunk/gdk/win32/gdkmain-win32.c
==============================================================================
--- trunk/gdk/win32/gdkmain-win32.c (original)
+++ trunk/gdk/win32/gdkmain-win32.c Mon Mar 10 15:48:06 2008
@@ -544,6 +544,48 @@
}
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)
Modified: trunk/gdk/win32/gdkprivate-win32.h
==============================================================================
--- trunk/gdk/win32/gdkprivate-win32.h (original)
+++ trunk/gdk/win32/gdkprivate-win32.h Mon Mar 10 15:48:06 2008
@@ -296,6 +296,7 @@
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);
Modified: trunk/gdk/win32/gdkwindow-win32.c
==============================================================================
--- trunk/gdk/win32/gdkwindow-win32.c (original)
+++ trunk/gdk/win32/gdkwindow-win32.c Mon Mar 10 15:48:06 2008
@@ -2867,14 +2867,15 @@
}
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 @@
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 @@
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_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 @@
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 @@
*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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]