atom: new atom infra

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-06-30 18:25:01 +02:00
parent 15111d8584
commit 5daa38ac2d
6 changed files with 269 additions and 186 deletions

View File

@ -58,6 +58,7 @@ set(AWE_SRCS
${SOURCE_DIR}/widget.c ${SOURCE_DIR}/widget.c
${SOURCE_DIR}/window.c ${SOURCE_DIR}/window.c
${SOURCE_DIR}/common/buffer.c ${SOURCE_DIR}/common/buffer.c
${SOURCE_DIR}/common/atoms.c
${SOURCE_DIR}/common/configopts.c ${SOURCE_DIR}/common/configopts.c
${SOURCE_DIR}/common/draw.c ${SOURCE_DIR}/common/draw.c
${SOURCE_DIR}/common/markup.c ${SOURCE_DIR}/common/markup.c

View File

@ -39,6 +39,7 @@
#include "common/socket.h" #include "common/socket.h"
#include "common/version.h" #include "common/version.h"
#include "common/configopts.h" #include "common/configopts.h"
#include "common/atoms.h"
#include "config.h" #include "config.h"
awesome_t globalconf; awesome_t globalconf;
@ -390,8 +391,8 @@ main(int argc, char **argv)
xutil_getlockmask(globalconf.connection, globalconf.keysyms, &globalconf.numlockmask, xutil_getlockmask(globalconf.connection, globalconf.keysyms, &globalconf.numlockmask,
&globalconf.shiftlockmask, &globalconf.capslockmask); &globalconf.shiftlockmask, &globalconf.capslockmask);
/* init Atoms cache and then EWMH atoms */ /* init atom cache */
ewmh_init_atoms(); atoms_init(globalconf.connection);
/* init screens struct */ /* init screens struct */
globalconf.screens_info = screensinfo_new(globalconf.connection); globalconf.screens_info = screensinfo_new(globalconf.connection);
@ -454,7 +455,7 @@ main(int argc, char **argv)
xutil_screen_get(globalconf.connection, screen_nbr)->root, xutil_screen_get(globalconf.connection, screen_nbr)->root,
XCB_CW_EVENT_MASK | XCB_CW_CURSOR, XCB_CW_EVENT_MASK | XCB_CW_CURSOR,
change_win_vals); change_win_vals);
ewmh_set_supported_hints(screen_nbr); ewmh_init(screen_nbr);
systray_init(screen_nbr); systray_init(screen_nbr);
} }

128
common/atoms.c Normal file
View File

