Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Compositing window managers can show and hide windows without ever af…
Browse files Browse the repository at this point in the history
…fecting the mapped state. However they do send NetWM protocol messages to indicate this is happening.

Also refactored the netwm state code so it's consistent between the places that use it.
  • Loading branch information
slouken committed Sep 28, 2012
1 parent 7994a1e commit c6ab260
Show file tree
Hide file tree
Showing 5 changed files with 172 additions and 132 deletions.
40 changes: 35 additions & 5 deletions src/video/x11/SDL_x11events.c
Expand Up @@ -109,6 +109,19 @@ static void X11_HandleGenericEvent(SDL_VideoData *videodata,XEvent event)
#endif /* SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS */


static void
X11_DispatchMapNotify(SDL_WindowData *data)
{
SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_SHOWN, 0, 0);
SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_RESTORED, 0, 0);
}

static void
X11_DispatchUnmapNotify(SDL_WindowData *data)
{
SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_HIDDEN, 0, 0);
SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_MINIMIZED, 0, 0);
}

static void
X11_DispatchEvent(_THIS)
Expand Down Expand Up @@ -315,8 +328,7 @@ X11_DispatchEvent(_THIS)
#ifdef DEBUG_XEVENTS
printf("UnmapNotify!\n");
#endif
SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_HIDDEN, 0, 0);
SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_MINIMIZED, 0, 0);
X11_DispatchUnmapNotify(data);
}
break;

Expand All @@ -325,8 +337,7 @@ X11_DispatchEvent(_THIS)
#ifdef DEBUG_XEVENTS
printf("MapNotify!\n");
#endif
SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_SHOWN, 0, 0);
SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_RESTORED, 0, 0);
X11_DispatchMapNotify(data);
}
break;

Expand Down Expand Up @@ -463,7 +474,26 @@ X11_DispatchEvent(_THIS)
}
}
}
#endif
if (status == Success) {
XFree(propdata);
}
#endif /* DEBUG_XEVENTS */

if (xevent.xproperty.atom == data->videodata->_NET_WM_STATE) {
/* Get the new state from the window manager.
Compositing window managers can alter visibility of windows
without ever mapping / unmapping them, so we handle that here,
because they use the NETWM protocol to notify us of changes.
*/
Uint32 flags = X11_GetNetWMState(_this, data->window);
if ((flags^data->window->flags) & SDL_WINDOW_HIDDEN) {
if (flags & SDL_WINDOW_HIDDEN) {
X11_DispatchUnmapNotify(data);
} else {
X11_DispatchMapNotify(data);
}
}
}
}
break;

Expand Down
2 changes: 2 additions & 0 deletions src/video/x11/SDL_x11video.c
Expand Up @@ -336,10 +336,12 @@ X11_VideoInit(_THIS)
GET_ATOM(WM_DELETE_WINDOW);
GET_ATOM(_NET_WM_STATE);
GET_ATOM(_NET_WM_STATE_HIDDEN);
GET_ATOM(_NET_WM_STATE_FOCUSED);
GET_ATOM(_NET_WM_STATE_MAXIMIZED_VERT);
GET_ATOM(_NET_WM_STATE_MAXIMIZED_HORZ);
GET_ATOM(_NET_WM_STATE_FULLSCREEN);
GET_ATOM(_NET_WM_ALLOWED_ACTIONS);
GET_ATOM(_NET_WM_ACTION_RESIZE);
GET_ATOM(_NET_WM_ACTION_FULLSCREEN);
GET_ATOM(_NET_WM_NAME);
GET_ATOM(_NET_WM_ICON_NAME);
Expand Down
2 changes: 2 additions & 0 deletions src/video/x11/SDL_x11video.h
Expand Up @@ -83,10 +83,12 @@ typedef struct SDL_VideoData
Atom WM_DELETE_WINDOW;
Atom _NET_WM_STATE;
Atom _NET_WM_STATE_HIDDEN;
Atom _NET_WM_STATE_FOCUSED;
Atom _NET_WM_STATE_MAXIMIZED_VERT;
Atom _NET_WM_STATE_MAXIMIZED_HORZ;
Atom _NET_WM_STATE_FULLSCREEN;
Atom _NET_WM_ALLOWED_ACTIONS;
Atom _NET_WM_ACTION_RESIZE;
Atom _NET_WM_ACTION_FULLSCREEN;
Atom _NET_WM_NAME;
Atom _NET_WM_ICON_NAME;
Expand Down

0 comments on commit c6ab260

Please sign in to comment.