client: split X props; handle fullscreen status

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-08-25 16:38:45 +02:00
parent 0dde158b5f
commit 7cf2b6615f
5 changed files with 52 additions and 28 deletions

View File

@ -146,7 +146,7 @@ scan(void)
state = window_state_get_reply(state_wins[i]); state = window_state_get_reply(state_wins[i]);
has_awesome_prop = xutil_text_prop_get(globalconf.connection, wins[i], has_awesome_prop = xutil_text_prop_get(globalconf.connection, wins[i],
_AWESOME_PROPERTIES, NULL, NULL); _AWESOME_TAGS, NULL, NULL);
if(!attr_r || attr_r->override_redirect if(!attr_r || attr_r->override_redirect
|| (attr_r->map_state != XCB_MAP_STATE_VIEWABLE && !has_awesome_prop) || (attr_r->map_state != XCB_MAP_STATE_VIEWABLE && !has_awesome_prop)

View File

@ -71,27 +71,45 @@ client_loadprops(client_t * c, screen_t *screen)
ssize_t len; ssize_t len;
tag_array_t *tags = &screen->tags; tag_array_t *tags = &screen->tags;
char *prop = NULL; char *prop = NULL;
xcb_get_property_cookie_t floating_q, fullscreen_q;
xcb_get_property_reply_t *reply;
void *data;
if(!xutil_text_prop_get(globalconf.connection, c->win, _AWESOME_PROPERTIES, if(!xutil_text_prop_get(globalconf.connection, c->win, _AWESOME_TAGS,
&prop, &len)) &prop, &len))
return false; return false;
if(len != tags->len + 2) /* Send the GetProperty requests which will be processed later */
{ floating_q = xcb_get_property_unchecked(globalconf.connection, false, c->win,
/* ignore property if the tag count isn't matching */ _AWESOME_FLOATING, CARDINAL, 0, 1);
p_delete(&prop);
return false;
}
fullscreen_q = xcb_get_property_unchecked(globalconf.connection, false, c->win,
_AWESOME_FULLSCREEN, CARDINAL, 0, 1);
/* ignore property if the tag count isn't matching */
if(len == tags->len)
for(int i = 0; i < tags->len; i++) for(int i = 0; i < tags->len; i++)
if(prop[i] == '1') if(prop[i] == '1')
tag_client(c, tags->tab[i]); tag_client(c, tags->tab[i]);
else else
untag_client(c, tags->tab[i]); untag_client(c, tags->tab[i]);
client_setlayer(c, prop[tags->len + 1] - '0');
client_setfloating(c, prop[tags->len] == '1');
p_delete(&prop); p_delete(&prop);
/* check for floating */
reply = xcb_get_property_reply(globalconf.connection, floating_q, NULL);
if(reply && reply->value_len && (data = xcb_get_property_value(reply)))
client_setfloating(c, *(bool *) data);
p_delete(&reply);
/* check for fullscreen */
reply = xcb_get_property_reply(globalconf.connection, fullscreen_q, NULL);
if(reply && reply->value_len && (data = xcb_get_property_value(reply)))
client_setfullscreen(c, *(bool *) data);
p_delete(&reply);
return true; return true;
} }
@ -609,7 +627,6 @@ client_setlayer(client_t *c, layer_t layer)
{ {
c->layer = layer; c->layer = layer;
client_raise(c); client_raise(c);
client_saveprops(c);
} }
/** Set a clinet floating. /** Set a clinet floating.
@ -632,8 +649,11 @@ client_setfloating(client_t *c, bool floating)
} }
client_need_arrange(c); client_need_arrange(c);
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS); widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
client_saveprops(c);
client_stack(); client_stack();
xcb_change_property(globalconf.connection,
XCB_PROP_MODE_REPLACE,
c->win, _AWESOME_FLOATING, CARDINAL, 8, 1,
&c->isfloating);
} }
} }
@ -693,6 +713,10 @@ client_setfullscreen(client_t *c, bool s)
client_resize(c, geometry, false); client_resize(c, geometry, false);
client_need_arrange(c); client_need_arrange(c);
client_stack(); client_stack();
xcb_change_property(globalconf.connection,
XCB_PROP_MODE_REPLACE,
c->win, _AWESOME_FULLSCREEN, CARDINAL, 8, 1,
&c->isfullscreen);
} }
} }
@ -756,19 +780,16 @@ client_setontop(client_t *c, bool s)
* \param c The client. * \param c The client.
*/ */
void void
client_saveprops(client_t *c) client_saveprops_tags(client_t *c)
{ {
tag_array_t *tags = &globalconf.screens[c->screen].tags; tag_array_t *tags = &globalconf.screens[c->screen].tags;
unsigned char *prop = p_alloca(unsigned char, tags->len + 3); unsigned char *prop = p_alloca(unsigned char, tags->len + 1);
int i; int i;
for(i = 0; i < tags->len; i++) for(i = 0; i < tags->len; i++)
prop[i] = is_client_tagged(c, tags->tab[i]) ? '1' : '0'; prop[i] = is_client_tagged(c, tags->tab[i]) ? '1' : '0';
prop[i++] = c->isfloating ? '1' : '0'; xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, c->win, _AWESOME_TAGS, STRING, 8, i, prop);
prop[i++] = '0' + c->layer;
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, c->win, _AWESOME_PROPERTIES, STRING, 8, i, prop);
} }
/** Unban a client. /** Unban a client.
@ -828,7 +849,8 @@ client_unmanage(client_t *c)
ewmh_update_net_client_list(c->phys_screen); ewmh_update_net_client_list(c->phys_screen);
/* delete properties */ /* delete properties */
xcb_delete_property(globalconf.connection, c->win, _AWESOME_PROPERTIES); xcb_delete_property(globalconf.connection, c->win, _AWESOME_TAGS);
xcb_delete_property(globalconf.connection, c->win, _AWESOME_FLOATING);
/* set client as invalid */ /* set client as invalid */
c->invalid = true; c->invalid = true;

View File

@ -48,7 +48,7 @@ void client_unmanage(client_t *);
void client_updatewmhints(client_t *); void client_updatewmhints(client_t *);
bool client_updatesizehints(client_t *, xcb_size_hints_t *); bool client_updatesizehints(client_t *, xcb_size_hints_t *);
bool client_updatetitle(client_t *); bool client_updatetitle(client_t *);
void client_saveprops(client_t *); void client_saveprops_tags(client_t *);
void client_kill(client_t *); void client_kill(client_t *);
void client_setfloating(client_t *, bool); void client_setfloating(client_t *, bool);
void client_setsticky(client_t *, bool); void client_setsticky(client_t *, bool);

View File

@ -31,7 +31,9 @@ _NET_WM_STATE_MODAL
_NET_WM_STATE_HIDDEN _NET_WM_STATE_HIDDEN
_NET_WM_STATE_DEMANDS_ATTENTION _NET_WM_STATE_DEMANDS_ATTENTION
UTF8_STRING UTF8_STRING
_AWESOME_PROPERTIES _AWESOME_FLOATING
_AWESOME_FULLSCREEN
_AWESOME_TAGS
WM_PROTOCOLS WM_PROTOCOLS
WM_DELETE_WINDOW WM_DELETE_WINDOW
_XEMBED _XEMBED

4
tag.c
View File

@ -133,7 +133,7 @@ tag_client(client_t *c, tag_t *t)
tag_ref(&t); tag_ref(&t);
client_array_append(&t->clients, c); client_array_append(&t->clients, c);
client_saveprops(c); client_saveprops_tags(c);
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS); widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
client_need_arrange(c); client_need_arrange(c);
} }
@ -151,7 +151,7 @@ untag_client(client_t *c, tag_t *t)
client_need_arrange(c); client_need_arrange(c);
client_array_take(&t->clients, i); client_array_take(&t->clients, i);
tag_unref(&t); tag_unref(&t);
client_saveprops(c); client_saveprops_tags(c);
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS); widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
return; return;
} }