Since this is probably somewhere on Alexandre's task list, I decided to submit this as soon as possible, to prevent duplicate work, and maybe get some comments and testing. Log: Ove Kaaven <ovek@transgaming.com> In managed mode, try to manage *all* windows, including borderless and captionless popup windows and such. Use MWM hints to remove the window manager decorations for such windows (like XMMS does). This should confuse window managers much less than the old managed/unmanaged mix. --- /dev/null Fri Nov 2 06:03:16 2001 +++ dlls/x11drv/mwm.h Sat Nov 24 09:14:19 2001 @@ -0,0 +1,65 @@ +/* + * Motif Window Manager definitions + * + * Copyright 2001 Ove Kåven, TransGaming Technologies Inc. + * (these definitions were found in GTK+ 1.2, gdk/MwmUtil.h) + */ +#ifndef __WINE_MWM_H +#define __WINE_MWM_H + +typedef struct { + unsigned long flags; + unsigned long functions; + unsigned long decorations; + long input_mode; + unsigned long status; +} MotifWmHints, MwmHints; + +#define MWM_HINTS_FUNCTIONS 1 +#define MWM_HINTS_DECORATIONS 2 +#define MWM_HINTS_INPUT_MODE 4 +#define MWM_HINTS_STATUS 8 + +#define MWM_FUNC_ALL 0x01 +#define MWM_FUNC_RESIZE 0x02 +#define MWM_FUNC_MOVE 0x04 +#define MWM_FUNC_MINIMIZE 0x08 +#define MWM_FUNC_MAXIMIZE 0x10 +#define MWM_FUNC_CLOSE 0x20 + +#define MWM_DECOR_ALL 0x01 +#define MWM_DECOR_BORDER 0x02 +#define MWM_DECOR_RESIZEH 0x04 +#define MWM_DECOR_TITLE 0x08 +#define MWM_DECOR_MENU 0x10 +#define MWM_DECOR_MINIMIZE 0x20 +#define MWM_DECOR_MAXIMIZE 0x40 + +#define MWM_INPUT_MODELESS 0 +#define MWM_INPUT_PRIMARY_APPLICATION_MODAL 1 +#define MWM_INPUT_SYSTEM_MODAL 2 +#define MWM_INPUT_FULL_APPLICATION_MODAL 3 +#define MWM_INPUT_APPLICATION_MODAL 1 + +#define MWM_TEAROFF_WINDOW 1 + +typedef struct { + long flags; + Window wm_window; +} MotifWmInfo, MwmInfo; + +#define MWM_INFO_STARTUP_STANDARD 1 +#define MWM_INFO_STARTUP_CUSTOM 2 + +#define _XA_MOTIF_WM_HINTS "_MOTIF_WM_HINTS" +#define _XA_MOTIF_WM_MESSAGES "_MOTIF_WM_MESSAGES" +#define _XA_MOTIF_WM_OFFSET "_MOTIF_WM_OFFSET" +#define _XA_MOTIF_WM_MENU "_MOTIF_WM_MENU" +#define _XA_MOTIF_WM_INFO "_MOTIF_WM_INFO" + +#define _XA_MWM_HINTS _XA_MOTIF_WM_HINTS +#define _XA_MWM_MESSAGES _XA_MOTIF_WM_MESSAGES +#define _XA_MWM_MENU _XA_MOTIF_WM_MENU +#define _XA_MWM_INFO _XA_MOTIF_WM_INFO + +#endif /* __WINE_MWM_H */ Index: dlls/x11drv/window.c =================================================================== RCS file: /home/wine/wine/dlls/x11drv/window.c,v retrieving revision 1.28 diff -u -r1.28 window.c --- dlls/x11drv/window.c 2001/10/22 19:08:34 1.28 +++ dlls/x11drv/window.c 2001/11/24 07:20:09 @@ -25,6 +25,7 @@ #include "winpos.h" #include "dce.h" #include "options.h" +#include "mwm.h" DEFAULT_DEBUG_CHANNEL(x11drv); @@ -34,6 +35,8 @@ (((exStyle) & WS_EX_DLGMODALFRAME) || \ (((style) & WS_DLGFRAME) && !((style) & WS_THICKFRAME))) +#define USE_MWM_HINTS + /* X context to associate a hwnd to an X window */ XContext winContext = 0; @@ -43,6 +46,9 @@ Atom dndProtocol = None; Atom dndSelection = None; Atom wmChangeState = None; +#ifdef USE_MWM_HINTS +Atom mwmHints = None; +#endif Atom kwmDockWindow = None; Atom _kde_net_wm_system_tray_window_for = None; /* KDE 2 Final */ @@ -65,6 +71,12 @@ if (win->dwStyle & WS_CHILD) return FALSE; /* tool windows are not managed */ if (win->dwExStyle & WS_EX_TOOLWINDOW) return FALSE; + +#ifdef USE_MWM_HINTS + /* using MWM hints, all windows can be managed */ + return TRUE; +#endif + /* windows with caption or thick frame are managed */ if ((win->dwStyle & WS_CAPTION) == WS_CAPTION) return TRUE; if (win->dwStyle & WS_THICKFRAME) return TRUE; @@ -365,12 +377,39 @@ { int val = 1; if (kwmDockWindow != None) - TSXChangeProperty( display, data->whole_window, kwmDockWindow, kwmDockWindow, - 32, PropModeReplace, (char*)&val, 1 ); + XChangeProperty( display, data->whole_window, kwmDockWindow, kwmDockWindow, + 32, PropModeReplace, (char*)&val, 1 ); if (_kde_net_wm_system_tray_window_for != None) - TSXChangeProperty( display, data->whole_window, _kde_net_wm_system_tray_window_for, - XA_WINDOW, 32, PropModeReplace, (char*)&data->whole_window, 1 ); + XChangeProperty( display, data->whole_window, _kde_net_wm_system_tray_window_for, + XA_WINDOW, 32, PropModeReplace, (char*)&data->whole_window, 1 ); + } + +#ifdef USE_MWM_HINTS + if (mwmHints != None) + { + MwmHints mwm_hints; + mwm_hints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS; + mwm_hints.functions = 0; + if ((win->dwStyle & WS_CAPTION) == WS_CAPTION) mwm_hints.functions |= MWM_FUNC_MOVE; + if (win->dwStyle & WS_THICKFRAME) mwm_hints.functions |= MWM_FUNC_MOVE | MWM_FUNC_RESIZE; + if (win->dwStyle & WS_MINIMIZE) mwm_hints.functions |= MWM_FUNC_MINIMIZE; + if (win->dwStyle & WS_MAXIMIZE) mwm_hints.functions |= MWM_FUNC_MAXIMIZE; + if (win->dwStyle & WS_SYSMENU) mwm_hints.functions |= MWM_FUNC_CLOSE; + mwm_hints.decorations = 0; + if ((win->dwStyle & WS_CAPTION) == WS_CAPTION) mwm_hints.decorations |= MWM_DECOR_TITLE; + if (win->dwExStyle & WS_EX_DLGMODALFRAME) mwm_hints.decorations |= MWM_DECOR_BORDER; + else if (win->dwStyle & WS_THICKFRAME) mwm_hints.decorations |= MWM_DECOR_BORDER | MWM_DECOR_RESIZEH; + else if ((win->dwStyle & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME) mwm_hints.decorations |= MWM_DECOR_BORDER; + else if (win->dwStyle & WS_BORDER) mwm_hints.decorations |= MWM_DECOR_BORDER; + else if (!(win->dwStyle & (WS_CHILD|WS_POPUP))) mwm_hints.decorations |= MWM_DECOR_BORDER; + if (win->dwStyle & WS_SYSMENU) mwm_hints.decorations |= MWM_DECOR_MENU; + if (win->dwStyle & WS_MINIMIZE) mwm_hints.decorations |= MWM_DECOR_MINIMIZE; + if (win->dwStyle & WS_MAXIMIZE) mwm_hints.decorations |= MWM_DECOR_MAXIMIZE; + + XChangeProperty( display, data->whole_window, mwmHints, mwmHints, 32, + PropModeReplace, (char*)&mwm_hints, sizeof(mwm_hints)/sizeof(long) ); } +#endif wine_tsx11_unlock(); @@ -599,7 +638,10 @@ wmTakeFocus = 0; /* not yet */ dndProtocol = XInternAtom( display, "DndProtocol" , False ); dndSelection = XInternAtom( display, "DndSelection" , False ); - wmChangeState = XInternAtom (display, "WM_CHANGE_STATE", False); + wmChangeState = XInternAtom( display, "WM_CHANGE_STATE", False ); +#ifdef USE_MWM_HINTS + mwmHints = XInternAtom( display, _XA_MWM_HINTS, False ); +#endif kwmDockWindow = XInternAtom( display, "KWM_DOCKWINDOW", False ); _kde_net_wm_system_tray_window_for = XInternAtom( display, "_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR", False ); wine_tsx11_unlock();