@ -0,0 +1,128 @@
/*
* atoms.c - X atoms functions
*
* Copyright © 2007-2008 Julien Danjou <julien@danjou.info>
*
* 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 "common/atoms.h"
#include "common/util.h"
xcb_atom_t NET_SUPPORTED;
xcb_atom_t NET_CLIENT_LIST;
xcb_atom_t NET_CLIENT_LIST_STACKING;
xcb_atom_t NET_NUMBER_OF_DESKTOPS;
xcb_atom_t NET_CURRENT_DESKTOP;
xcb_atom_t NET_DESKTOP_NAMES;
xcb_atom_t NET_ACTIVE_WINDOW;
xcb_atom_t NET_WORKAREA;
xcb_atom_t NET_SUPPORTING_WM_CHECK;
xcb_atom_t NET_CLOSE_WINDOW;
xcb_atom_t NET_WM_NAME;
xcb_atom_t NET_WM_VISIBLE_NAME;
xcb_atom_t NET_WM_DESKTOP;
xcb_atom_t NET_WM_ICON_NAME;
xcb_atom_t NET_WM_VISIBLE_ICON_NAME;
xcb_atom_t NET_WM_WINDOW_TYPE;
xcb_atom_t NET_WM_WINDOW_TYPE_NORMAL;
xcb_atom_t NET_WM_WINDOW_TYPE_DESKTOP;
xcb_atom_t NET_WM_WINDOW_TYPE_DOCK;
xcb_atom_t NET_WM_WINDOW_TYPE_SPLASH;
xcb_atom_t NET_WM_WINDOW_TYPE_DIALOG;
xcb_atom_t NET_WM_ICON;
xcb_atom_t NET_WM_PID;
xcb_atom_t NET_WM_STATE;
xcb_atom_t NET_WM_STATE_STICKY;
xcb_atom_t NET_WM_STATE_SKIP_TASKBAR;
xcb_atom_t NET_WM_STATE_FULLSCREEN;
xcb_atom_t NET_WM_STATE_ABOVE;
xcb_atom_t NET_WM_STATE_BELOW;
xcb_atom_t NET_WM_STATE_MODAL;
xcb_atom_t NET_WM_STATE_HIDDEN;
xcb_atom_t NET_WM_STATE_DEMANDS_ATTENTION;
xcb_atom_t UTF8_STRING;
typedef struct
{
const char *name;
xcb_atom_t *atom;
} atom_item_t;
static atom_item_t ATOM_LIST[] =
{
{ "_NET_SUPPORTED", &NET_SUPPORTED },
{ "_NET_CLIENT_LIST", &NET_CLIENT_LIST },
{ "_NET_CLIENT_LIST_STACKING", &NET_CLIENT_LIST_STACKING },
{ "_NET_NUMBER_OF_DESKTOPS", &NET_NUMBER_OF_DESKTOPS },
{ "_NET_CURRENT_DESKTOP", &NET_CURRENT_DESKTOP },
{ "_NET_DESKTOP_NAMES", &NET_DESKTOP_NAMES },
{ "_NET_ACTIVE_WINDOW", &NET_ACTIVE_WINDOW },
{ "_NET_WORKAREA", &NET_WORKAREA },
{ "_NET_SUPPORTING_WM_CHECK", &NET_SUPPORTING_WM_CHECK },
{ "_NET_CLOSE_WINDOW", &NET_CLOSE_WINDOW },
{ "_NET_WM_NAME", &NET_WM_NAME },
{ "_NET_WM_VISIBLE_NAME", &NET_WM_VISIBLE_NAME },
{ "_NET_WM_DESKTOP", &NET_WM_DESKTOP },
{ "_NET_WM_ICON_NAME", &NET_WM_ICON_NAME },
{ "_NET_WM_VISIBLE_ICON_NAME", &NET_WM_VISIBLE_ICON_NAME },
{ "_NET_WM_WINDOW_TYPE", &NET_WM_WINDOW_TYPE },
{ "_NET_WM_WINDOW_TYPE_NORMAL", &NET_WM_WINDOW_TYPE_NORMAL },
{ "_NET_WM_WINDOW_TYPE_DESKTOP", &NET_WM_WINDOW_TYPE_DESKTOP },
{ "_NET_WM_WINDOW_TYPE_DOCK", &NET_WM_WINDOW_TYPE_DOCK },
{ "_NET_WM_WINDOW_TYPE_SPLASH", &NET_WM_WINDOW_TYPE_SPLASH },
{ "_NET_WM_WINDOW_TYPE_DIALOG", &NET_WM_WINDOW_TYPE_DIALOG },
{ "_NET_WM_ICON", &NET_WM_ICON },
{ "_NET_WM_PID", &NET_WM_PID },
{ "_NET_WM_STATE", &NET_WM_STATE },
{ "_NET_WM_STATE_STICKY", &NET_WM_STATE_STICKY },
{ "_NET_WM_STATE_SKIP_TASKBAR", &NET_WM_STATE_SKIP_TASKBAR },
{ "_NET_WM_STATE_FULLSCREEN", &NET_WM_STATE_FULLSCREEN },
{ "_NET_WM_STATE_ABOVE", &NET_WM_STATE_ABOVE },
{ "_NET_WM_STATE_BELOW", &NET_WM_STATE_BELOW },
{ "_NET_WM_STATE_MODAL", &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 },
};
void
atoms_init(xcb_connection_t *conn)
{
unsigned int i;
xcb_intern_atom_cookie_t cs[countof(ATOM_LIST)];
xcb_intern_atom_reply_t *r;
/* Create the atom and get the reply in a XCB way (e.g. send all
* the requests at the same time and then get the replies) */
for(i = 0; i < countof(ATOM_LIST); i++)
cs[i] = xcb_intern_atom_unchecked(conn,
false,
a_strlen(ATOM_LIST[i].name),
ATOM_LIST[i].name);
for(i = 0; i < countof(ATOM_LIST); i++)
{
if(!(r = xcb_intern_atom_reply(conn, cs[i], NULL)))
/* An error occured, get reply for next atom */
continue;
*ATOM_LIST[i].atom = r->atom;
p_delete(&r);
}
}
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80

