set up the atoms in cwmcc
This commit is contained in:
parent
787cbcf656
commit
51e27c03cf
8 changed files with 778 additions and 2 deletions
|
@ -3,9 +3,10 @@ include build/Makefile.incl
|
|||
dir = cwmcc
|
||||
|
||||
CPPFLAGS += $(GLIB_CFLAGS) $(XFT_CFLAGS) -DG_LOG_DOMAIN=\"CWMCC\"
|
||||
LIBS += $(GLIB_LIBS)
|
||||
|
||||
target = libcwmcc.la
|
||||
sources = cwmcc.c
|
||||
sources = cwmcc.c atom.c
|
||||
|
||||
srcdir := $(srcdir)/$(dir)
|
||||
target := $(addprefix $(dir)/, $(target))
|
||||
|
|
|
@ -55,6 +55,6 @@ themedir = $(datadir)/openbox/themes
|
|||
COMPILE = $(CC) $(DEFS) $(CPPFLAGS) $(CFLAGS)
|
||||
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(CPPFLAGS) $(CFLAGS)
|
||||
DEPCOMPILE = $(CC) $(DEFS) $(CPPFLAGS) $(CFLAGS)
|
||||
LINK = $(LIBTOOL) --mode=link $(CC)
|
||||
LINK = $(LIBTOOL) --mode=link $(CC) $(LIBS)
|
||||
LTCLEAN = $(LIBTOOL) --mode=clean $(RM)
|
||||
LTRM = $(LIBTOOL) --mode=uninstall $(RM)
|
||||
|
|
114
cwmcc/atom.c
Normal file
114
cwmcc/atom.c
Normal file
|
@ -0,0 +1,114 @@
|
|||
#include "cwmcc_internal.h"
|
||||
#include "atom.h"
|
||||
#include <glib.h>
|
||||
|
||||
struct TypeAtoms cwmcc_atom_type;
|
||||
struct ClientAtoms cwmcc_atom_client;
|
||||
struct RootAtoms cwmcc_atom_root;
|
||||
struct DataAtoms cwmcc_atom_data;
|
||||
|
||||
#define CREATE(type, var, name) (cwmcc_atom_##type.var = \
|
||||
XInternAtom(cwmcc_display, name, FALSE))
|
||||
#define SETVALUE(type, var, value) (cwmcc_atom_##type.var = value)
|
||||
|
||||
void atom_startup()
|
||||
{
|
||||
CREATE(type, cardinal, "CARDINAL");
|
||||
CREATE(type, window, "WINDOW");
|
||||
CREATE(type, pixmap, "PIXMAP");
|
||||
CREATE(type, atom, "ATOM");
|
||||
CREATE(type, string, "STRING");
|
||||
CREATE(type, utf8, "UTF8_STRING");
|
||||
|
||||
CREATE(client, wm_protocols, "WM_PROTOCOLS");
|
||||
CREATE(client, wm_state, "WM_STATE");
|
||||
CREATE(client, wm_name, "WM_NAME");
|
||||
CREATE(client, wm_icon_name, "WM_ICON_NAME");
|
||||
CREATE(client, wm_class, "WM_CLASS");
|
||||
CREATE(client, wm_window_role, "WM_WINDOW_ROLE");
|
||||
CREATE(client, motif_wm_hints, "_MOTIF_WM_HINTS");
|
||||
CREATE(client, net_wm_name, "_NET_WM_NAME");
|
||||
CREATE(client, net_wm_visible_name, "_NET_WM_VISIBLE_NAME");
|
||||
CREATE(client, net_wm_icon_name, "_NET_WM_ICON_NAME");
|
||||
CREATE(client, net_wm_visible_icon_name, "_NET_WM_VISIBLE_ICON_NAME");
|
||||
CREATE(client, net_wm_desktop, "_NET_WM_DESKTOP");
|
||||
CREATE(client, net_wm_window_type, "_NET_WM_WINDOW_TYPE");
|
||||
CREATE(client, net_wm_state, "_NET_WM_STATE");
|
||||
CREATE(client, net_wm_strut, "_NET_WM_STRUT");
|
||||
CREATE(client, net_wm_icon, "_NET_WM_ICON");
|
||||
CREATE(client, net_wm_allowed_actions, "_NET_WM_ALLOWED_ACTIONS");
|
||||
CREATE(client, kwm_win_icon, "KWM_WIN_ICON");
|
||||
CREATE(client, openbox_premax, "_OPENBOX_PREMAX");
|
||||
|
||||
CREATE(root, net_supported, "_NET_SUPPORTED");
|
||||
CREATE(root, net_client_list, "_NET_CLIENT_LIST");
|
||||
CREATE(root, net_client_list_stacking, "_NET_CLIENT_LIST_STACKING");
|
||||
CREATE(root, net_number_of_desktops, "_NET_NUMBER_OF_DESKTOPS");
|
||||
CREATE(root, net_desktop_geometry, "_NET_DESKTOP_GEOMETRY");
|
||||
CREATE(root, net_desktop_viewport, "_NET_DESKTOP_VIEWPORT");
|
||||
CREATE(root, net_current_desktop, "_NET_CURRENT_DESKTOP");
|
||||
CREATE(root, net_desktop_names, "_NET_DESKTOP_NAMES");
|
||||
CREATE(root, net_active_window, "_NET_ACTIVE_WINDOW");
|
||||
CREATE(root, net_workarea, "_NET_WORKAREA");
|
||||
CREATE(root, net_supporting_wm_check, "_NET_SUPPORTING_WM_CHECK");
|
||||
CREATE(root, net_desktop_layout, "_NET_DESKTOP_LAYOUT");
|
||||
CREATE(root, net_showing_desktop, "_NET_SHOWING_DESKTOP");
|
||||
CREATE(root, openbox_pid, "_OPENBOX_PID");
|
||||
|
||||
CREATE(data, wm_delete_window, "WM_DELETE_WINDOW");
|
||||
CREATE(data, wm_take_focus, "WM_TAKE_FOCUS");
|
||||
CREATE(data, wm_change_state, "WM_CHANGE_STATE");
|
||||
CREATE(data, net_close_window, "_NET_CLOSE_WINDOW");
|
||||
CREATE(data, net_wm_moveresize, "_NET_WM_MOVERESIZE");
|
||||
|
||||
CREATE(data, net_wm_window_type_desktop, "_NET_WM_WINDOW_TYPE_DESKTOP");
|
||||
CREATE(data, net_wm_window_type_dock, "_NET_WM_WINDOW_TYPE_DOCK");
|
||||
CREATE(data, net_wm_window_type_toolbar, "_NET_WM_WINDOW_TYPE_TOOLBAR");
|
||||
CREATE(data, net_wm_window_type_menu, "_NET_WM_WINDOW_TYPE_MENU");
|
||||
CREATE(data, net_wm_window_type_utility, "_NET_WM_WINDOW_TYPE_UTILITY");
|
||||
CREATE(data, net_wm_window_type_splash, "_NET_WM_WINDOW_TYPE_SPLASH");
|
||||
CREATE(data, net_wm_window_type_dialog, "_NET_WM_WINDOW_TYPE_DIALOG");
|
||||
CREATE(data, net_wm_window_type_normal, "_NET_WM_WINDOW_TYPE_NORMAL");
|
||||
CREATE(data, kde_net_wm_window_type_override,
|
||||
"_KDE_NET_WM_WINDOW_TYPE_OVERRIDE");
|
||||
|
||||
SETVALUE(data, net_wm_moveresize_size_topleft, 0);
|
||||
SETVALUE(data, net_wm_moveresize_size_topright, 2);
|
||||
SETVALUE(data, net_wm_moveresize_size_bottomright, 4);
|
||||
SETVALUE(data, net_wm_moveresize_size_bottomleft, 6);
|
||||
SETVALUE(data, net_wm_moveresize_move, 8);
|
||||
|
||||
CREATE(data, net_wm_action_move, "_NET_WM_ACTION_MOVE");
|
||||
CREATE(data, net_wm_action_resize, "_NET_WM_ACTION_RESIZE");
|
||||
CREATE(data, net_wm_action_minimize, "_NET_WM_ACTION_MINIMIZE");
|
||||
CREATE(data, net_wm_action_shade, "_NET_WM_ACTION_SHADE");
|
||||
CREATE(data, net_wm_action_stick, "_NET_WM_ACTION_STICK");
|
||||
CREATE(data, net_wm_action_maximize_horz, "_NET_WM_ACTION_MAXIMIZE_HORZ");
|
||||
CREATE(data, net_wm_action_maximize_vert, "_NET_WM_ACTION_MAXIMIZE_VERT");
|
||||
CREATE(data, net_wm_action_fullscreen, "_NET_WM_ACTION_FULLSCREEN");
|
||||
CREATE(data, net_wm_action_change_desktop,"_NET_WM_ACTION_CHANGE_DESKTOP");
|
||||
CREATE(data, net_wm_action_close, "_NET_WM_ACTION_CLOSE");
|
||||
|
||||
CREATE(data, net_wm_state_modal, "_NET_WM_STATE_MODAL");
|
||||
CREATE(data, net_wm_state_sticky, "_NET_WM_STATE_STICKY");
|
||||
CREATE(data, net_wm_state_maximized_vert, "_NET_WM_STATE_MAXIMIZED_VERT");
|
||||
CREATE(data, net_wm_state_maximized_horz, "_NET_WM_STATE_MAXIMIZED_HORZ");
|
||||
CREATE(data, net_wm_state_shaded, "_NET_WM_STATE_SHADED");
|
||||
CREATE(data, net_wm_state_skip_taskbar, "_NET_WM_STATE_SKIP_TASKBAR");
|
||||
CREATE(data, net_wm_state_skip_pager, "_NET_WM_STATE_SKIP_PAGER");
|
||||
CREATE(data, net_wm_state_hidden, "_NET_WM_STATE_HIDDEN");
|
||||
CREATE(data, net_wm_state_fullscreen, "_NET_WM_STATE_FULLSCREEN");
|
||||
CREATE(data, net_wm_state_above, "_NET_WM_STATE_ABOVE");
|
||||
CREATE(data, net_wm_state_below, "_NET_WM_STATE_BELOW");
|
||||
|
||||
SETVALUE(data, net_wm_state_remove, 0);
|
||||
SETVALUE(data, net_wm_state_add, 1);
|
||||
SETVALUE(data, net_wm_state_toggle, 2);
|
||||
|
||||
SETVALUE(data, net_wm_orientation_horz, 0);
|
||||
SETVALUE(data, net_wm_orientation_vert, 1);
|
||||
SETVALUE(data, net_wm_topleft, 0);
|
||||
SETVALUE(data, net_wm_topright, 1);
|
||||
SETVALUE(data, net_wm_bottomright, 2);
|
||||
SETVALUE(data, net_wm_bottomleft, 3);
|
||||
}
|
127
cwmcc/atom.h
Normal file
127
cwmcc/atom.h
Normal file
|
@ -0,0 +1,127 @@
|
|||
#ifndef __cwmcc_atom_h
|
||||
#define __cwmcc_atom_h
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
/*! Atoms for basic data types for properties */
|
||||
struct TypeAtoms {
|
||||
Atom cardinal; /*!< The atom which represents the Cardinal data type */
|
||||
Atom window; /*!< The atom which represents window ids */
|
||||
Atom pixmap; /*!< The atom which represents pixmap ids */
|
||||
Atom atom; /*!< The atom which represents atom values */
|
||||
Atom string; /*!< The atom which represents ascii strings */
|
||||
Atom utf8; /*!< The atom which represents utf8-encoded strings */
|
||||
};
|
||||
|
||||
/*! Atoms for client window properties */
|
||||
struct ClientAtoms {
|
||||
Atom wm_protocols;
|
||||
Atom wm_state;
|
||||
Atom wm_name;
|
||||
Atom wm_icon_name;
|
||||
Atom wm_class;
|
||||
Atom wm_window_role;
|
||||
Atom motif_wm_hints;
|
||||
Atom net_wm_name;
|
||||
Atom net_wm_visible_name;
|
||||
Atom net_wm_icon_name;
|
||||
Atom net_wm_visible_icon_name;
|
||||
Atom net_wm_desktop;
|
||||
Atom net_wm_window_type;
|
||||
Atom net_wm_state;
|
||||
Atom net_wm_strut;
|
||||
Atom net_wm_icon;
|
||||
Atom net_wm_allowed_actions;
|
||||
Atom kwm_win_icon;
|
||||
Atom openbox_premax;
|
||||
};
|
||||
|
||||
/*! Atoms for root window properties */
|
||||
struct RootAtoms {
|
||||
Atom net_supported;
|
||||
Atom net_client_list;
|
||||
Atom net_client_list_stacking;
|
||||
Atom net_number_of_desktops;
|
||||
Atom net_desktop_geometry;
|
||||
Atom net_desktop_viewport;
|
||||
Atom net_current_desktop;
|
||||
Atom net_desktop_names;
|
||||
Atom net_active_window;
|
||||
Atom net_workarea;
|
||||
Atom net_supporting_wm_check;
|
||||
Atom net_desktop_layout;
|
||||
Atom net_showing_desktop;
|
||||
Atom openbox_pid;
|
||||
};
|
||||
|
||||
/*! Atoms used for protocols or client messages, or for setting as values of
|
||||
properties */
|
||||
struct DataAtoms {
|
||||
/* window hints */
|
||||
Atom wm_delete_window;
|
||||
Atom wm_take_focus;
|
||||
Atom wm_change_state;
|
||||
Atom net_close_window;
|
||||
Atom net_wm_moveresize;
|
||||
|
||||
Atom net_wm_window_type_desktop;
|
||||
Atom net_wm_window_type_dock;
|
||||
Atom net_wm_window_type_toolbar;
|
||||
Atom net_wm_window_type_menu;
|
||||
Atom net_wm_window_type_utility;
|
||||
Atom net_wm_window_type_splash;
|
||||
Atom net_wm_window_type_dialog;
|
||||
Atom net_wm_window_type_normal;
|
||||
Atom kde_net_wm_window_type_override;
|
||||
|
||||
Atom net_wm_moveresize_size_topleft;
|
||||
Atom net_wm_moveresize_size_topright;
|
||||
Atom net_wm_moveresize_size_bottomleft;
|
||||
Atom net_wm_moveresize_size_bottomright;
|
||||
Atom net_wm_moveresize_move;
|
||||
|
||||
Atom net_wm_action_move;
|
||||
Atom net_wm_action_resize;
|
||||
Atom net_wm_action_minimize;
|
||||
Atom net_wm_action_shade;
|
||||
Atom net_wm_action_stick;
|
||||
Atom net_wm_action_maximize_horz;
|
||||
Atom net_wm_action_maximize_vert;
|
||||
Atom net_wm_action_fullscreen;
|
||||
Atom net_wm_action_change_desktop;
|
||||
Atom net_wm_action_close;
|
||||
|
||||
Atom net_wm_state_modal;
|
||||
Atom net_wm_state_sticky;
|
||||
Atom net_wm_state_maximized_vert;
|
||||
Atom net_wm_state_maximized_horz;
|
||||
Atom net_wm_state_shaded;
|
||||
Atom net_wm_state_skip_taskbar;
|
||||
Atom net_wm_state_skip_pager;
|
||||
Atom net_wm_state_hidden;
|
||||
Atom net_wm_state_fullscreen;
|
||||
Atom net_wm_state_above;
|
||||
Atom net_wm_state_below;
|
||||
|
||||
Atom net_wm_state_add;
|
||||
Atom net_wm_state_remove;
|
||||
Atom net_wm_state_toggle;
|
||||
|
||||
Atom net_wm_orientation_horz;
|
||||
Atom net_wm_orientation_vert;
|
||||
Atom net_wm_topleft;
|
||||
Atom net_wm_topright;
|
||||
Atom net_wm_bottomright;
|
||||
Atom net_wm_bottomleft;
|
||||
};
|
||||
|
||||
extern struct TypeAtoms cwmcc_atom_type;
|
||||
extern struct ClientAtoms cwmcc_atom_client;
|
||||
extern struct RootAtoms cwmcc_atom_root;
|
||||
extern struct DataAtoms cwmcc_atom_data;
|
||||
|
||||
#define CWMCC_ATOM(type, name) (cwmcc_atom_##type.name)
|
||||
|
||||
void atom_startup();
|
||||
|
||||
#endif
|
|
@ -0,0 +1,10 @@
|
|||
#include "cwmcc_internal.h"
|
||||
#include "atom.h"
|
||||
|
||||
Display *cwmcc_display;
|
||||
|
||||
void cwmcc_startup(Display *d)
|
||||
{
|
||||
cwmcc_display = d;
|
||||
atom_startup();
|
||||
}
|
8
cwmcc/cwmcc_internal.h
Normal file
8
cwmcc/cwmcc_internal.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
#ifndef __cwmcc_cwmcc_internal_h
|
||||
#define __cwmcc_cwmcc_internal_h
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
extern Display *cwmcc_display;
|
||||
|
||||
#endif
|
302
cwmcc/prop.c
Normal file
302
cwmcc/prop.c
Normal file
|
@ -0,0 +1,302 @@
|
|||
#include "prop.h"
|
||||
#include "openbox.h"
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
Atoms prop_atoms;
|
||||
|
||||
#define CREATE(var, name) (prop_atoms.var = \
|
||||
XInternAtom(ob_display, name, FALSE))
|
||||
|
||||
void prop_startup()
|
||||
{
|
||||
g_assert(ob_display != NULL);
|
||||
|
||||
CREATE(cardinal, "CARDINAL");
|
||||
CREATE(window, "WINDOW");
|
||||
CREATE(pixmap, "PIXMAP");
|
||||
CREATE(atom, "ATOM");
|
||||
CREATE(string, "STRING");
|
||||
CREATE(utf8, "UTF8_STRING");
|
||||
|
||||
CREATE(wm_colormap_windows, "WM_COLORMAP_WINDOWS");
|
||||
CREATE(wm_protocols, "WM_PROTOCOLS");
|
||||
CREATE(wm_state, "WM_STATE");
|
||||
CREATE(wm_change_state, "WM_CHANGE_STATE");
|
||||
CREATE(wm_delete_window, "WM_DELETE_WINDOW");
|
||||
CREATE(wm_take_focus, "WM_TAKE_FOCUS");
|
||||
CREATE(wm_name, "WM_NAME");
|
||||
CREATE(wm_icon_name, "WM_ICON_NAME");
|
||||
CREATE(wm_class, "WM_CLASS");
|
||||
CREATE(wm_window_role, "WM_WINDOW_ROLE");
|
||||
CREATE(motif_wm_hints, "_MOTIF_WM_HINTS");
|
||||
|
||||
CREATE(net_supported, "_NET_SUPPORTED");
|
||||
CREATE(net_client_list, "_NET_CLIENT_LIST");
|
||||
CREATE(net_client_list_stacking, "_NET_CLIENT_LIST_STACKING");
|
||||
CREATE(net_number_of_desktops, "_NET_NUMBER_OF_DESKTOPS");
|
||||
CREATE(net_desktop_geometry, "_NET_DESKTOP_GEOMETRY");
|
||||
CREATE(net_desktop_viewport, "_NET_DESKTOP_VIEWPORT");
|
||||
CREATE(net_current_desktop, "_NET_CURRENT_DESKTOP");
|
||||
CREATE(net_desktop_names, "_NET_DESKTOP_NAMES");
|
||||
CREATE(net_active_window, "_NET_ACTIVE_WINDOW");
|
||||
CREATE(net_workarea, "_NET_WORKAREA");
|
||||
CREATE(net_supporting_wm_check, "_NET_SUPPORTING_WM_CHECK");
|
||||
/* CREATE(net_virtual_roots, "_NET_VIRTUAL_ROOTS"); */
|
||||
CREATE(net_desktop_layout, "_NET_DESKTOP_LAYOUT");
|
||||
CREATE(net_showing_desktop, "_NET_SHOWING_DESKTOP");
|
||||
|
||||
CREATE(net_close_window, "_NET_CLOSE_WINDOW");
|
||||
CREATE(net_wm_moveresize, "_NET_WM_MOVERESIZE");
|
||||
|
||||
/* CREATE(net_properties, "_NET_PROPERTIES"); */
|
||||
CREATE(net_wm_name, "_NET_WM_NAME");
|
||||
CREATE(net_wm_visible_name, "_NET_WM_VISIBLE_NAME");
|
||||
CREATE(net_wm_icon_name, "_NET_WM_ICON_NAME");
|
||||
CREATE(net_wm_visible_icon_name, "_NET_WM_VISIBLE_ICON_NAME");
|
||||
CREATE(net_wm_desktop, "_NET_WM_DESKTOP");
|
||||
CREATE(net_wm_window_type, "_NET_WM_WINDOW_TYPE");
|
||||
CREATE(net_wm_state, "_NET_WM_STATE");
|
||||
CREATE(net_wm_strut, "_NET_WM_STRUT");
|
||||
/* CREATE(net_wm_icon_geometry, "_NET_WM_ICON_GEOMETRY"); */
|
||||
CREATE(net_wm_icon, "_NET_WM_ICON");
|
||||
/* CREATE(net_wm_pid, "_NET_WM_PID"); */
|
||||
/* CREATE(net_wm_handled_icons, "_NET_WM_HANDLED_ICONS"); */
|
||||
CREATE(net_wm_allowed_actions, "_NET_WM_ALLOWED_ACTIONS");
|
||||
|
||||
/* CREATE(net_wm_ping, "_NET_WM_PING"); */
|
||||
|
||||
CREATE(net_wm_window_type_desktop, "_NET_WM_WINDOW_TYPE_DESKTOP");
|
||||
CREATE(net_wm_window_type_dock, "_NET_WM_WINDOW_TYPE_DOCK");
|
||||
CREATE(net_wm_window_type_toolbar, "_NET_WM_WINDOW_TYPE_TOOLBAR");
|
||||
CREATE(net_wm_window_type_menu, "_NET_WM_WINDOW_TYPE_MENU");
|
||||
CREATE(net_wm_window_type_utility, "_NET_WM_WINDOW_TYPE_UTILITY");
|
||||
CREATE(net_wm_window_type_splash, "_NET_WM_WINDOW_TYPE_SPLASH");
|
||||
CREATE(net_wm_window_type_dialog, "_NET_WM_WINDOW_TYPE_DIALOG");
|
||||
CREATE(net_wm_window_type_normal, "_NET_WM_WINDOW_TYPE_NORMAL");
|
||||
|
||||
CREATE(net_wm_moveresize_size_topleft, "_NET_WM_MOVERESIZE_SIZE_TOPLEFT");
|
||||
CREATE(net_wm_moveresize_size_topright,
|
||||
"_NET_WM_MOVERESIZE_SIZE_TOPRIGHT");
|
||||
CREATE(net_wm_moveresize_size_bottomleft,
|
||||
"_NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT");
|
||||
CREATE(net_wm_moveresize_size_bottomright,
|
||||
"_NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT");
|
||||
CREATE(net_wm_moveresize_move, "_NET_WM_MOVERESIZE_MOVE");
|
||||
|
||||
CREATE(net_wm_action_move, "_NET_WM_ACTION_MOVE");
|
||||
CREATE(net_wm_action_resize, "_NET_WM_ACTION_RESIZE");
|
||||
CREATE(net_wm_action_minimize, "_NET_WM_ACTION_MINIMIZE");
|
||||
CREATE(net_wm_action_shade, "_NET_WM_ACTION_SHADE");
|
||||
CREATE(net_wm_action_stick, "_NET_WM_ACTION_STICK");
|
||||
CREATE(net_wm_action_maximize_horz, "_NET_WM_ACTION_MAXIMIZE_HORZ");
|
||||
CREATE(net_wm_action_maximize_vert, "_NET_WM_ACTION_MAXIMIZE_VERT");
|
||||
CREATE(net_wm_action_fullscreen, "_NET_WM_ACTION_FULLSCREEN");
|
||||
CREATE(net_wm_action_change_desktop, "_NET_WM_ACTION_CHANGE_DESKTOP");
|
||||
CREATE(net_wm_action_close, "_NET_WM_ACTION_CLOSE");
|
||||
CREATE(net_wm_state_modal, "_NET_WM_STATE_MODAL");
|
||||
CREATE(net_wm_state_sticky, "_NET_WM_STATE_STICKY");
|
||||
CREATE(net_wm_state_maximized_vert, "_NET_WM_STATE_MAXIMIZED_VERT");
|
||||
CREATE(net_wm_state_maximized_horz, "_NET_WM_STATE_MAXIMIZED_HORZ");
|
||||
CREATE(net_wm_state_shaded, "_NET_WM_STATE_SHADED");
|
||||
CREATE(net_wm_state_skip_taskbar, "_NET_WM_STATE_SKIP_TASKBAR");
|
||||
CREATE(net_wm_state_skip_pager, "_NET_WM_STATE_SKIP_PAGER");
|
||||
CREATE(net_wm_state_hidden, "_NET_WM_STATE_HIDDEN");
|
||||
CREATE(net_wm_state_fullscreen, "_NET_WM_STATE_FULLSCREEN");
|
||||
CREATE(net_wm_state_above, "_NET_WM_STATE_ABOVE");
|
||||
CREATE(net_wm_state_below, "_NET_WM_STATE_BELOW");
|
||||
|
||||
prop_atoms.net_wm_state_add = 1;
|
||||
prop_atoms.net_wm_state_remove = 0;
|
||||
prop_atoms.net_wm_state_toggle = 2;
|
||||
|
||||
prop_atoms.net_wm_orientation_horz = 0;
|
||||
prop_atoms.net_wm_orientation_vert = 1;
|
||||
prop_atoms.net_wm_topleft = 0;
|
||||
prop_atoms.net_wm_topright = 1;
|
||||
prop_atoms.net_wm_bottomright = 2;
|
||||
prop_atoms.net_wm_bottomleft = 3;
|
||||
|
||||
CREATE(kde_net_system_tray_windows, "_KDE_NET_SYSTEM_TRAY_WINDOWS");
|
||||
CREATE(kde_net_wm_system_tray_window_for,
|
||||
"_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR");
|
||||
CREATE(kde_net_wm_window_type_override,
|
||||
"_KDE_NET_WM_WINDOW_TYPE_OVERRIDE");
|
||||
|
||||
CREATE(kwm_win_icon, "KWM_WIN_ICON");
|
||||
|
||||
CREATE(rootpmapid, "_XROOTPMAP_ID");
|
||||
CREATE(esetrootid, "ESETROOT_PMAP_ID");
|
||||
|
||||
CREATE(openbox_pid, "_OPENBOX_PID");
|
||||
CREATE(openbox_premax, "_OPENBOX_PREMAX");
|
||||
}
|
||||
|
||||
gboolean prop_get(Window win, Atom prop, Atom type, int size,
|
||||
guchar **data, gulong num)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
int res;
|
||||
guchar *xdata = NULL;
|
||||
Atom ret_type;
|
||||
int ret_size;
|
||||
gulong ret_items, bytes_left;
|
||||
long num32 = 32 / size * num; /* num in 32-bit elements */
|
||||
|
||||
res = XGetWindowProperty(ob_display, win, prop, 0l, num32,
|
||||
FALSE, type, &ret_type, &ret_size,
|
||||
&ret_items, &bytes_left, &xdata);
|
||||
if (res == Success && ret_items && xdata) {
|
||||
if (ret_size == size && ret_items >= num) {
|
||||
*data = g_memdup(xdata, num * (size / 8));
|
||||
ret = TRUE;
|
||||
}
|
||||
XFree(xdata);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
gboolean prop_get_prealloc(Window win, Atom prop, Atom type, int size,
|
||||
guchar *data, gulong num)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
int res;
|
||||
guchar *xdata = NULL;
|
||||
Atom ret_type;
|
||||
int ret_size;
|
||||
gulong ret_items, bytes_left;
|
||||
long num32 = 32 / size * num; /* num in 32-bit elements */
|
||||
|
||||
res = XGetWindowProperty(ob_display, win, prop, 0l, num32,
|
||||
FALSE, type, &ret_type, &ret_size,
|
||||
&ret_items, &bytes_left, &xdata);
|
||||
if (res == Success && ret_items && xdata) {
|
||||
if (ret_size == size && ret_items >= num) {
|
||||
gulong i;
|
||||
for (i = 0; i < num; ++i)
|
||||
switch (size) {
|
||||
case 8:
|
||||
data[i] = xdata[i];
|
||||
break;
|
||||
case 16:
|
||||
((guint16*)data)[i] = ((guint16*)xdata)[i];
|
||||
break;
|
||||
case 32:
|
||||
((guint32*)data)[i] = ((guint32*)xdata)[i];
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached(); /* unhandled size */
|
||||
}
|
||||
ret = TRUE;
|
||||
}
|
||||
XFree(xdata);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
gboolean prop_get_all(Window win, Atom prop, Atom type, int size,
|
||||
guchar **data, gulong *num)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
int res;
|
||||
guchar *xdata = NULL;
|
||||
Atom ret_type;
|
||||
int ret_size;
|
||||
gulong ret_items, bytes_left;
|
||||
|
||||
res = XGetWindowProperty(ob_display, win, prop, 0l, G_MAXLONG,
|
||||
FALSE, type, &ret_type, &ret_size,
|
||||
&ret_items, &bytes_left, &xdata);
|
||||
if (res == Success) {
|
||||
if (ret_size == size && ret_items > 0) {
|
||||
*data = g_memdup(xdata, ret_items * (size / 8));
|
||||
*num = ret_items;
|
||||
ret = TRUE;
|
||||
}
|
||||
XFree(xdata);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
gboolean prop_get_string(Window win, Atom prop, Atom type, guchar **data)
|
||||
{
|
||||
guchar *raw;
|
||||
gulong num;
|
||||
GString *str;
|
||||
|
||||
if (prop_get_all(win, prop, type, 8, &raw, &num)) {
|
||||
str = g_string_new_len((char*)raw, num);
|
||||
g_assert(str->str[num] == '\0');
|
||||
|
||||
g_free(raw);
|
||||
|
||||
*data = (guchar*)g_string_free(str, FALSE);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean prop_get_strings(Window win, Atom prop, Atom type,
|
||||
GPtrArray *data)
|
||||
{
|
||||
guchar *raw;
|
||||
gulong num;
|
||||
GString *str, *str2;
|
||||
guint i, start;
|
||||
|
||||
if (prop_get_all(win, prop, type, 8, &raw, &num)) {
|
||||
str = g_string_new_len((gchar*)raw, num);
|
||||
g_assert(str->str[num] == '\0'); /* assuming this is always true.. */
|
||||
|
||||
g_free(raw);
|
||||
|
||||
/* split it into the list */
|
||||
for (start = 0, i = 0; i < str->len; ++i) {
|
||||
if (str->str[i] == '\0') {
|
||||
str2 = g_string_new_len(&str->str[start], i - start);
|
||||
g_ptr_array_add(data, g_string_free(str2, FALSE));
|
||||
start = i + 1;
|
||||
}
|
||||
}
|
||||
g_string_free(str, TRUE);
|
||||
|
||||
if (data->len > 0)
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void prop_set_strings(Window win, Atom prop, Atom type, GPtrArray *data)
|
||||
{
|
||||
GString *str;
|
||||
guint i;
|
||||
|
||||
str = g_string_sized_new(0);
|
||||
for (i = 0; i < data->len; ++i) {
|
||||
str = g_string_append(str, data->pdata[i]);
|
||||
str = g_string_append_c(str, '\0');
|
||||
}
|
||||
XChangeProperty(ob_display, win, prop, type, 8,
|
||||
PropModeReplace, (guchar*)str->str, str->len);
|
||||
}
|
||||
|
||||
void prop_erase(Window win, Atom prop)
|
||||
{
|
||||
XDeleteProperty(ob_display, win, prop);
|
||||
}
|
||||
|
||||
void prop_message(Window about, Atom messagetype, long data0, long data1,
|
||||
long data2, long data3)
|
||||
{
|
||||
XEvent ce;
|
||||
ce.xclient.type = ClientMessage;
|
||||
ce.xclient.message_type = messagetype;
|
||||
ce.xclient.display = ob_display;
|
||||
ce.xclient.window = about;
|
||||
ce.xclient.format = 32;
|
||||
ce.xclient.data.l[0] = data0;
|
||||
ce.xclient.data.l[1] = data1;
|
||||
ce.xclient.data.l[2] = data2;
|
||||
ce.xclient.data.l[3] = data3;
|
||||
XSendEvent(ob_display, ob_root, FALSE,
|
||||
SubstructureNotifyMask | SubstructureRedirectMask, &ce);
|
||||
}
|
214
cwmcc/prop.h
Normal file
214
cwmcc/prop.h
Normal file
|
@ -0,0 +1,214 @@
|
|||
#ifndef __atoms_h
|
||||
#define __atoms_h
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <glib.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
#include "openbox.h"
|
||||
|
||||
/*! The atoms on the X server which this class will cache */
|
||||
typedef struct Atoms {
|
||||
/* types */
|
||||
Atom cardinal; /*!< The atom which represents the Cardinal data type */
|
||||
Atom window; /*!< The atom which represents window ids */
|
||||
Atom pixmap; /*!< The atom which represents pixmap ids */
|
||||
Atom atom; /*!< The atom which represents atom values */
|
||||
Atom string; /*!< The atom which represents ascii strings */
|
||||
Atom utf8; /*!< The atom which represents utf8-encoded strings */
|
||||
|
||||
/* window hints */
|
||||
Atom wm_colormap_windows;
|
||||
Atom wm_protocols;
|
||||
Atom wm_state;
|
||||
Atom wm_delete_window;
|
||||
Atom wm_take_focus;
|
||||
Atom wm_change_state;
|
||||
Atom wm_name;
|
||||
Atom wm_icon_name;
|
||||
Atom wm_class;
|
||||
Atom wm_window_role;
|
||||
Atom motif_wm_hints;
|
||||
|
||||
/* NETWM atoms */
|
||||
|
||||
/* root window properties */
|
||||
Atom net_supported;
|
||||
Atom net_client_list;
|
||||
Atom net_client_list_stacking;
|
||||
Atom net_number_of_desktops;
|
||||
Atom net_desktop_geometry;
|
||||
Atom net_desktop_viewport;
|
||||
Atom net_current_desktop;
|
||||
Atom net_desktop_names;
|
||||
Atom net_active_window;
|
||||
Atom net_workarea;
|
||||
Atom net_supporting_wm_check;
|
||||
/* Atom net_virtual_roots; */
|
||||
Atom net_desktop_layout;
|
||||
Atom net_showing_desktop;
|
||||
/* root window messages */
|
||||
Atom net_close_window;
|
||||
Atom net_wm_moveresize;
|
||||
/* application window properties */
|
||||
/* Atom net_properties; */
|
||||
Atom net_wm_name;
|
||||
Atom net_wm_visible_name;
|
||||
Atom net_wm_icon_name;
|
||||
Atom net_wm_visible_icon_name;
|
||||
Atom net_wm_desktop;
|
||||
Atom net_wm_window_type;
|
||||
Atom net_wm_state;
|
||||
Atom net_wm_strut;
|
||||
/* Atom net_wm_icon_geometry; */
|
||||
Atom net_wm_icon;
|
||||
/* Atom net_wm_pid; */
|
||||
/* Atom net_wm_handled_icons; */
|
||||
Atom net_wm_allowed_actions;
|
||||
/* application protocols */
|
||||
/* Atom Atom net_wm_ping; */
|
||||
|
||||
Atom net_wm_window_type_desktop;
|
||||
Atom net_wm_window_type_dock;
|
||||
Atom net_wm_window_type_toolbar;
|
||||
Atom net_wm_window_type_menu;
|
||||
Atom net_wm_window_type_utility;
|
||||
Atom net_wm_window_type_splash;
|
||||
Atom net_wm_window_type_dialog;
|
||||
Atom net_wm_window_type_normal;
|
||||
|
||||
Atom net_wm_moveresize_size_topleft;
|
||||
Atom net_wm_moveresize_size_topright;
|
||||
Atom net_wm_moveresize_size_bottomleft;
|
||||
Atom net_wm_moveresize_size_bottomright;
|
||||
Atom net_wm_moveresize_move;
|
||||
|
||||
Atom net_wm_action_move;
|
||||
Atom net_wm_action_resize;
|
||||
Atom net_wm_action_minimize;
|
||||
Atom net_wm_action_shade;
|
||||
Atom net_wm_action_stick;
|
||||
Atom net_wm_action_maximize_horz;
|
||||
Atom net_wm_action_maximize_vert;
|
||||
Atom net_wm_action_fullscreen;
|
||||
Atom net_wm_action_change_desktop;
|
||||
Atom net_wm_action_close;
|
||||
|
||||
Atom net_wm_state_modal;
|
||||
Atom net_wm_state_sticky;
|
||||
Atom net_wm_state_maximized_vert;
|
||||
Atom net_wm_state_maximized_horz;
|
||||
Atom net_wm_state_shaded;
|
||||
Atom net_wm_state_skip_taskbar;
|
||||
Atom net_wm_state_skip_pager;
|
||||
Atom net_wm_state_hidden;
|
||||
Atom net_wm_state_fullscreen;
|
||||
Atom net_wm_state_above;
|
||||
Atom net_wm_state_below;
|
||||
|
||||
Atom net_wm_state_add;
|
||||
Atom net_wm_state_remove;
|
||||
Atom net_wm_state_toggle;
|
||||
|
||||
Atom net_wm_orientation_horz;
|
||||
Atom net_wm_orientation_vert;
|
||||
Atom net_wm_topleft;
|
||||
Atom net_wm_topright;
|
||||
Atom net_wm_bottomright;
|
||||
Atom net_wm_bottomleft;
|
||||
|
||||
/* Extra atoms */
|
||||
|
||||
Atom kde_net_system_tray_windows;
|
||||
Atom kde_net_wm_system_tray_window_for;
|
||||
Atom kde_net_wm_window_type_override;
|
||||
|
||||
Atom kwm_win_icon;
|
||||
|
||||
Atom rootpmapid;
|
||||
Atom esetrootid;
|
||||
|
||||
/* Openbox specific atoms */
|
||||
|
||||
Atom openbox_pid;
|
||||
Atom openbox_premax;
|
||||
} Atoms;
|
||||
Atoms prop_atoms;
|
||||
|
||||
void prop_startup();
|
||||
|
||||
gboolean prop_get(Window win, Atom prop, Atom type, int size,
|
||||
guchar **data, gulong num);
|
||||
|
||||
gboolean prop_get_prealloc(Window win, Atom prop, Atom type, int size,
|
||||
guchar *data, gulong num);
|
||||
|
||||
gboolean prop_get_all(Window win, Atom prop, Atom type, int size,
|
||||
guchar **data, gulong *num);
|
||||
|
||||
gboolean prop_get_string(Window win, Atom prop, Atom type, guchar **data);
|
||||
gboolean prop_get_strings(Window win, Atom prop, Atom type,
|
||||
GPtrArray *data);
|
||||
|
||||
void prop_set_strings(Window win, Atom prop, Atom type, GPtrArray *data);
|
||||
|
||||
void prop_erase(Window win, Atom prop);
|
||||
|
||||
void prop_message(Window about, Atom messagetype, long data0, long data1,
|
||||
long data2, long data3);
|
||||
|
||||
#define PROP_MSG(about, msgtype, data0, data1, data2, data3) \
|
||||
(prop_message(about, prop_atoms.msgtype, data0, data1, data2, data3))
|
||||
|
||||
/* Set an 8-bit property from a string */
|
||||
#define PROP_SETS(win, prop, type, value) \
|
||||
(XChangeProperty(ob_display, win, prop_atoms.prop, prop_atoms.type, 8, \
|
||||
PropModeReplace, (guchar*)value, strlen(value)))
|
||||
/* Set an 8-bit property array from a GPtrArray of strings */
|
||||
#define PROP_SETSA(win, prop, type, value) \
|
||||
(prop_set_strings(win, prop_atoms.prop, prop_atoms.type, value))
|
||||
|
||||
/* Set a 32-bit property from a single value */
|
||||
#define PROP_SET32(win, prop, type, value) \
|
||||
(XChangeProperty(ob_display, win, prop_atoms.prop, prop_atoms.type, 32, \
|
||||
PropModeReplace, (guchar*)&value, 1))
|
||||
/* Set a 32-bit property from an array */
|
||||
#define PROP_SET32A(win, prop, type, value, num) \
|
||||
(XChangeProperty(ob_display, win, prop_atoms.prop, prop_atoms.type, 32, \
|
||||
PropModeReplace, (guchar*)value, num))
|
||||
|
||||
/* Get an 8-bit property into a string */
|
||||
#define PROP_GETS(win, prop, type, value) \
|
||||
(prop_get_string(win, prop_atoms.prop, prop_atoms.type, \
|
||||
(guchar**)&value))
|
||||
/* Get an 8-bit property into a GPtrArray of strings
|
||||
(The strings must be freed, the GPtrArray must already be created.) */
|
||||
#define PROP_GETSA(win, prop, type, value) \
|
||||
(prop_get_strings(win, prop_atoms.prop, prop_atoms.type, \
|
||||
value))
|
||||
|
||||
/* Get an entire 8-bit property into an array (which must be freed) */
|
||||
#define PROP_GET8U(win, prop, type, value, num) \
|
||||
(prop_get_all(win, prop_atoms.prop, prop_atoms.type, 8, \
|
||||
(guchar**)&value, &num))
|
||||
|
||||
/* Get 1 element of a 32-bit property into a given variable */
|
||||
#define PROP_GET32(win, prop, type, value) \
|
||||
(prop_get_prealloc(win, prop_atoms.prop, prop_atoms.type, 32, \
|
||||
(guchar*)&value, 1))
|
||||
|
||||
/* Get an amount of a 32-bit property into an array (which must be freed) */
|
||||
#define PROP_GET32A(win, prop, type, value, num) \
|
||||
(prop_get(win, prop_atoms.prop, prop_atoms.type, 32, \
|
||||
(guchar**)&value, num))
|
||||
|
||||
/* Get an entire 32-bit property into an array (which must be freed) */
|
||||
#define PROP_GET32U(win, prop, type, value, num) \
|
||||
(prop_get_all(win, prop_atoms.prop, prop_atoms.type, 32, \
|
||||
(guchar**)&value, &num))
|
||||
|
||||
#define PROP_ERASE(win, prop) (prop_erase(win, prop_atoms.prop))
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue