2008-09-16 14:09:56 +02:00
|
|
|
/*
|
|
|
|
* property.c - property handlers
|
|
|
|
*
|
2009-08-10 11:36:11 +02:00
|
|
|
* Copyright © 2008-2009 Julien Danjou <julien@danjou.info>
|
2008-09-16 14:09:56 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <xcb/xcb_atom.h>
|
|
|
|
|
2009-04-17 16:14:09 +02:00
|
|
|
#include "screen.h"
|
2008-09-16 14:09:56 +02:00
|
|
|
#include "property.h"
|
|
|
|
#include "client.h"
|
|
|
|
#include "ewmh.h"
|
2009-05-10 14:55:13 +02:00
|
|
|
#include "wibox.h"
|
2009-08-17 16:38:56 +02:00
|
|
|
#include "window.h"
|
|
|
|
#include "luaa.h"
|
2008-09-16 14:09:56 +02:00
|
|
|
#include "common/atoms.h"
|
2009-04-17 16:52:25 +02:00
|
|
|
#include "common/xutil.h"
|
2008-09-16 14:09:56 +02:00
|
|
|
|
2009-08-24 10:05:50 +02:00
|
|
|
|
|
|
|
#define HANDLE_TEXT_PROPERTY(funcname, atom, setfunc) \
|
|
|
|
void \
|
|
|
|
property_update_##funcname(client_t *c, xcb_get_property_reply_t *reply) \
|
|
|
|
{ \
|
|
|
|
bool no_reply = !reply; \
|
|
|
|
if(no_reply) \
|
|
|
|
reply = xcb_get_property_reply(globalconf.connection, \
|
2010-08-08 16:45:56 +02:00
|
|
|
xcb_get_property(globalconf.connection, \
|
|
|
|
false, \
|
|
|
|
c->window, \
|
|
|
|
atom, \
|
|
|
|
XCB_GET_PROPERTY_TYPE_ANY, \
|
|
|
|
0, \
|
|
|
|
UINT_MAX), NULL); \
|
2009-08-24 10:05:50 +02:00
|
|
|
luaA_object_push(globalconf.L, c); \
|
|
|
|
setfunc(globalconf.L, -1, xutil_get_text_property_from_reply(reply)); \
|
|
|
|
lua_pop(globalconf.L, 1); \
|
|
|
|
if(no_reply) \
|
|
|
|
p_delete(&reply); \
|
|
|
|
} \
|
|
|
|
static int \
|
2010-08-08 16:54:36 +02:00
|
|
|
property_handle_##funcname(uint8_t state, \
|
2009-08-24 10:05:50 +02:00
|
|
|
xcb_window_t window, \
|
|
|
|
xcb_atom_t name, \
|
|
|
|
xcb_get_property_reply_t *reply) \
|
|
|
|
{ \
|
|
|
|
client_t *c = client_getbywin(window); \
|
|
|
|
if(c) \
|
|
|
|
property_update_##funcname(c, reply); \
|
|
|
|
return 0; \
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-25 16:52:18 +02:00
|
|
|
HANDLE_TEXT_PROPERTY(wm_name, WM_NAME, client_set_alt_name)
|
2009-08-25 16:39:10 +02:00
|
|
|
HANDLE_TEXT_PROPERTY(net_wm_name, _NET_WM_NAME, client_set_name)
|
2009-08-25 16:52:18 +02:00
|
|
|
HANDLE_TEXT_PROPERTY(wm_icon_name, WM_ICON_NAME, client_set_alt_icon_name)
|
2009-08-25 16:39:10 +02:00
|
|
|
HANDLE_TEXT_PROPERTY(net_wm_icon_name, _NET_WM_ICON_NAME, client_set_icon_name)
|
2009-08-24 10:05:50 +02:00
|
|
|
HANDLE_TEXT_PROPERTY(wm_client_machine, WM_CLIENT_MACHINE, client_set_machine)
|
|
|
|
HANDLE_TEXT_PROPERTY(wm_window_role, WM_WINDOW_ROLE, client_set_role)
|
|
|
|
|
|
|
|
#undef HANDLE_TEXT_PROPERTY
|
|
|
|
|
2009-08-24 11:22:28 +02:00
|
|
|
#define HANDLE_PROPERTY(name) \
|
|
|
|
static int \
|
2010-08-08 16:54:36 +02:00
|
|
|
property_handle_##name(uint8_t state, \
|
2009-08-24 11:22:28 +02:00
|
|
|
xcb_window_t window, \
|
|
|
|
xcb_atom_t name, \
|
|
|
|
xcb_get_property_reply_t *reply) \
|
|
|
|
{ \
|
|
|
|
client_t *c = client_getbywin(window); \
|
|
|
|
if(c) \
|
|
|
|
property_update_##name(c, reply); \
|
|
|
|
return 0; \
|
|
|
|
}
|
|
|
|
|
|
|
|
HANDLE_PROPERTY(wm_protocols)
|
|
|
|
HANDLE_PROPERTY(wm_transient_for)
|
|
|
|
HANDLE_PROPERTY(wm_client_leader)
|
|
|
|
HANDLE_PROPERTY(wm_normal_hints)
|
|
|
|
HANDLE_PROPERTY(wm_hints)
|
|
|
|
HANDLE_PROPERTY(wm_class)
|
|
|
|
HANDLE_PROPERTY(net_wm_icon)
|
|
|
|
HANDLE_PROPERTY(net_wm_pid)
|
|
|
|
|
|
|
|
#undef HANDLE_PROPERTY
|
|
|
|
|
2008-09-16 14:09:56 +02:00
|
|
|
void
|
|
|
|
property_update_wm_transient_for(client_t *c, xcb_get_property_reply_t *reply)
|
|
|
|
{
|
|
|
|
xcb_window_t trans;
|
|
|
|
|
|
|
|
if(reply)
|
|
|
|
{
|
|
|
|
if(!xcb_get_wm_transient_for_from_reply(&trans, reply))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(!xcb_get_wm_transient_for_reply(globalconf.connection,
|
|
|
|
xcb_get_wm_transient_for_unchecked(globalconf.connection,
|
2009-08-17 17:02:45 +02:00
|
|
|
c->window),
|
2008-09-16 14:09:56 +02:00
|
|
|
&trans, NULL))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-08-17 17:02:45 +02:00
|
|
|
luaA_object_push(globalconf.L, c);
|
|
|
|
client_set_type(globalconf.L, -1, WINDOW_TYPE_DIALOG);
|
|
|
|
client_set_above(globalconf.L, -1, false);
|
|
|
|
client_set_transient_for(globalconf.L, -1, client_getbywin(trans));
|
|
|
|
lua_pop(globalconf.L, 1);
|
2008-09-16 14:09:56 +02:00
|
|
|
}
|
|
|
|
|
2008-12-01 19:44:28 +01:00
|
|
|
/** Update leader hint of a client.
|
|
|
|
* \param c The client.
|
|
|
|
* \param reply (Optional) An existing reply.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
property_update_wm_client_leader(client_t *c, xcb_get_property_reply_t *reply)
|
|
|
|
{
|
|
|
|
xcb_get_property_cookie_t client_leader_q;
|
|
|
|
void *data;
|
|
|
|
bool no_reply = !reply;
|
|
|
|
|
|
|
|
if(no_reply)
|
|
|
|
{
|
2009-08-17 17:02:45 +02:00
|
|
|
client_leader_q = xcb_get_property_unchecked(globalconf.connection, false, c->window,
|
2008-12-01 19:44:28 +01:00
|
|
|
WM_CLIENT_LEADER, WINDOW, 0, 32);
|
|
|
|
|
|
|
|
reply = xcb_get_property_reply(globalconf.connection, client_leader_q, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(reply && reply->value_len && (data = xcb_get_property_value(reply)))
|
2009-08-17 17:02:45 +02:00
|
|
|
c->leader_window = *(xcb_window_t *) data;
|
2008-12-01 19:44:28 +01:00
|
|
|
|
|
|
|
/* Only free when we created a reply ourselves. */
|
|
|
|
if(no_reply)
|
|
|
|
p_delete(&reply);
|
|
|
|
}
|
|
|
|
|
2008-09-16 14:09:56 +02:00
|
|
|
/** Update the size hints of a client.
|
|
|
|
* \param c The client.
|
2009-07-27 06:20:00 +02:00
|
|
|
* \param reply (Optional) An existing reply.
|
2008-09-16 14:09:56 +02:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
property_update_wm_normal_hints(client_t *c, xcb_get_property_reply_t *reply)
|
|
|
|
{
|
|
|
|
if(reply)
|
|
|
|
{
|
|
|
|
if(!xcb_get_wm_size_hints_from_reply(&c->size_hints, reply))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(!xcb_get_wm_normal_hints_reply(globalconf.connection,
|
|
|
|
xcb_get_wm_normal_hints_unchecked(globalconf.connection,
|
2009-08-17 17:02:45 +02:00
|
|
|
c->window),
|
2008-09-16 14:09:56 +02:00
|
|
|
&c->size_hints, NULL))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Update the WM hints of a client.
|
|
|
|
* \param c The client.
|
2009-07-27 06:20:00 +02:00
|
|
|
* \param reply (Optional) An existing reply.
|
2008-09-16 14:09:56 +02:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
property_update_wm_hints(client_t *c, xcb_get_property_reply_t *reply)
|
|
|
|
{
|
|
|
|
xcb_wm_hints_t wmh;
|
|
|
|
|
|
|
|
if(reply)
|
|
|
|
{
|
|
|
|
if(!xcb_get_wm_hints_from_reply(&wmh, reply))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(!xcb_get_wm_hints_reply(globalconf.connection,
|
2009-08-17 17:02:45 +02:00
|
|
|
xcb_get_wm_hints_unchecked(globalconf.connection, c->window),
|
2008-09-16 14:09:56 +02:00
|
|
|
&wmh, NULL))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-08-17 17:02:45 +02:00
|
|
|
luaA_object_push(globalconf.L, c);
|
|
|
|
client_set_urgent(globalconf.L, -1, xcb_wm_hints_get_urgency(&wmh));
|
2008-10-11 09:52:03 +02:00
|
|
|
if(wmh.flags & XCB_WM_HINT_STATE &&
|
2008-09-16 14:09:56 +02:00
|
|
|
wmh.initial_state == XCB_WM_STATE_WITHDRAWN)
|
2009-08-17 17:02:45 +02:00
|
|
|
client_set_border_width(globalconf.L, -1, 0);
|
2008-09-16 14:09:56 +02:00
|
|
|
|
2008-10-11 09:52:03 +02:00
|
|
|
if(wmh.flags & XCB_WM_HINT_INPUT)
|
|
|
|
c->nofocus = !wmh.input;
|
2008-12-01 19:06:35 +01:00
|
|
|
|
|
|
|
if(wmh.flags & XCB_WM_HINT_WINDOW_GROUP)
|
2009-08-17 17:02:45 +02:00
|
|
|
client_set_group_window(globalconf.L, -1, wmh.window_group);
|
2010-02-09 14:02:38 +01:00
|
|
|
|
|
|
|
lua_pop(globalconf.L, 1);
|
2008-09-16 14:09:56 +02:00
|
|
|
}
|
|
|
|
|
2009-04-18 14:20:06 +02:00
|
|
|
/** Update WM_CLASS of a client.
|
|
|
|
* \param c The client.
|
|
|
|
* \param reply The reply to get property request, or NULL if none.
|
|
|
|
*/
|
2009-04-04 13:41:17 +02:00
|
|
|
void
|
2009-04-18 14:20:06 +02:00
|
|
|
property_update_wm_class(client_t *c, xcb_get_property_reply_t *reply)
|
2009-04-04 13:41:17 +02:00
|
|
|
{
|
|
|
|
xcb_get_wm_class_reply_t hint;
|
|
|
|
|
2009-04-18 14:20:06 +02:00
|
|
|
if(reply)
|
|
|
|
{
|
|
|
|
if(!xcb_get_wm_class_from_reply(&hint, reply))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(!xcb_get_wm_class_reply(globalconf.connection,
|
2009-08-17 17:02:45 +02:00
|
|
|
xcb_get_wm_class_unchecked(globalconf.connection, c->window),
|
2009-04-18 14:20:06 +02:00
|
|
|
&hint, NULL))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-08-17 17:02:45 +02:00
|
|
|
luaA_object_push(globalconf.L, c);
|
2009-08-24 23:02:46 +02:00
|
|
|
client_set_class_instance(globalconf.L, -1, hint.class_name, hint.instance_name);
|
2009-08-17 17:02:45 +02:00
|
|
|
lua_pop(globalconf.L, 1);
|
2009-04-04 13:41:17 +02:00
|
|
|
|
2009-04-21 08:46:36 +02:00
|
|
|
/* only delete reply if we get it ourselves */
|
|
|
|
if(!reply)
|
|
|
|
xcb_get_wm_class_reply_wipe(&hint);
|
2009-04-04 13:41:17 +02:00
|
|
|
}
|
|
|
|
|
2008-09-16 14:09:56 +02:00
|
|
|
static int
|
2010-08-08 16:54:36 +02:00
|
|
|
property_handle_net_wm_strut_partial(uint8_t state,
|
2008-09-16 14:09:56 +02:00
|
|
|
xcb_window_t window,
|
|
|
|
xcb_atom_t name,
|
|
|
|
xcb_get_property_reply_t *reply)
|
|
|
|
{
|
|
|
|
client_t *c = client_getbywin(window);
|
|
|
|
|
|
|
|
if(c)
|
2009-02-07 19:40:07 +01:00
|
|
|
ewmh_process_client_strut(c, reply);
|
2008-09-16 14:09:56 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-08-17 17:02:45 +02:00
|
|
|
void
|
|
|
|
property_update_net_wm_icon(client_t *c,
|
|
|
|
xcb_get_property_reply_t *reply)
|
|
|
|
{
|
|
|
|
luaA_object_push(globalconf.L, c);
|
|
|
|
|
|
|
|
if(reply)
|
|
|
|
{
|
|
|
|
if(ewmh_window_icon_from_reply(reply))
|
|
|
|
client_set_icon(globalconf.L, -2, -1);
|
|
|
|
}
|
|
|
|
else if(ewmh_window_icon_get_reply(ewmh_window_icon_get_unchecked(c->window)))
|
|
|
|
client_set_icon(globalconf.L, -2, -1);
|
|
|
|
|
2009-08-22 16:28:31 +02:00
|
|
|
/* remove client */
|
2009-08-17 17:02:45 +02:00
|
|
|
lua_pop(globalconf.L, 1);
|
|
|
|
}
|
|
|
|
|
2009-08-10 11:40:06 +02:00
|
|
|
void
|
|
|
|
property_update_net_wm_pid(client_t *c,
|
|
|
|
xcb_get_property_reply_t *reply)
|
|
|
|
{
|
|
|
|
bool no_reply = !reply;
|
|
|
|
|
|
|
|
if(no_reply)
|
|
|
|
{
|
|
|
|
xcb_get_property_cookie_t prop_c =
|
2009-08-17 17:02:45 +02:00
|
|
|
xcb_get_property_unchecked(globalconf.connection, false, c->window, _NET_WM_PID, CARDINAL, 0L, 1L);
|
2009-08-10 11:40:06 +02:00
|
|
|
reply = xcb_get_property_reply(globalconf.connection, prop_c, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(reply && reply->value_len)
|
|
|
|
{
|
|
|
|
uint32_t *rdata = xcb_get_property_value(reply);
|
|
|
|
if(rdata)
|
2009-08-17 17:02:45 +02:00
|
|
|
{
|
|
|
|
luaA_object_push(globalconf.L, c);
|
|
|
|
client_set_pid(globalconf.L, -1, *rdata);
|
|
|
|
lua_pop(globalconf.L, 1);
|
|
|
|
}
|
2009-08-10 11:40:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(no_reply)
|
|
|
|
p_delete(&reply);
|
|
|
|
}
|
|
|
|
|
2009-06-24 17:59:19 +02:00
|
|
|
/** Update the list of supported protocols for a client.
|
|
|
|
* \param c The client.
|
2009-08-25 04:55:10 +02:00
|
|
|
* \param reply The xcb property reply.
|
2009-06-24 17:59:19 +02:00
|
|
|
*/
|
|
|
|
void
|
2009-08-24 11:11:52 +02:00
|
|
|
property_update_wm_protocols(client_t *c, xcb_get_property_reply_t *reply)
|
2009-06-24 17:59:19 +02:00
|
|
|
{
|
|
|
|
xcb_get_wm_protocols_reply_t protocols;
|
2010-03-22 14:17:27 +01:00
|
|
|
xcb_get_property_reply_t *reply_copy;
|
2009-06-24 17:59:19 +02:00
|
|
|
|
2009-08-24 11:11:52 +02:00
|
|
|
if(reply)
|
2009-06-24 17:59:19 +02:00
|
|
|
{
|
2010-03-22 14:17:27 +01:00
|
|
|
reply_copy = p_dup(reply, 1);
|
|
|
|
|
|
|
|
if(!xcb_get_wm_protocols_from_reply(reply_copy, &protocols))
|
|
|
|
{
|
|
|
|
p_delete(&reply_copy);
|
2009-08-24 11:11:52 +02:00
|
|
|
return;
|
2010-03-22 14:17:27 +01:00
|
|
|
}
|
2009-06-24 17:59:19 +02:00
|
|
|
}
|
2009-08-24 11:11:52 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* If this fails for any reason, we still got the old value */
|
|
|
|
if(!xcb_get_wm_protocols_reply(globalconf.connection,
|
|
|
|
xcb_get_wm_protocols_unchecked(globalconf.connection,
|
|
|
|
c->window, WM_PROTOCOLS),
|
|
|
|
&protocols, NULL))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
xcb_get_wm_protocols_reply_wipe(&c->protocols);
|
|
|
|
memcpy(&c->protocols, &protocols, sizeof(protocols));
|
2009-06-24 17:59:19 +02:00
|
|
|
}
|
|
|
|
|
2008-09-16 14:09:56 +02:00
|
|
|
/** The property notify event handler.
|
2009-07-27 06:20:00 +02:00
|
|
|
* \param state currently unused
|
|
|
|
* \param window The window to obtain update the property with.
|
|
|
|
* \param name The protocol atom, currently unused.
|
|
|
|
* \param reply (Optional) An existing reply.
|
2008-09-16 14:09:56 +02:00
|
|
|
*/
|
|
|
|
static int
|
2010-08-08 16:54:36 +02:00
|
|
|
property_handle_xembed_info(uint8_t state,
|
2008-09-16 14:09:56 +02:00
|
|
|
xcb_window_t window,
|
|
|
|
xcb_atom_t name,
|
|
|
|
xcb_get_property_reply_t *reply)
|
|
|
|
{
|
2008-12-01 16:43:44 +01:00
|
|
|
xembed_window_t *emwin = xembed_getbywin(&globalconf.embedded, window);
|
2008-09-16 14:09:56 +02:00
|
|
|
|
|
|
|
if(emwin)
|
2010-08-08 16:54:36 +02:00
|
|
|
xembed_property_update(globalconf.connection, emwin, reply);
|
2008-09-16 14:09:56 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-10-06 11:42:02 +02:00
|
|
|
static int
|
2010-08-08 16:54:36 +02:00
|
|
|
property_handle_xrootpmap_id(uint8_t state,
|
2008-10-06 11:42:02 +02:00
|
|
|
xcb_window_t window,
|
|
|
|
xcb_atom_t name,
|
|
|
|
xcb_get_property_reply_t *reply)
|
|
|
|
{
|
|
|
|
if(globalconf.xinerama_is_active)
|
2009-05-10 14:55:13 +02:00
|
|
|
foreach(w, globalconf.wiboxes)
|
|
|
|
(*w)->need_update = true;
|
2008-10-06 11:42:02 +02:00
|
|
|
else
|
|
|
|
{
|
2010-08-08 16:54:36 +02:00
|
|
|
int screen = xutil_root2screen(globalconf.connection, window);
|
2009-05-10 14:55:13 +02:00
|
|
|
foreach(w, globalconf.wiboxes)
|
|
|
|
if(screen == screen_array_indexof(&globalconf.screens, (*w)->screen))
|
|
|
|
(*w)->need_update = true;
|
2008-10-06 11:42:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-05-25 16:27:17 +02:00
|
|
|
static int
|
2010-08-08 16:54:36 +02:00
|
|
|
property_handle_net_wm_opacity(uint8_t state,
|
2009-08-10 11:59:17 +02:00
|
|
|
xcb_window_t window,
|
|
|
|
xcb_atom_t name,
|
|
|
|
xcb_get_property_reply_t *reply)
|
2009-05-25 16:27:17 +02:00
|
|
|
{
|
|
|
|
wibox_t *wibox = wibox_getbywin(window);
|
|
|
|
|
2009-08-10 11:59:17 +02:00
|
|
|
if(wibox)
|
2009-08-17 16:56:03 +02:00
|
|
|
{
|
|
|
|
luaA_object_push(globalconf.L, wibox);
|
|
|
|
wibox_set_opacity(globalconf.L, -1, window_opacity_get_from_reply(reply));
|
|
|
|
lua_pop(globalconf.L, -1);
|
|
|
|
}
|
2009-08-10 11:59:17 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
client_t *c = client_getbywin(window);
|
|
|
|
if(c)
|
2009-08-17 17:02:45 +02:00
|
|
|
{
|
|
|
|
luaA_object_push(globalconf.L, c);
|
|
|
|
client_set_opacity(globalconf.L, -1, window_opacity_get_from_reply(reply));
|
|
|
|
lua_pop(globalconf.L, 1);
|
|
|
|
}
|
2009-08-10 11:59:17 +02:00
|
|
|
}
|
|
|
|
|
2009-05-25 16:27:17 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-08-08 16:45:56 +02:00
|
|
|
/** The property notify event handler.
|
|
|
|
* \param data Unused data.
|
|
|
|
* \param connection The connection to the X server.
|
|
|
|
* \param ev The event.
|
|
|
|
* \return Status code, 0 if everything's fine.
|
|
|
|
*/
|
2010-08-08 17:35:48 +02:00
|
|
|
int
|
|
|
|
property_handle_propertynotify(void *data,
|
|
|
|
xcb_connection_t *c,
|
|
|
|
xcb_property_notify_event_t *ev)
|
2008-09-16 14:09:56 +02:00
|
|
|
{
|
2010-08-08 16:45:56 +02:00
|
|
|
uint32_t length;
|
2010-08-08 16:54:36 +02:00
|
|
|
int (*handler)(uint8_t state,
|
2010-08-08 16:45:56 +02:00
|
|
|
xcb_window_t window,
|
|
|
|
xcb_atom_t name,
|
|
|
|
xcb_get_property_reply_t *reply) = NULL;
|
|
|
|
|
|
|
|
/* Find the correct event handler */
|
|
|
|
#define HANDLE(atom_, cb, len) \
|
|
|
|
if (ev->atom == atom_) \
|
|
|
|
{ \
|
|
|
|
handler = cb; \
|
|
|
|
length = len; \
|
|
|
|
} else
|
|
|
|
#define HANDLE_L(atom, cb) HANDLE(atom, cb, UINT_MAX)
|
|
|
|
#define HANDLE_S(atom, cb) HANDLE(atom, cb, 1)
|
|
|
|
#define END return 0
|
2008-09-16 14:09:56 +02:00
|
|
|
|
|
|
|
/* Xembed stuff */
|
2010-08-08 16:45:56 +02:00
|
|
|
HANDLE_L(_XEMBED_INFO, property_handle_xembed_info)
|
2008-09-16 14:09:56 +02:00
|
|
|
|
|
|
|
/* ICCCM stuff */
|
2010-08-08 16:45:56 +02:00
|
|
|
HANDLE_L(WM_TRANSIENT_FOR, property_handle_wm_transient_for)
|
|
|
|
HANDLE_L(WM_CLIENT_LEADER, property_handle_wm_client_leader)
|
|
|
|
HANDLE_L(WM_NORMAL_HINTS, property_handle_wm_normal_hints)
|
|
|
|
HANDLE_L(WM_HINTS, property_handle_wm_hints)
|
|
|
|
HANDLE_L(WM_NAME, property_handle_wm_name)
|
|
|
|
HANDLE_L(WM_ICON_NAME, property_handle_wm_icon_name)
|
|
|
|
HANDLE_L(WM_CLASS, property_handle_wm_class)
|
|
|
|
HANDLE_L(WM_PROTOCOLS, property_handle_wm_protocols)
|
|
|
|
HANDLE_L(WM_CLIENT_MACHINE, property_handle_wm_client_machine)
|
|
|
|
HANDLE_L(WM_WINDOW_ROLE, property_handle_wm_window_role)
|
2008-09-16 14:09:56 +02:00
|
|
|
|
|
|
|
/* EWMH stuff */
|
2010-08-08 16:45:56 +02:00
|
|
|
HANDLE_L(_NET_WM_NAME, property_handle_net_wm_name)
|
|
|
|
HANDLE_L(_NET_WM_ICON_NAME, property_handle_net_wm_icon_name)
|
|
|
|
HANDLE_L(_NET_WM_STRUT_PARTIAL, property_handle_net_wm_strut_partial)
|
|
|
|
HANDLE_L(_NET_WM_ICON, property_handle_net_wm_icon)
|
|
|
|
HANDLE_L(_NET_WM_PID, property_handle_net_wm_pid)
|
|
|
|
HANDLE_S(_NET_WM_WINDOW_OPACITY, property_handle_net_wm_opacity)
|
2008-10-06 11:42:02 +02:00
|
|
|
|
|
|
|
/* background change */
|
2010-08-08 16:45:56 +02:00
|
|
|
HANDLE_S(_XROOTPMAP_ID, property_handle_xrootpmap_id)
|
|
|
|
|
|
|
|
/* If nothing was found, return */
|
|
|
|
END;
|
|
|
|
|
|
|
|
#undef HANDLE_L
|
|
|
|
#undef HANDLE_S
|
|
|
|
#undef END
|
|
|
|
|
|
|
|
/* Get the property, if needed. */
|
|
|
|
xcb_get_property_reply_t *propr = NULL;
|
|
|
|
if(ev->state != XCB_PROPERTY_DELETE)
|
|
|
|
{
|
|
|
|
xcb_get_property_cookie_t cookie =
|
|
|
|
xcb_get_property(c, 0, ev->window, ev->atom,
|
|
|
|
XCB_GET_PROPERTY_TYPE_ANY, 0, length);
|
|
|
|
propr = xcb_get_property_reply(c, cookie, 0);
|
|
|
|
}
|
|
|
|
|
2010-08-08 16:54:36 +02:00
|
|
|
int ret = (*handler)(ev->state, ev->window, ev->atom, propr);
|
2010-08-08 16:45:56 +02:00
|
|
|
|
|
|
|
p_delete(&propr);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2008-09-16 14:09:56 +02:00
|
|
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|