winex11: Added tracking of the WM_STATE window property.

oldstable
Alexandre Julliard 2008-02-27 19:11:43 +01:00
parent 9939b7b430
commit 5a5344b4ad
4 changed files with 55 additions and 21 deletions

View File

@ -582,36 +582,67 @@ static void EVENT_FocusOut( HWND hwnd, XEvent *xev )
}
/***********************************************************************
* get_window_wm_state
*/
int get_window_wm_state( Display *display, struct x11drv_win_data *data )
{
struct
{
CARD32 state;
XID icon;
} *state;
Atom type;
int format, ret = -1;
unsigned long count, remaining;
wine_tsx11_lock();
if (!XGetWindowProperty( display, data->whole_window, x11drv_atom(WM_STATE), 0,
sizeof(*state)/sizeof(CARD32), False, x11drv_atom(WM_STATE),
&type, &format, &count, &remaining, (unsigned char **)&state ))
{
if (type == x11drv_atom(WM_STATE) && format && count >= sizeof(*state)/(format/8))
ret = state->state;
XFree( state );
}
wine_tsx11_unlock();
return ret;
}
/***********************************************************************
* EVENT_PropertyNotify
* We use this to release resources like Pixmaps when a selection
* client no longer needs them.
*/
static void EVENT_PropertyNotify( HWND hwnd, XEvent *xev )
{
XPropertyEvent *event = &xev->xproperty;
/* Check if we have any resources to free */
TRACE("Received PropertyNotify event:\n");
XPropertyEvent *event = &xev->xproperty;
struct x11drv_win_data *data;
switch(event->state)
{
case PropertyDelete:
if (!hwnd) return;
if (!(data = X11DRV_get_win_data( hwnd ))) return;
switch(event->state)
{
TRACE("\tPropertyDelete for atom %ld on window %ld\n",
event->atom, (long)event->window);
break;
}
case PropertyDelete:
if (event->atom == x11drv_atom(WM_STATE))
{
data->wm_state = WithdrawnState;
TRACE( "%p/%lx: WM_STATE deleted\n", data->hwnd, data->whole_window );
}
break;
case PropertyNewValue:
{
TRACE("\tPropertyNewValue for atom %ld on window %ld\n\n",
event->atom, (long)event->window);
break;
if (event->atom == x11drv_atom(WM_STATE))
{
int new_state = get_window_wm_state( event->display, data );
if (new_state != -1 && new_state != data->wm_state)
{
TRACE( "%p/%lx: new WM_STATE %d\n", data->hwnd, data->whole_window, new_state );
data->wm_state = new_state;
}
}
break;
}
default:
break;
}
}
static HWND find_drop_window( HWND hQueryWnd, LPPOINT lpPt )

View File

@ -200,7 +200,7 @@ static int get_window_attributes( Display *display, struct x11drv_win_data *data
attr->event_mask = (ExposureMask | PointerMotionMask |
ButtonPressMask | ButtonReleaseMask | EnterWindowMask |
KeyPressMask | KeyReleaseMask | FocusChangeMask | KeymapStateMask);
if (data->managed) attr->event_mask |= StructureNotifyMask;
if (data->managed) attr->event_mask |= StructureNotifyMask | PropertyChangeMask;
return (CWOverrideRedirect | CWSaveUnder | CWColormap | CWCursor |
CWEventMask | CWBitGravity | CWBackingStore);

View File

@ -559,6 +559,7 @@ enum x11drv_atoms
XATOM_RAW_CAP_HEIGHT,
XATOM_WM_PROTOCOLS,
XATOM_WM_DELETE_WINDOW,
XATOM_WM_STATE,
XATOM_WM_TAKE_FOCUS,
XATOM_KWM_DOCKWINDOW,
XATOM_DndProtocol,
@ -669,6 +670,7 @@ struct x11drv_win_data
XWMHints *wm_hints; /* window manager hints */
BOOL managed : 1; /* is window managed? */
BOOL mapped : 1; /* is window mapped? (in either normal or iconic state) */
int wm_state; /* current value of the WM_STATE property */
DWORD net_wm_state; /* bit mask of active x11drv_net_wm_state values */
unsigned int lock_changes; /* lock count for X11 change requests */
HBITMAP hWMIconBitmap;

View File

@ -123,6 +123,7 @@ static const char * const atom_names[NB_XATOMS - FIRST_XATOM] =
"RAW_CAP_HEIGHT",
"WM_PROTOCOLS",
"WM_DELETE_WINDOW",
"WM_STATE",
"WM_TAKE_FOCUS",
"KWM_DOCKWINDOW",
"DndProtocol",