64
common/atoms.h Normal file
View File

@ -0,0 +1,64 @@
/*
* atoms.h - atoms header
*
* Copyright © 2007-2008 Julien Danjou <julien@danjou.info>
*
* 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.
*
*/
#ifndef AWESOME_COMMON_ATOMS_H
#define AWESOME_COMMON_ATOMS_H
#include <xcb/xcb.h>
extern xcb_atom_t NET_SUPPORTED;
extern xcb_atom_t NET_CLIENT_LIST;
extern xcb_atom_t NET_CLIENT_LIST_STACKING;
extern xcb_atom_t NET_NUMBER_OF_DESKTOPS;
extern xcb_atom_t NET_CURRENT_DESKTOP;
extern xcb_atom_t NET_DESKTOP_NAMES;
extern xcb_atom_t NET_ACTIVE_WINDOW;
extern xcb_atom_t NET_WORKAREA;
extern xcb_atom_t NET_SUPPORTING_WM_CHECK;
extern xcb_atom_t NET_CLOSE_WINDOW;
extern xcb_atom_t NET_WM_NAME;
extern xcb_atom_t NET_WM_VISIBLE_NAME;
extern xcb_atom_t NET_WM_DESKTOP;
extern xcb_atom_t NET_WM_ICON_NAME;
extern xcb_atom_t NET_WM_VISIBLE_ICON_NAME;
extern xcb_atom_t NET_WM_WINDOW_TYPE;
extern xcb_atom_t NET_WM_WINDOW_TYPE_NORMAL;
extern xcb_atom_t NET_WM_WINDOW_TYPE_DESKTOP;
extern xcb_atom_t NET_WM_WINDOW_TYPE_DOCK;
extern xcb_atom_t NET_WM_WINDOW_TYPE_SPLASH;
extern xcb_atom_t NET_WM_WINDOW_TYPE_DIALOG;
extern xcb_atom_t NET_WM_ICON;
extern xcb_atom_t NET_WM_PID;
extern xcb_atom_t NET_WM_STATE;
extern xcb_atom_t NET_WM_STATE_STICKY;
extern xcb_atom_t NET_WM_STATE_SKIP_TASKBAR;
extern xcb_atom_t NET_WM_STATE_FULLSCREEN;
extern xcb_atom_t NET_WM_STATE_ABOVE;
extern xcb_atom_t NET_WM_STATE_BELOW;
extern xcb_atom_t NET_WM_STATE_MODAL;
extern xcb_atom_t NET_WM_STATE_HIDDEN;
extern xcb_atom_t NET_WM_STATE_DEMANDS_ATTENTION;
extern xcb_atom_t UTF8_STRING;
void atoms_init(xcb_connection_t *);
#endif
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80

252
ewmh.c
View File

