Alexandre Julliard : winex11:
Store wm hints in the window data instead of fetching them when needed.
Alexandre Julliard
julliard at wine.codeweavers.com
Fri Aug 17 06:30:19 CDT 2007
Module: wine
Branch: master
Commit: bde89576b385ef10ceeba16992f9895c4b5225da
URL: http://source.winehq.org/git/wine.git/?a=commit;h=bde89576b385ef10ceeba16992f9895c4b5225da
Author: Alexandre Julliard <julliard at winehq.org>
Date: Thu Aug 16 23:27:37 2007 +0200
winex11: Store wm hints in the window data instead of fetching them when needed.
---
dlls/winex11.drv/window.c | 54 +++++++++++++++++++-------------------------
dlls/winex11.drv/winpos.c | 14 ++---------
dlls/winex11.drv/x11drv.h | 1 +
3 files changed, 27 insertions(+), 42 deletions(-)
diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c
index c571684..459b8f9 100644
--- a/dlls/winex11.drv/window.c
+++ b/dlls/winex11.drv/window.c
@@ -248,9 +248,10 @@ static void destroy_icon_window( Display *display, struct x11drv_win_data *data
*
* Set the icon wm hints
*/
-static void set_icon_hints( Display *display, struct x11drv_win_data *data,
- XWMHints *hints, HICON hIcon )
+static void set_icon_hints( Display *display, struct x11drv_win_data *data, HICON hIcon )
{
+ XWMHints *hints = data->wm_hints;
+
if (data->hWMIconBitmap) DeleteObject( data->hWMIconBitmap );
if (data->hWMIconMask) DeleteObject( data->hWMIconMask);
data->hWMIconBitmap = 0;
@@ -468,7 +469,6 @@ void X11DRV_set_wm_hints( Display *display, struct x11drv_win_data *data )
{
Window group_leader;
XClassHint *class_hints;
- XWMHints* wm_hints;
Atom protocols[3];
Atom window_type;
MwmHints mwm_hints;
@@ -566,24 +566,19 @@ void X11DRV_set_wm_hints( Display *display, struct x11drv_win_data *data )
XChangeProperty( display, data->whole_window, x11drv_atom(XdndAware),
XA_ATOM, 32, PropModeReplace, (unsigned char*)&dndVersion, 1 );
- wm_hints = XAllocWMHints();
wine_tsx11_unlock();
/* wm hints */
- if (wm_hints)
+ if (data->wm_hints)
{
- wm_hints->flags = InputHint | StateHint | WindowGroupHint;
- wm_hints->input = !(style & WS_DISABLED);
-
- set_icon_hints( display, data, wm_hints,
- (HICON)GetClassLongPtrW( data->hwnd, GCLP_HICON ) );
-
- wm_hints->initial_state = (style & WS_MINIMIZE) ? IconicState : NormalState;
- wm_hints->window_group = group_leader;
+ data->wm_hints->flags = InputHint | StateHint | WindowGroupHint;
+ data->wm_hints->input = !(style & WS_DISABLED);
+ data->wm_hints->initial_state = (style & WS_MINIMIZE) ? IconicState : NormalState;
+ data->wm_hints->window_group = group_leader;
+ set_icon_hints( display, data, (HICON)GetClassLongPtrW( data->hwnd, GCLP_HICON ) );
wine_tsx11_lock();
- XSetWMHints( display, data->whole_window, wm_hints );
- XFree(wm_hints);
+ XSetWMHints( display, data->whole_window, data->wm_hints );
wine_tsx11_unlock();
}
}
@@ -599,7 +594,6 @@ void X11DRV_set_iconic_state( HWND hwnd )
Display *display = thread_display();
struct x11drv_win_data *data;
RECT rect;
- XWMHints* wm_hints;
DWORD style = GetWindowLongW( hwnd, GWL_STYLE );
BOOL iconic = (style & WS_MINIMIZE) != 0;
@@ -610,12 +604,14 @@ void X11DRV_set_iconic_state( HWND hwnd )
wine_tsx11_lock();
- if (!(wm_hints = XGetWMHints( display, data->whole_window ))) wm_hints = XAllocWMHints();
- wm_hints->flags |= StateHint | IconPositionHint;
- wm_hints->initial_state = iconic ? IconicState : NormalState;
- wm_hints->icon_x = rect.left - virtual_screen_rect.left;
- wm_hints->icon_y = rect.top - virtual_screen_rect.top;
- XSetWMHints( display, data->whole_window, wm_hints );
+ if (data->wm_hints)
+ {
+ data->wm_hints->flags |= StateHint | IconPositionHint;
+ data->wm_hints->initial_state = iconic ? IconicState : NormalState;
+ data->wm_hints->icon_x = rect.left - virtual_screen_rect.left;
+ data->wm_hints->icon_y = rect.top - virtual_screen_rect.top;
+ XSetWMHints( display, data->whole_window, data->wm_hints );
+ }
if (style & WS_VISIBLE)
{
@@ -626,7 +622,6 @@ void X11DRV_set_iconic_state( HWND hwnd )
XMapWindow( display, data->whole_window );
}
- XFree(wm_hints);
wine_tsx11_unlock();
}
@@ -913,6 +908,7 @@ void X11DRV_DestroyWindow( HWND hwnd )
if (data->hWMIconMask) DeleteObject( data->hWMIconMask);
wine_tsx11_lock();
XDeleteContext( display, (XID)hwnd, win_data_context );
+ XFree( data->wm_hints );
wine_tsx11_unlock();
HeapFree( GetProcessHeap(), 0, data );
}
@@ -938,6 +934,7 @@ static struct x11drv_win_data *alloc_win_data( Display *display, HWND hwnd )
if (!winContext) winContext = XUniqueContext();
if (!win_data_context) win_data_context = XUniqueContext();
XSaveContext( display, (XID)hwnd, win_data_context, (char *)data );
+ data->wm_hints = XAllocWMHints();
wine_tsx11_unlock();
}
return data;
@@ -1325,7 +1322,6 @@ void X11DRV_SetWindowIcon( HWND hwnd, UINT type, HICON icon )
{
Display *display = thread_display();
struct x11drv_win_data *data;
- XWMHints* wm_hints;
if (type != ICON_BIG) return; /* nothing to do here */
@@ -1333,15 +1329,11 @@ void X11DRV_SetWindowIcon( HWND hwnd, UINT type, HICON icon )
if (!data->whole_window) return;
if (!data->managed) return;
- wine_tsx11_lock();
- if (!(wm_hints = XGetWMHints( display, data->whole_window ))) wm_hints = XAllocWMHints();
- wine_tsx11_unlock();
- if (wm_hints)
+ if (data->wm_hints)
{
- set_icon_hints( display, data, wm_hints, icon );
+ set_icon_hints( display, data, icon );
wine_tsx11_lock();
- XSetWMHints( display, data->whole_window, wm_hints );
- XFree( wm_hints );
+ XSetWMHints( display, data->whole_window, data->wm_hints );
wine_tsx11_unlock();
}
}
diff --git a/dlls/winex11.drv/winpos.c b/dlls/winex11.drv/winpos.c
index 5e0e604..baee122 100644
--- a/dlls/winex11.drv/winpos.c
+++ b/dlls/winex11.drv/winpos.c
@@ -160,19 +160,11 @@ void X11DRV_SetWindowStyle( HWND hwnd, DWORD old_style )
if (changed & WS_DISABLED)
{
- if (data->whole_window && data->managed)
+ if (data->whole_window && data->wm_hints)
{
- XWMHints *wm_hints;
wine_tsx11_lock();
- if (!(wm_hints = XGetWMHints( display, data->whole_window )))
- wm_hints = XAllocWMHints();
- if (wm_hints)
- {
- wm_hints->flags |= InputHint;
- wm_hints->input = !(new_style & WS_DISABLED);
- XSetWMHints( display, data->whole_window, wm_hints );
- XFree(wm_hints);
- }
+ data->wm_hints->input = !(new_style & WS_DISABLED);
+ XSetWMHints( display, data->whole_window, data->wm_hints );
wine_tsx11_unlock();
}
}
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
index a778f64..1fca990 100644
--- a/dlls/winex11.drv/x11drv.h
+++ b/dlls/winex11.drv/x11drv.h
@@ -646,6 +646,7 @@ struct x11drv_win_data
RECT whole_rect; /* X window rectangle for the whole window relative to parent */
RECT client_rect; /* client area relative to whole window */
XIC xic; /* X input context */
+ XWMHints *wm_hints; /* window manager hints */
BOOL managed; /* is window managed? */
struct dce *dce; /* DCE for CS_OWNDC or CS_CLASSDC windows */
unsigned int lock_changes; /* lock count for X11 change requests */
More information about the wine-cvs
mailing list