xwayland: Add WM_STATE modal property

Adds a modal property to indicate whether the surface wants to be a
modal.
This commit is contained in:
Ryan Dwyer 2018-09-02 14:23:22 +10:00 committed by emersion
parent a0bf3f150e
commit 69a5279f79
3 changed files with 14 additions and 2 deletions

View File

@ -138,6 +138,7 @@ struct wlr_xwayland_surface {
struct wl_event_source *ping_timer; struct wl_event_source *ping_timer;
// _NET_WM_STATE // _NET_WM_STATE
bool modal;
bool fullscreen; bool fullscreen;
bool maximized_vert, maximized_horz; bool maximized_vert, maximized_horz;

View File

@ -40,6 +40,7 @@ enum atom_name {
_NET_WM_MOVERESIZE, _NET_WM_MOVERESIZE,
_NET_WM_NAME, _NET_WM_NAME,
_NET_SUPPORTING_WM_CHECK, _NET_SUPPORTING_WM_CHECK,
_NET_WM_STATE_MODAL,
_NET_WM_STATE_FULLSCREEN, _NET_WM_STATE_FULLSCREEN,
_NET_WM_STATE_MAXIMIZED_VERT, _NET_WM_STATE_MAXIMIZED_VERT,
_NET_WM_STATE_MAXIMIZED_HORZ, _NET_WM_STATE_MAXIMIZED_HORZ,

View File

@ -39,6 +39,7 @@ const char *atom_map[ATOM_LAST] = {
"_NET_WM_MOVERESIZE", "_NET_WM_MOVERESIZE",
"_NET_WM_NAME", "_NET_WM_NAME",
"_NET_SUPPORTING_WM_CHECK", "_NET_SUPPORTING_WM_CHECK",
"_NET_WM_STATE_MODAL",
"_NET_WM_STATE_FULLSCREEN", "_NET_WM_STATE_FULLSCREEN",
"_NET_WM_STATE_MAXIMIZED_VERT", "_NET_WM_STATE_MAXIMIZED_VERT",
"_NET_WM_STATE_MAXIMIZED_HORZ", "_NET_WM_STATE_MAXIMIZED_HORZ",
@ -268,6 +269,9 @@ static void xsurface_set_net_wm_state(struct wlr_xwayland_surface *xsurface) {
int i; int i;
i = 0; i = 0;
if (xsurface->modal) {
property[i++] = xwm->atoms[_NET_WM_STATE_MODAL];
}
if (xsurface->fullscreen) { if (xsurface->fullscreen) {
property[i++] = xwm->atoms[_NET_WM_STATE_FULLSCREEN]; property[i++] = xwm->atoms[_NET_WM_STATE_FULLSCREEN];
} }
@ -575,7 +579,9 @@ static void read_surface_net_wm_state(struct wlr_xwm *xwm,
xsurface->fullscreen = 0; xsurface->fullscreen = 0;
xcb_atom_t *atom = xcb_get_property_value(reply); xcb_atom_t *atom = xcb_get_property_value(reply);
for (uint32_t i = 0; i < reply->value_len; i++) { for (uint32_t i = 0; i < reply->value_len; i++) {
if (atom[i] == xwm->atoms[_NET_WM_STATE_FULLSCREEN]) { if (atom[i] == xwm->atoms[_NET_WM_STATE_MODAL]) {
xsurface->modal = true;
} else if (atom[i] == xwm->atoms[_NET_WM_STATE_FULLSCREEN]) {
xsurface->fullscreen = true; xsurface->fullscreen = true;
} else if (atom[i] == xwm->atoms[_NET_WM_STATE_MAXIMIZED_VERT]) { } else if (atom[i] == xwm->atoms[_NET_WM_STATE_MAXIMIZED_VERT]) {
xsurface->maximized_vert = true; xsurface->maximized_vert = true;
@ -1028,7 +1034,10 @@ static void xwm_handle_net_wm_state_message(struct wlr_xwm *xwm,
for (size_t i = 0; i < 2; ++i) { for (size_t i = 0; i < 2; ++i) {
uint32_t property = client_message->data.data32[1 + i]; uint32_t property = client_message->data.data32[1 + i];
if (property == xwm->atoms[_NET_WM_STATE_FULLSCREEN] && if (property == xwm->atoms[_NET_WM_STATE_MODAL] &&
update_state(action, &xsurface->modal)) {
xsurface_set_net_wm_state(xsurface);
} else if (property == xwm->atoms[_NET_WM_STATE_FULLSCREEN] &&
update_state(action, &xsurface->fullscreen)) { update_state(action, &xsurface->fullscreen)) {
xsurface_set_net_wm_state(xsurface); xsurface_set_net_wm_state(xsurface);
} else if (property == xwm->atoms[_NET_WM_STATE_MAXIMIZED_VERT] && } else if (property == xwm->atoms[_NET_WM_STATE_MAXIMIZED_VERT] &&
@ -1630,6 +1639,7 @@ struct wlr_xwm *xwm_create(struct wlr_xwayland *wlr_xwayland) {
xwm->atoms[NET_WM_STATE], xwm->atoms[NET_WM_STATE],
xwm->atoms[_NET_ACTIVE_WINDOW], xwm->atoms[_NET_ACTIVE_WINDOW],
xwm->atoms[_NET_WM_MOVERESIZE], xwm->atoms[_NET_WM_MOVERESIZE],
xwm->atoms[_NET_WM_STATE_MODAL],
xwm->atoms[_NET_WM_STATE_FULLSCREEN], xwm->atoms[_NET_WM_STATE_FULLSCREEN],
xwm->atoms[_NET_WM_STATE_MAXIMIZED_VERT], xwm->atoms[_NET_WM_STATE_MAXIMIZED_VERT],
xwm->atoms[_NET_WM_STATE_MAXIMIZED_HORZ], xwm->atoms[_NET_WM_STATE_MAXIMIZED_HORZ],