@ -33,168 +33,58 @@
#include "widget.h" #include "widget.h"
#include "cnode.h" #include "cnode.h"
#include "titlebar.h" #include "titlebar.h"
#include "common/atoms.h"
extern awesome_t globalconf; extern awesome_t globalconf;
static xcb_atom_t net_supported;
static xcb_atom_t net_client_list;
static xcb_atom_t net_client_list_stacking;
static xcb_atom_t net_number_of_desktops;
static xcb_atom_t net_current_desktop;
static xcb_atom_t net_desktop_names;
static xcb_atom_t net_active_window;
static xcb_atom_t net_workarea;
static xcb_atom_t net_supporting_wm_check;
static xcb_atom_t net_close_window;
static xcb_atom_t net_wm_name;
static xcb_atom_t net_wm_visible_name;
static xcb_atom_t net_wm_desktop;
static xcb_atom_t net_wm_icon_name;
static xcb_atom_t net_wm_visible_icon_name;
static xcb_atom_t net_wm_window_type;
static xcb_atom_t net_wm_window_type_normal;
static xcb_atom_t net_wm_window_type_desktop;
static xcb_atom_t net_wm_window_type_dock;
static xcb_atom_t net_wm_window_type_splash;
static xcb_atom_t net_wm_window_type_dialog;
static xcb_atom_t net_wm_icon;
static xcb_atom_t net_wm_pid;
static xcb_atom_t net_wm_state;
static xcb_atom_t net_wm_state_sticky;
static xcb_atom_t net_wm_state_skip_taskbar;
static xcb_atom_t net_wm_state_fullscreen;
static xcb_atom_t net_wm_state_above;
static xcb_atom_t net_wm_state_below;
static xcb_atom_t net_wm_state_modal;
static xcb_atom_t net_wm_state_hidden;
static xcb_atom_t net_wm_state_demands_attention;
static xcb_atom_t utf8_string;
typedef struct
{
const char *name;
xcb_atom_t *atom;
} AtomItem;
static AtomItem AtomNames[] =
{
{ "_NET_SUPPORTED", &net_supported },
{ "_NET_CLIENT_LIST", &net_client_list },
{ "_NET_CLIENT_LIST_STACKING", &net_client_list_stacking },
{ "_NET_NUMBER_OF_DESKTOPS", &net_number_of_desktops },
{ "_NET_CURRENT_DESKTOP", &net_current_desktop },
{ "_NET_DESKTOP_NAMES", &net_desktop_names },
{ "_NET_ACTIVE_WINDOW", &net_active_window },
{ "_NET_WORKAREA", &net_workarea },
{ "_NET_SUPPORTING_WM_CHECK", &net_supporting_wm_check },
{ "_NET_CLOSE_WINDOW", &net_close_window },
{ "_NET_WM_NAME", &net_wm_name },
{ "_NET_WM_VISIBLE_NAME", &net_wm_visible_name },
{ "_NET_WM_DESKTOP", &net_wm_desktop },
{ "_NET_WM_ICON_NAME", &net_wm_icon_name },
{ "_NET_WM_VISIBLE_ICON_NAME", &net_wm_visible_icon_name },
{ "_NET_WM_WINDOW_TYPE", &net_wm_window_type },
{ "_NET_WM_WINDOW_TYPE_NORMAL", &net_wm_window_type_normal },
{ "_NET_WM_WINDOW_TYPE_DESKTOP", &net_wm_window_type_desktop },
{ "_NET_WM_WINDOW_TYPE_DOCK", &net_wm_window_type_dock },
{ "_NET_WM_WINDOW_TYPE_SPLASH", &net_wm_window_type_splash },
{ "_NET_WM_WINDOW_TYPE_DIALOG", &net_wm_window_type_dialog },
{ "_NET_WM_ICON", &net_wm_icon },
{ "_NET_WM_PID", &net_wm_pid },
{ "_NET_WM_STATE", &net_wm_state },
{ "_NET_WM_STATE_STICKY", &net_wm_state_sticky },
{ "_NET_WM_STATE_SKIP_TASKBAR", &net_wm_state_skip_taskbar },
{ "_NET_WM_STATE_FULLSCREEN", &net_wm_state_fullscreen },
{ "_NET_WM_STATE_ABOVE", &net_wm_state_above },
{ "_NET_WM_STATE_BELOW", &net_wm_state_below },
{ "_NET_WM_STATE_MODAL", &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 },
};
#define ATOM_NUMBER (sizeof(AtomNames)/sizeof(AtomItem))
#define _NET_WM_STATE_REMOVE 0 #define _NET_WM_STATE_REMOVE 0
#define _NET_WM_STATE_ADD 1 #define _NET_WM_STATE_ADD 1
#define _NET_WM_STATE_TOGGLE 2 #define _NET_WM_STATE_TOGGLE 2
void void
ewmh_init_atoms(void) ewmh_init(int phys_screen)
{ {
unsigned int i;
xcb_intern_atom_cookie_t cs[ATOM_NUMBER];
xcb_intern_atom_reply_t *r;
/*
* Create the atom and get the reply in a XCB way (e.g. send all
* the requests at the same time and then get the replies)
*/
for(i = 0; i < ATOM_NUMBER; i++)
cs[i] = xcb_intern_atom_unchecked(globalconf.connection,
false,
strlen(AtomNames[i].name),
AtomNames[i].name);
for(i = 0; i < ATOM_NUMBER; i++)
{
if(!(r = xcb_intern_atom_reply(globalconf.connection, cs[i], NULL)))
/* An error occured, get reply for next atom */
continue;
*AtomNames[i].atom = r->atom;
p_delete(&r);
}
}
void
ewmh_set_supported_hints(int phys_screen)
{
xcb_atom_t atom[ATOM_NUMBER];
xcb_window_t father; xcb_window_t father;
xcb_screen_t *xscreen = xutil_screen_get(globalconf.connection, phys_screen); xcb_screen_t *xscreen = xutil_screen_get(globalconf.connection, phys_screen);
int i = 0; xcb_atom_t atom[] =
{
atom[i++] = net_supported; NET_SUPPORTED,
atom[i++] = net_supporting_wm_check; NET_SUPPORTING_WM_CHECK,
atom[i++] = net_client_list; NET_CLIENT_LIST,
atom[i++] = net_client_list_stacking; NET_CLIENT_LIST_STACKING,
atom[i++] = net_number_of_desktops; NET_NUMBER_OF_DESKTOPS,
atom[i++] = net_current_desktop; NET_CURRENT_DESKTOP,
atom[i++] = net_desktop_names; NET_DESKTOP_NAMES,
atom[i++] = net_active_window; NET_ACTIVE_WINDOW,
atom[i++] = net_workarea; NET_WORKAREA,
NET_CLOSE_WINDOW,
atom[i++] = net_close_window; NET_WM_NAME,
NET_WM_ICON_NAME,
atom[i++] = net_wm_name; NET_WM_VISIBLE_ICON_NAME,
atom[i++] = net_wm_icon_name; NET_WM_DESKTOP,
atom[i++] = net_wm_visible_icon_name; NET_WM_WINDOW_TYPE,
atom[i++] = net_wm_desktop; NET_WM_WINDOW_TYPE_NORMAL,
atom[i++] = net_wm_window_type; NET_WM_WINDOW_TYPE_DESKTOP,
atom[i++] = net_wm_window_type_normal; NET_WM_WINDOW_TYPE_DOCK,
atom[i++] = net_wm_window_type_desktop; NET_WM_WINDOW_TYPE_SPLASH,
atom[i++] = net_wm_window_type_dock; NET_WM_WINDOW_TYPE_DIALOG,
atom[i++] = net_wm_window_type_splash; NET_WM_ICON,
atom[i++] = net_wm_window_type_dialog; NET_WM_PID,
atom[i++] = net_wm_icon; NET_WM_STATE,
atom[i++] = net_wm_pid; NET_WM_STATE_STICKY,
atom[i++] = net_wm_state; NET_WM_STATE_SKIP_TASKBAR,
atom[i++] = net_wm_state_sticky; NET_WM_STATE_FULLSCREEN,
atom[i++] = net_wm_state_skip_taskbar; NET_WM_STATE_ABOVE,
atom[i++] = net_wm_state_fullscreen; NET_WM_STATE_BELOW,
atom[i++] = net_wm_state_above; NET_WM_STATE_MODAL,
atom[i++] = net_wm_state_below; NET_WM_STATE_HIDDEN,
atom[i++] = net_wm_state_modal; NET_WM_STATE_DEMANDS_ATTENTION
atom[i++] = net_wm_state_hidden; };
atom[i++] = net_wm_state_demands_attention; int i;
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
xscreen->root, net_supported, ATOM, 32, i, atom); xscreen->root, NET_SUPPORTED, ATOM, 32,
countof(atom), atom);
/* create our own window */ /* create our own window */
father = xcb_generate_id(globalconf.connection); father = xcb_generate_id(globalconf.connection);
@ -203,21 +93,21 @@ ewmh_set_supported_hints(int phys_screen)
XCB_COPY_FROM_PARENT, xscreen->root_visual, 0, NULL); XCB_COPY_FROM_PARENT, xscreen->root_visual, 0, NULL);
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
xscreen->root, net_supporting_wm_check, WINDOW, 32, xscreen->root, NET_SUPPORTING_WM_CHECK, WINDOW, 32,
1, &father); 1, &father);
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
father, net_supporting_wm_check, WINDOW, 32, father, NET_SUPPORTING_WM_CHECK, WINDOW, 32,
1, &father); 1, &father);
/* set the window manager name */ /* set the window manager name */
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
father, net_wm_name, utf8_string, 8, 7, "awesome"); father, NET_WM_NAME, UTF8_STRING, 8, 7, "awesome");
/* set the window manager PID */ /* set the window manager PID */
i = getpid(); i = getpid();
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
father, net_wm_pid, CARDINAL, 32, 1, &i); father, NET_WM_PID, CARDINAL, 32, 1, &i);
} }
void void
@ -238,7 +128,7 @@ ewmh_update_net_client_list(int phys_screen)
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
xutil_screen_get(globalconf.connection, phys_screen)->root, xutil_screen_get(globalconf.connection, phys_screen)->root,
net_client_list, WINDOW, 32, n, wins); NET_CLIENT_LIST, WINDOW, 32, n, wins);
p_delete(&wins); p_delete(&wins);
} }
@ -264,7 +154,7 @@ ewmh_update_net_client_list_stacking(int phys_screen)
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
xutil_screen_get(globalconf.connection, phys_screen)->root, xutil_screen_get(globalconf.connection, phys_screen)->root,
net_client_list_stacking, WINDOW, 32, n, wins); NET_CLIENT_LIST_STACKING, WINDOW, 32, n, wins);
p_delete(&wins); p_delete(&wins);
} }
@ -276,7 +166,7 @@ ewmh_update_net_numbers_of_desktop(int phys_screen)
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
xutil_screen_get(globalconf.connection, phys_screen)->root, xutil_screen_get(globalconf.connection, phys_screen)->root,
net_number_of_desktops, CARDINAL, 32, 1, &count); NET_NUMBER_OF_DESKTOPS, CARDINAL, 32, 1, &count);
} }
void void
@ -290,7 +180,7 @@ ewmh_update_net_current_desktop(int phys_screen)
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
xutil_screen_get(globalconf.connection, phys_screen)->root, xutil_screen_get(globalconf.connection, phys_screen)->root,
net_current_desktop, CARDINAL, 32, 1, &count); NET_CURRENT_DESKTOP, CARDINAL, 32, 1, &count);
p_delete(&curtags); p_delete(&curtags);
} }
@ -311,7 +201,7 @@ ewmh_update_net_desktop_names(int phys_screen)
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
xutil_screen_get(globalconf.connection, phys_screen)->root, xutil_screen_get(globalconf.connection, phys_screen)->root,
net_desktop_names, utf8_string, 8, buf.len, buf.s); NET_DESKTOP_NAMES, UTF8_STRING, 8, buf.len, buf.s);
buffer_wipe(&buf); buffer_wipe(&buf);
} }
@ -338,7 +228,7 @@ ewmh_update_workarea(int phys_screen)
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
xutil_screen_get(globalconf.connection, phys_screen)->root, xutil_screen_get(globalconf.connection, phys_screen)->root,
net_workarea, CARDINAL, 32, tags->len * 4, area); NET_WORKAREA, CARDINAL, 32, tags->len * 4, area);
} }
void void
@ -351,19 +241,19 @@ ewmh_update_net_active_window(int phys_screen)
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
xutil_screen_get(globalconf.connection, phys_screen)->root, xutil_screen_get(globalconf.connection, phys_screen)->root,
net_active_window, WINDOW, 32, 1, &win); NET_ACTIVE_WINDOW, WINDOW, 32, 1, &win);
} }
static void static void
ewmh_process_state_atom(client_t *c, xcb_atom_t state, int set) ewmh_process_state_atom(client_t *c, xcb_atom_t state, int set)
{ {
if(state == net_wm_state_sticky) if(state == NET_WM_STATE_STICKY)
{ {
tag_array_t *tags = &globalconf.screens[c->screen].tags; tag_array_t *tags = &globalconf.screens[c->screen].tags;
for(int i = 0; i < tags->len; i++) for(int i = 0; i < tags->len; i++)
tag_client(c, tags->tab[i]); tag_client(c, tags->tab[i]);
} }
else if(state == net_wm_state_skip_taskbar) else if(state == NET_WM_STATE_SKIP_TASKBAR)
{ {
if(set == _NET_WM_STATE_REMOVE) if(set == _NET_WM_STATE_REMOVE)
{ {
@ -376,7 +266,7 @@ ewmh_process_state_atom(client_t *c, xcb_atom_t state, int set)
c->skip = true; c->skip = true;
} }
} }
else if(state == net_wm_state_fullscreen) else if(state == NET_WM_STATE_FULLSCREEN)
{ {
area_t geometry = c->geometry; area_t geometry = c->geometry;
if(set == _NET_WM_STATE_REMOVE) if(set == _NET_WM_STATE_REMOVE)
@ -415,7 +305,7 @@ ewmh_process_state_atom(client_t *c, xcb_atom_t state, int set)
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS); widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
client_resize(c, geometry, false); client_resize(c, geometry, false);
} }
else if(state == net_wm_state_above) else if(state == NET_WM_STATE_ABOVE)
{ {
if(set == _NET_WM_STATE_REMOVE) if(set == _NET_WM_STATE_REMOVE)
client_setlayer(c, c->oldlayer); client_setlayer(c, c->oldlayer);
@ -425,7 +315,7 @@ ewmh_process_state_atom(client_t *c, xcb_atom_t state, int set)
client_setlayer(c, LAYER_ABOVE); client_setlayer(c, LAYER_ABOVE);
} }
} }
else if(state == net_wm_state_below) else if(state == NET_WM_STATE_BELOW)
{ {
if(set == _NET_WM_STATE_REMOVE) if(set == _NET_WM_STATE_REMOVE)
client_setlayer(c, c->oldlayer); client_setlayer(c, c->oldlayer);
@ -435,7 +325,7 @@ ewmh_process_state_atom(client_t *c, xcb_atom_t state, int set)
client_setlayer(c, LAYER_BELOW); client_setlayer(c, LAYER_BELOW);
} }
} }
else if(state == net_wm_state_modal) else if(state == NET_WM_STATE_MODAL)
{ {
if(set == _NET_WM_STATE_REMOVE) if(set == _NET_WM_STATE_REMOVE)
client_setlayer(c, c->oldlayer); client_setlayer(c, c->oldlayer);
@ -445,7 +335,7 @@ ewmh_process_state_atom(client_t *c, xcb_atom_t state, int set)
client_setlayer(c, LAYER_MODAL); client_setlayer(c, LAYER_MODAL);
} }
} }
else if(state == net_wm_state_hidden) else if(state == NET_WM_STATE_HIDDEN)
{ {
if(set == _NET_WM_STATE_REMOVE) if(set == _NET_WM_STATE_REMOVE)
c->ishidden = false; c->ishidden = false;
@ -453,7 +343,7 @@ ewmh_process_state_atom(client_t *c, xcb_atom_t state, int set)
c->ishidden = true; c->ishidden = true;
globalconf.screens[c->screen].need_arrange = true; globalconf.screens[c->screen].need_arrange = true;
} }
else if(state == net_wm_state_demands_attention) else if(state == NET_WM_STATE_DEMANDS_ATTENTION)
{ {
if(set == _NET_WM_STATE_REMOVE) if(set == _NET_WM_STATE_REMOVE)
c->isurgent = false; c->isurgent = false;
@ -471,12 +361,12 @@ ewmh_process_state_atom(client_t *c, xcb_atom_t state, int set)
static void static void
ewmh_process_window_type_atom(client_t *c, xcb_atom_t state) ewmh_process_window_type_atom(client_t *c, xcb_atom_t state)
{ {
if(state == net_wm_window_type_normal) if(state == NET_WM_WINDOW_TYPE_NORMAL)
{ {
/* do nothing. this is REALLY IMPORTANT */ /* do nothing. this is REALLY IMPORTANT */
} }
else if(state == net_wm_window_type_dock else if(state == NET_WM_WINDOW_TYPE_DOCK
|| state == net_wm_window_type_splash) || state == NET_WM_WINDOW_TYPE_SPLASH)
{ {
c->skip = true; c->skip = true;
c->isfixed = true; c->isfixed = true;
@ -490,12 +380,12 @@ ewmh_process_window_type_atom(client_t *c, xcb_atom_t state)
client_setlayer(c, LAYER_ABOVE); client_setlayer(c, LAYER_ABOVE);
client_setfloating(c, true); client_setfloating(c, true);
} }
else if(state == net_wm_window_type_dialog) else if(state == NET_WM_WINDOW_TYPE_DIALOG)
{ {
client_setlayer(c, LAYER_MODAL); client_setlayer(c, LAYER_MODAL);
client_setfloating(c, true); client_setfloating(c, true);
} }
else if(state == net_wm_window_type_desktop) else if(state == NET_WM_WINDOW_TYPE_DESKTOP)
{ {
tag_array_t *tags = &globalconf.screens[c->screen].tags; tag_array_t *tags = &globalconf.screens[c->screen].tags;
c->noborder = true; c->noborder = true;
@ -513,7 +403,7 @@ ewmh_process_client_message(xcb_client_message_event_t *ev)
client_t *c; client_t *c;
int screen; int screen;
if(ev->type == net_current_desktop) if(ev->type == NET_CURRENT_DESKTOP)
for(screen = 0; for(screen = 0;
screen < xcb_setup_roots_length(xcb_get_setup(globalconf.connection)); screen < xcb_setup_roots_length(xcb_get_setup(globalconf.connection));
screen++) screen++)
@ -521,12 +411,12 @@ ewmh_process_client_message(xcb_client_message_event_t *ev)
if(ev->window == xutil_screen_get(globalconf.connection, screen)->root) if(ev->window == xutil_screen_get(globalconf.connection, screen)->root)
tag_view_only_byindex(screen, ev->data.data32[0]); tag_view_only_byindex(screen, ev->data.data32[0]);
} }
else if(ev->type == net_close_window) else if(ev->type == NET_CLOSE_WINDOW)
{ {
if((c = client_getbywin(ev->window))) if((c = client_getbywin(ev->window)))
client_kill(c); client_kill(c);
} }
else if(ev->type == net_wm_desktop) else if(ev->type == NET_WM_DESKTOP)
{ {
if((c = client_getbywin(ev->window))) if((c = client_getbywin(ev->window)))
{ {
@ -543,7 +433,7 @@ ewmh_process_client_message(xcb_client_message_event_t *ev)
untag_client(c, tags->tab[i]); untag_client(c, tags->tab[i]);
} }
} }
else if(ev->type == net_wm_state) else if(ev->type == NET_WM_STATE)
{ {
if((c = client_getbywin(ev->window))) if((c = client_getbywin(ev->window)))
{ {
@ -568,13 +458,13 @@ ewmh_check_client_hints(client_t *c)
/* Send the GetProperty requests which will be processed later */ /* Send the GetProperty requests which will be processed later */
c0 = xcb_get_property_unchecked(globalconf.connection, false, c->win, c0 = xcb_get_property_unchecked(globalconf.connection, false, c->win,
net_wm_desktop, XCB_GET_PROPERTY_TYPE_ANY, 0, 1); NET_WM_DESKTOP, XCB_GET_PROPERTY_TYPE_ANY, 0, 1);
c1 = xcb_get_property_unchecked(globalconf.connection, false, c->win, c1 = xcb_get_property_unchecked(globalconf.connection, false, c->win,
net_wm_state, ATOM, 0, UINT32_MAX); NET_WM_STATE, ATOM, 0, UINT32_MAX);
c2 = xcb_get_property_unchecked(globalconf.connection, false, c->win, c2 = xcb_get_property_unchecked(globalconf.connection, false, c->win,
net_wm_window_type, ATOM, 0, UINT32_MAX); NET_WM_WINDOW_TYPE, ATOM, 0, UINT32_MAX);
reply = xcb_get_property_reply(globalconf.connection, c0, NULL); reply = xcb_get_property_reply(globalconf.connection, c0, NULL);
if(reply && reply->value_len && (data = xcb_get_property_value(reply))) if(reply && reply->value_len && (data = xcb_get_property_value(reply)))
@ -628,7 +518,7 @@ ewmh_get_window_icon(xcb_window_t w)
r = xcb_get_property_reply(globalconf.connection, r = xcb_get_property_reply(globalconf.connection,
xcb_get_property_unchecked(globalconf.connection, false, w, xcb_get_property_unchecked(globalconf.connection, false, w,
net_wm_icon, CARDINAL, 0, UINT32_MAX), NET_WM_ICON, CARDINAL, 0, UINT32_MAX),
NULL); NULL);
if(!r || r->type != CARDINAL || r->format != 32 || r->length < 2 || if(!r || r->type != CARDINAL || r->format != 32 || r->length < 2 ||
!(data = (uint32_t *) xcb_get_property_value(r))) !(data = (uint32_t *) xcb_get_property_value(r)))

3
ewmh.h
View File

@ -31,8 +31,7 @@ typedef struct
unsigned char *image; unsigned char *image;
} netwm_icon_t; } netwm_icon_t;
void ewmh_init_atoms(void); void ewmh_init(int);
void ewmh_set_supported_hints(int);
void ewmh_update_net_client_list(int); void ewmh_update_net_client_list(int);
void ewmh_update_net_numbers_of_desktop(int); void ewmh_update_net_numbers_of_desktop(int);
void ewmh_update_net_current_desktop(int); void ewmh_update_net_current_desktop(int);