+++ /dev/null
-.libs
-cwmcc.lo
-libcwmcc.la
-atom.lo
-prop.lo
-client_props.lo
-root_props.lo
+++ /dev/null
-#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);
-}
+++ /dev/null
-#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
+++ /dev/null
-#include "cwmcc_internal.h"
-#include "atom.h"
-#include "prop.h"
-#include "client_props.h"
-
-#include <X11/Xutil.h>
-#include <string.h>
-
-void cwmcc_client_get_protocols(Window win, Atom **protocols, gulong *num)
-{
- if (!cwmcc_prop_get_array32(win, CWMCC_ATOM(client, wm_protocols),
- CWMCC_ATOM(type, atom), protocols, num)) {
- g_warning("Failed to read WM_PROTOCOLS from 0x%lx", win);
- *protocols = NULL;
- *num = 0;
- }
-}
-
-void cwmcc_client_set_protocols(Window win, Atom *protocols, gulong num)
-{
- cwmcc_prop_set_array32(win, CWMCC_ATOM(client, wm_state),
- CWMCC_ATOM(type, atom), protocols, num);
-}
-
-void cwmcc_client_get_wm_state(Window win, gulong *state)
-{
- if (!cwmcc_prop_get32(win, CWMCC_ATOM(client, wm_state),
- CWMCC_ATOM(client, wm_state), state)) {
- g_warning("Failed to read WM_STATE from 0x%lx", win);
- *state = NormalState;
- }
-}
-
-void cwmcc_client_set_wm_state(Window win, gulong state)
-{
- cwmcc_prop_set32(win, CWMCC_ATOM(client, wm_state),
- CWMCC_ATOM(client, wm_state), state);
-}
-
-void cwmcc_client_get_name(Window win, char **name)
-{
- if (!cwmcc_prop_get_string_utf8(win, CWMCC_ATOM(client, net_wm_name),
- name))
- if (!cwmcc_prop_get_string_locale(win, CWMCC_ATOM(client, wm_name),
- name)) {
- g_warning("Failed to read a name from 0x%lx", win);
- *name = g_strdup("Unnamed Window");
- }
-}
-
-void cwmcc_client_set_name(Window win, char *name)
-{
- cwmcc_prop_set_string_utf8(win, CWMCC_ATOM(client, net_wm_name), name);
-}
-
-void cwmcc_client_get_icon_name(Window win, char **name)
-{
- if (!cwmcc_prop_get_string_utf8(win, CWMCC_ATOM(client, net_wm_icon_name),
- name))
- if (!cwmcc_prop_get_string_locale(win,CWMCC_ATOM(client, wm_icon_name),
- name)) {
- g_warning("Failed to read an icon name from 0x%lx", win);
- *name = g_strdup("Unnamed Window");
- }
-}
-
-void cwmcc_client_set_icon_name(Window win, char *name)
-{
- cwmcc_prop_set_string_utf8(win, CWMCC_ATOM(client, net_wm_icon_name),name);
-}
-
-void cwmcc_client_get_class(Window win, char **class, char **name)
-{
- char **s;
-
- if (!cwmcc_prop_get_strings_locale(win, CWMCC_ATOM(client, wm_class), &s)){
- g_warning("Failed to read WM_CLASS from 0x%lx", win);
- *class = g_strdup("");
- *name = g_strdup("");
- } else {
- if (!s[0]) {
- g_warning("Failed to read class element of WM_CLASS from 0x%lx",
- win);
- *class = g_strdup("");
- } else
- *class = g_strdup(s[0]);
- if (!s[0] || !s[1]) {
- g_warning("Failed to read name element of WM_CLASS from 0x%lx",
- win);
- *name = g_strdup("");
- } else
- *name = g_strdup(s[1]);
- }
- g_strfreev(s);
-}
-
-void cwmcc_client_get_role(Window win, char **role)
-{
- if (!cwmcc_prop_get_string_locale(win, CWMCC_ATOM(client, wm_window_role),
- role)) {
- g_warning("Failed to read WM_WINDOW_ROLE from 0x%lx", win);
- *role = g_strdup("");
- }
-}
-
-void cwmcc_client_get_mwmhints(Window win, struct Cwmcc_MwmHints *hints)
-{
- gulong *l = NULL, num;
-
- if (!cwmcc_prop_get_array32(win, CWMCC_ATOM(client, motif_wm_hints),
- CWMCC_ATOM(client, motif_wm_hints), &l, &num)){
- g_warning("Failed to read Motif WM Hints from 0x%lx", win);
- hints->flags = 0;
- } else if (num < 3) {
- g_warning("Read incomplete Motif WM Hints from 0x%lx", win);
- hints->flags = 0;
- } else {
- hints->flags = l[0];
- hints->functions = l[1];
- hints->decorations = l[2];
- }
- g_free(l);
-}
-
-void cwmcc_client_get_desktop(Window win, gulong *desk)
-{
- if (!cwmcc_prop_get32(win, CWMCC_ATOM(client, net_wm_desktop),
- CWMCC_ATOM(type, cardinal), desk)) {
- g_warning("Failed to read NET_WM_DESKTOP from 0x%lx", win);
- *desk = 0;
- }
-}
-
-void cwmcc_client_set_desktop(Window win, gulong desk)
-{
- cwmcc_prop_set32(win, CWMCC_ATOM(client, net_wm_desktop),
- CWMCC_ATOM(type, cardinal), desk);
-}
-
-void cwmcc_client_get_type(Window win, gulong **types, gulong *num)
-{
- if (!cwmcc_prop_get_array32(win, CWMCC_ATOM(client, net_wm_window_type),
- CWMCC_ATOM(type, atom), types, num)) {
- g_warning("Failed to read NET_WM_WINDOW_TYPE from 0x%lx", win);
- *types = g_new(Atom, 1);
- (*types)[0] = CWMCC_ATOM(data, net_wm_window_type_normal);
- *num = 1;
- }
-}
-
-void cwmcc_client_set_type(Window win, gulong *types, gulong num)
-{
- cwmcc_prop_set_array32(win, CWMCC_ATOM(client, net_wm_window_type),
- CWMCC_ATOM(type, atom), types, num);
-}
-
-void cwmcc_client_get_state(Window win, gulong **states, gulong *num)
-{
- if (!cwmcc_prop_get_array32(win, CWMCC_ATOM(client, net_wm_state),
- CWMCC_ATOM(type, atom), states, num)) {
- g_warning("Failed to read NET_WM_STATE from 0x%lx", win);
- *states = NULL;
- *num = 0;
- }
-}
-
-void cwmcc_client_set_state(Window win, gulong *states, gulong num)
-{
- cwmcc_prop_set_array32(win, CWMCC_ATOM(client, net_wm_state),
- CWMCC_ATOM(type, atom), states, num);
-}
-
-void cwmcc_client_get_strut(Window win, int *l, int *t, int *r, int *b)
-{
- gulong *data = NULL, num;
-
- if (!cwmcc_prop_get_array32(win, CWMCC_ATOM(client, net_wm_strut),
- CWMCC_ATOM(type, cardinal), &data, &num)) {
- g_warning("Failed to read NET_WM_STRUT from 0x%lx", win);
- *l = *t = *r = *b = 0;
- } else if (num != 4) {
- g_warning("Read invalid NET_WM_STRUT from 0x%lx", win);
- *l = *t = *r = *b = 0;
- } else {
- *l = data[0];
- *r = data[1];
- *t = data[2];
- *b = data[3];
- }
- g_free(data);
-}
-
-void cwmcc_client_set_strut(Window win, int l, int t, int r, int b)
-{
- gulong data[4];
-
- data[0] = l;
- data[1] = r;
- data[2] = t;
- data[3] = b;
- cwmcc_prop_set_array32(win, CWMCC_ATOM(client, net_wm_strut),
- CWMCC_ATOM(type, cardinal), data, 4);
-}
-
-static void convert_pixmap_to_icon(Pixmap pix, Pixmap mask,
- struct Cwmcc_Icon *icon)
-{
-/*
- guint pw, ph, mw, mh, depth;
- Window wjunk;
- int ijunk;
- guint uijunk;
- guint x, y;
-
- if (!XGetGeometry(cwmcc_display, pix, &wjunk, &ijunk, &ijunk, &pw, &ph,
- &uijunk, &depth)) {
- g_message("Unable to read pixmap icon's geometry");
- icon->width = icon->height = 0;
- icon->data = NULL;
- return;
- }
- if (!XGetGeometry(cwmcc_display, mask, &wjunk, &ijunk, &ijunk, &mw, &mh,
- &uijunk, &ujunk)) {
- g_message("Unable to read pixmap icon's mask's geometry");
- icon->width = icon->height = 0;
- icon->data = NULL;
- return;
- }
- if (pw != mw || ph !_ mh) {
- g_warning("Pixmap icon's mask does not match icon's dimensions");
- icon->width = icon->height = 0;
- icon->data = NULL;
- return;
- }
-
- for (y = 0; y < ph; ++y)
- for (x = 0; x < pw; ++x) {
- }
-*/
- icon->width = icon->height = 0;
- icon->data = NULL;
-}
-
-void cwmcc_client_get_icon(Window win, struct Cwmcc_Icon **icons, gulong *num)
-{
- gulong *data = NULL;
- gulong w, h, i;
- int j;
- int nicons;
-
- if (!cwmcc_prop_get_array32(win, CWMCC_ATOM(client, net_wm_icon),
- CWMCC_ATOM(type, cardinal), &data, num)) {
- g_warning("Failed to read NET_WM_ICON from 0x%lx", win);
- *icons = NULL;
- nicons = 0;
- } else {
- /* figure out how many valid icons are in here */
- i = 0;
- nicons = 0;
- while (*num - i > 2) {
- w = data[i++];
- h = data[i++];
- i += w * h;
- if (i > *num) break;
- ++nicons;
- }
-
- *icons = g_new(struct Cwmcc_Icon, nicons);
-
- /* store the icons */
- i = 0;
- for (j = 0; j < nicons; ++j) {
- w = (*icons)[j].width = data[i++];
- h = (*icons)[j].height = data[i++];
- (*icons)[j].data =
- g_memdup(&data[i], w * h * sizeof(gulong));
- i += w * h;
- g_assert(i <= *num);
- }
- }
- g_free(data);
-
- data = NULL;
- if (!cwmcc_prop_get_array32(win, CWMCC_ATOM(client, kwm_win_icon),
- CWMCC_ATOM(client, kwm_win_icon), &data, num)){
- g_warning("Failed to read KWM_WIN_ICON from 0x%lx", win);
- } else if (*num != 2) {
- g_warning("Read invalid KWM_WIN_ICON from 0x%lx", win);
- } else {
- Pixmap p, m;
- struct Cwmcc_Icon icon;
-
- p = data[0];
- m = data[1];
-
- convert_pixmap_to_icon(p, m, &icon);
-
- if (icon.data) {
- ++nicons;
- *icons = g_renew(struct Cwmcc_Icon, *icons, nicons);
- (*icons[nicons]).data = NULL;
- g_memmove(&(*icons)[nicons-1], &icon, sizeof(struct Cwmcc_Icon));
- }
- }
- g_free(data);
-
- *num = nicons;
-}
-
-void cwmcc_client_get_premax(Window win, int *x, int *y, int *w, int *h)
-{
- gulong *l = NULL, num;
-
- if (!cwmcc_prop_get_array32(win, CWMCC_ATOM(client, openbox_premax),
- CWMCC_ATOM(type, cardinal), &l, &num)) {
- g_warning("Failed to read OPENBOX_PREMAX from 0x%lx", win);
- *x = *y = *w = *h = 0;
- } else if (num != 4) {
- g_warning("Read invalid OPENBOX_PREMAX from 0x%lx", win);
- *x = *y = *w = *h = 0;
- } else {
- *x = l[0];
- *y = l[1];
- *w = l[2];
- *h = l[3];
- }
- g_free(l);
-}
-
-void cwmcc_client_set_premax(Window win, int x, int y, int w, int h)
-{
- gulong l[4];
-
- l[0] = x;
- l[1] = y;
- l[2] = w;
- l[3] = h;
- cwmcc_prop_set_array32(win, CWMCC_ATOM(client, openbox_premax),
- CWMCC_ATOM(type, cardinal), l, 4);
-}
+++ /dev/null
-#ifndef __cwmcc_client_get_props_h
-#define __cwmcc_client_get_props_h
-
-void cwmcc_client_get_protocols(Window win, Atom **protocols, gulong *num);
-void cwmcc_client_set_protocols(Window win, Atom *protocols, gulong num);
-
-void cwmcc_client_get_wm_state(Window win, gulong *state);
-void cwmcc_client_set_wm_state(Window win, gulong state);
-
-void cwmcc_client_get_name(Window win, char **name);
-void cwmcc_client_set_name(Window win, char *name);
-
-void cwmcc_client_get_icon_name(Window win, char **name);
-void cwmcc_client_set_icon_name(Window win, char *name);
-
-void cwmcc_client_get_class(Window win, char **class, char **name);
-
-/*! Possible flags for MWM Hints (defined by Motif 2.0) */
-enum Cwmcc_MwmFlags {
- Cwmcc_MwmFlag_Functions = 1 << 0, /*!< The Hints define functions */
- Cwmcc_MwmFlag_Decorations = 1 << 1 /*!< The Hints define decorations */
-};
-
-/*! Possible functions for MWM Hints (defined by Motif 2.0) */
-enum Cwmcc_MwmFunctions {
- Cwmcc_MwmFunc_All = 1 << 0, /*!< All functions */
- Cwmcc_MwmFunc_Resize = 1 << 1, /*!< Allow resizing */
- Cwmcc_MwmFunc_Move = 1 << 2, /*!< Allow moving */
- Cwmcc_MwmFunc_Iconify = 1 << 3, /*!< Allow to be iconfied */
- Cwmcc_MwmFunc_Maximize = 1 << 4 /*!< Allow to be maximized */
- /*MwmFunc_Close = 1 << 5 /!< Allow to be closed */
-};
-
-/*! Possible decorations for MWM Hints (defined by Motif 2.0) */
-enum Cwmcc_MwmDecorations {
- Cwmcc_MwmDecor_All = 1 << 0, /*!< All decorations */
- Cwmcc_MwmDecor_Border = 1 << 1, /*!< Show a border */
- Cwmcc_MwmDecor_Handle = 1 << 2, /*!< Show a handle (bottom) */
- Cwmcc_MwmDecor_Title = 1 << 3, /*!< Show a titlebar */
- Cwmcc_MwmDecor_Menu = 1 << 4, /*!< Show a menu */
- Cwmcc_MwmDecor_Iconify = 1 << 5, /*!< Show an iconify button */
- Cwmcc_MwmDecor_Maximize = 1 << 6 /*!< Show a maximize button */
-};
-
-/*! The MWM Hints as retrieved from the window property
- This structure only contains 3 elements, even though the Motif 2.0
- structure contains 5. We only use the first 3, so that is all gets
- defined.
-*/
-struct Cwmcc_MwmHints {
- /*! A bitmask of Cwmcc_MwmFlags values */
- gulong flags;
- /*! A bitmask of Cwmcc_MwmFunctions values */
- gulong functions;
- /*! A bitmask of Cwmcc_MwmDecorations values */
- gulong decorations;
-};
-
-void cwmcc_client_get_mwmhints(Window win, struct Cwmcc_MwmHints *hints);
-
-void cwmcc_client_get_desktop(Window win, gulong *desk);
-void cwmcc_client_set_desktop(Window win, gulong desk);
-
-void cwmcc_client_get_type(Window win, gulong **types, gulong *num);
-void cwmcc_client_set_type(Window win, gulong *types, gulong num);
-
-void cwmcc_client_get_state(Window win, gulong **states, gulong *num);
-void cwmcc_client_set_state(Window win, gulong *states, gulong num);
-
-void cwmcc_client_get_strut(Window win, int *l, int *t, int *r, int *b);
-void cwmcc_client_set_strut(Window win, int l, int t, int r, int b);
-
-/*! Holds an icon in ARGB format */
-struct Cwmcc_Icon {
- gulong width, height;
- gulong *data;
-};
-
-/* Returns an array of Cwms_Icons. The array is terminated by a Cwmcc_Icon with
- its data member set to NULL */
-void cwmcc_client_get_icon(Window win, struct Cwmcc_Icon **icons, gulong *num);
-
-void cwmcc_client_get_premax(Window win, int *x, int *y, int *w, int *h);
-void cwmcc_client_set_premax(Window win, int x, int y, int w, int h);
-
-#endif
+++ /dev/null
-#include "cwmcc_internal.h"
-#include "atom.h"
-
-Display *cwmcc_display;
-
-void cwmcc_startup(Display *d)
-{
- cwmcc_display = d;
- atom_startup();
-}
+++ /dev/null
-#ifndef __cwmcc_cwmcc_h
-#define __cwmcc_cwmcc_h
-
-void cwmcc_startup(Display *d);
-
-#endif
+++ /dev/null
-#ifndef __cwmcc_cwmcc_internal_h
-#define __cwmcc_cwmcc_internal_h
-
-#include <X11/Xlib.h>
-
-extern Display *cwmcc_display;
-
-#endif
+++ /dev/null
-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 = cwmcc_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(cwmcc_display, ob_root, FALSE,
- SubstructureNotifyMask | SubstructureRedirectMask, &ce);
-}
+++ /dev/null
-#include "cwmcc_internal.h"
-#include "atom.h"
-
-#include <X11/Xutil.h>
-#include <glib.h>
-#include <string.h>
-
-/* this just isn't used...
-static gboolean 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(cwmcc_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;
-}
-*/
-
-static gboolean 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(cwmcc_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;
-}
-
-static gboolean 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(cwmcc_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;
-}
-
-static gboolean get_stringlist(Window win, Atom prop, char ***list, int *nstr)
-{
- XTextProperty tprop;
- gboolean ret = FALSE;
-
- if (XGetTextProperty(cwmcc_display, win, &tprop, prop) && tprop.nitems) {
- if (XTextPropertyToStringList(&tprop, list, nstr))
- ret = TRUE;
- XFree(tprop.value);
- }
- return ret;
-}
-
-gboolean cwmcc_prop_get32(Window win, Atom prop, Atom type, gulong *ret)
-{
- return get_prealloc(win, prop, type, 32, (guchar*)ret, 1);
-}
-
-gboolean cwmcc_prop_get_array32(Window win, Atom prop, Atom type, gulong **ret,
- gulong *nret)
-{
- return get_all(win, prop, type, 32, (guchar**)ret, nret);
-}
-
-gboolean cwmcc_prop_get_string_locale(Window win, Atom prop, char **data)
-{
- char **list;
- int nstr;
-
- if (get_stringlist(win, prop, &list, &nstr) && nstr) {
- *data = g_locale_to_utf8(list[0], -1, NULL, NULL, NULL);
- XFreeStringList(list);
- if (data) return TRUE;
- }
- return FALSE;
-}
-
-gboolean cwmcc_prop_get_string_utf8(Window win, Atom prop, char **ret)
-{
- char *raw;
- gulong num;
-
- if (get_all(win, prop, CWMCC_ATOM(type, utf8), 8, (guchar**)&raw, &num)) {
- *ret = g_strdup(raw); /* grab the first string from the list */
- g_free(raw);
- return TRUE;
- }
- return FALSE;
-}
-
-gboolean cwmcc_prop_get_strings_utf8(Window win, Atom prop, char ***ret)
-{
- char *raw, *p;
- gulong num, i;
-
- if (get_all(win, prop, CWMCC_ATOM(type, utf8), 8, (guchar**)&raw, &num)) {
- *ret = g_new(char*, num + 1);
- (*ret)[num] = NULL; /* null terminated list */
-
- p = raw;
- for (i = 0; i < num; ++i) {
- (*ret)[i] = g_strdup(p);
- p = strchr(p, '\0');
- }
- g_free(raw);
- return TRUE;
- }
- return FALSE;
-}
-
-gboolean cwmcc_prop_get_strings_locale(Window win, Atom prop, char ***ret)
-{
- char *raw, *p;
- gulong num, i;
-
- if (get_all(win, prop, CWMCC_ATOM(type, string), 8, (guchar**)&raw, &num)){
- *ret = g_new(char*, num + 1);
- (*ret)[num] = NULL; /* null terminated list */
-
- p = raw;
- for (i = 0; i < num; ++i) {
- (*ret)[i] = g_locale_to_utf8(p, -1, NULL, NULL, NULL);
- /* make sure translation did not fail */
- if (!(*ret)[i]) {
- g_strfreev(*ret); /* free what we did so far */
- break; /* the force is not strong with us */
- }
- p = strchr(p, '\0');
- }
- g_free(raw);
- if (i == num)
- return TRUE;
- }
- return FALSE;
-}
-
-void cwmcc_prop_set32(Window win, Atom prop, Atom type, gulong val)
-{
- XChangeProperty(cwmcc_display, win, prop, type, 32, PropModeReplace,
- (guchar*)&val, 1);
-}
-
-void cwmcc_prop_set_array32(Window win, Atom prop, Atom type,
- gulong *val, gulong num)
-{
- XChangeProperty(cwmcc_display, win, prop, type, 32, PropModeReplace,
- (guchar*)val, num);
-}
-
-void cwmcc_prop_set_string_utf8(Window win, Atom prop, char *val)
-{
- XChangeProperty(cwmcc_display, win, prop, CWMCC_ATOM(type, utf8), 8,
- PropModeReplace, (guchar*)val, strlen(val));
-}
-
-void cwmcc_prop_set_strings_utf8(Window win, Atom prop, char **strs)
-{
- GString *str;
- guint i;
-
- str = g_string_sized_new(0);
- for (i = 0; strs[i]; ++i) {
- str = g_string_append(str, strs[i]);
- str = g_string_append_c(str, '\0');
- }
- XChangeProperty(cwmcc_display, win, prop, CWMCC_ATOM(type, utf8), 8,
- PropModeReplace, (guchar*)str->str, str->len);
-}
-
-void cwmcc_prop_erase(Window win, Atom prop)
-{
- XDeleteProperty(cwmcc_display, win, prop);
-}
-
+++ /dev/null
-#ifndef __cwmcc_prop_h
-#define __cwmcc_prop_h
-
-#include <glib.h>
-#include <X11/Xlib.h>
-
-/* with the exception of prop_get32, all other prop_get_* functions require
- you to free the returned value with g_free or g_strfreev (for the char**s)
-*/
-
-gboolean cwmcc_prop_get32(Window win, Atom prop, Atom type, gulong *ret);
-
-gboolean cwmcc_prop_get_array32(Window win, Atom prop, Atom type, gulong **ret,
- gulong *nret);
-
-gboolean cwmcc_prop_get_string(Window win, Atom prop, Atom type, char **ret);
-
-/*! Gets a string from a property which is stored in UTF-8 encoding. */
-gboolean cwmcc_prop_get_string_utf8(Window win, Atom prop, char **ret);
-
-/*! Gets a string from a property which is stored in the current local
- encoding. The returned string is in UTF-8 encoding. */
-gboolean cwmcc_prop_get_string_locale(Window win, Atom prop, char **ret);
-
-/*! Gets a null terminated array of strings from a property which is stored in
- UTF-8 encoding. */
-gboolean cwmcc_prop_get_strings_utf8(Window win, Atom prop, char ***ret);
-
-/*! Gets a null terminated array of strings from a property which is stored in
- the current locale encoding. The returned string is in UTF-8 encoding. */
-gboolean cwmcc_prop_get_strings_locale(Window win, Atom prop, char ***ret);
-
-void cwmcc_prop_set32(Window win, Atom prop, Atom type, gulong val);
-
-void cwmcc_prop_set_array32(Window win, Atom prop, Atom type,
- gulong *val, gulong num);
-
-void cwmcc_prop_set_string_utf8(Window win, Atom prop, char *val);
-
-/*! Sets a null terminated array of strings in a property encoded as UTF-8. */
-void cwmcc_prop_set_strings_utf8(Window win, Atom prop, char **strs);
-
-void cwmcc_prop_erase(Window win, Atom prop);
-
-#endif
+++ /dev/null
-#include "cwmcc_internal.h"
-#include "atom.h"
-#include "prop.h"
-#include "root_props.h"
-
-#include <string.h>
-
-void cwmcc_root_get_supported(Window win, Atom **atoms, gulong *num)
-{
- if (!cwmcc_prop_get_array32(win, CWMCC_ATOM(root, net_supported),
- CWMCC_ATOM(type, atom), atoms, num)) {
- g_warning("Failed to read NET_SUPPORTED from 0x%lx", win);
- *atoms = NULL;
- *num = 0;
- }
-}
-
-void cwmcc_root_get_client_list(Window win, Window **windows, gulong *num)
-{
- if (!cwmcc_prop_get_array32(win, CWMCC_ATOM(root, net_client_list),
- CWMCC_ATOM(type, window), windows, num)) {
- g_warning("Failed to read NET_CLIENT_LIST from 0x%lx", win);
- *windows = NULL;
- *num = 0;
- }
-}
-
-void cwmcc_root_get_client_list_stacking(Window win, Window **windows,
- gulong *num)
-{
- if (!cwmcc_prop_get_array32(win,CWMCC_ATOM(root, net_client_list_stacking),
- CWMCC_ATOM(type, window), windows, num)) {
- g_warning("Failed to read NET_CLIENT_LIST_STACKING from 0x%lx", win);
- *windows = NULL;
- *num = 0;
- }
-}
-
-void cwmcc_root_get_number_of_desktops(Window win, gulong *desktops)
-{
- if (!cwmcc_prop_get32(win, CWMCC_ATOM(root, net_number_of_desktops),
- CWMCC_ATOM(type, cardinal), desktops)) {
- g_warning("Failed to read NET_NUMBER_OF_DESKTOPS from 0x%lx", win);
- *desktops = 1;
- }
-}
-
-void cwmcc_root_get_desktop_geometry(Window win, gulong *w, gulong *h)
-{
- gulong *data = NULL, num;
-
- if (!cwmcc_prop_get_array32(win, CWMCC_ATOM(root, net_desktop_geometry),
- CWMCC_ATOM(type, cardinal), &data, &num)) {
- g_warning("Failed to read NET_DESKTOP_GEOMETRY from 0x%lx", win);
- *w = *h = 0;
- } else if (num != 2) {
- g_warning("Read invalid NET_DESKTOP_GEOMETRY from 0x%lx", win);
- *w = *h = 0;
- } else {
- *w = data[0];
- *h = data[1];
- }
- g_free(data);
-}
-
-void cwmcc_root_get_desktop_viewport(Window win, gulong *x, gulong *y)
-{
- gulong *data = NULL, num;
-
- if (!cwmcc_prop_get_array32(win, CWMCC_ATOM(root, net_desktop_viewport),
- CWMCC_ATOM(type, cardinal), &data, &num)) {
- g_warning("Failed to read NET_DESKTOP_VIEWPORT from 0x%lx", win);
- *x = *y = 0;
- } else if (num != 2) {
- g_warning("Read invalid NET_DESKTOP_VIEWPORT from 0x%lx", win);
- *x = *y = 0;
- } else {
- *x = data[0];
- *y = data[1];
- }
- g_free(data);
-}
-
-void cwmcc_root_get_current_desktop(Window win, gulong *desktop)
-{
- if (!cwmcc_prop_get32(win, CWMCC_ATOM(root, net_current_desktop),
- CWMCC_ATOM(type, cardinal), desktop)) {
- g_warning("Failed to read NET_CURRENT_DESKTOP from 0x%lx", win);
- *desktop = 0;
- }
-}
-
-void cwmcc_root_get_desktop_names(Window win, char ***names)
-{
- if (!cwmcc_prop_get_strings_utf8(win, CWMCC_ATOM(root, net_desktop_names),
- names)) {
- g_warning("Failed to read NET_DESKTOP_NAMES from 0x%lx", win);
- *names = NULL;
- }
-}
-
-void cwmcc_root_get_active_window(Window win, Window *window)
-{
- if (!cwmcc_prop_get32(win, CWMCC_ATOM(root, net_active_window),
- CWMCC_ATOM(type, window), window)) {
- g_warning("Failed to read NET_ACTIVE_WINDOW from 0x%lx", win);
- *window = None;
- }
-}
-
-void cwmcc_root_get_workarea(Window win, int **x, int **y, int **w, int **h)
-{
- gulong *data = NULL, num;
- gulong desks, i;
-
- /* need the number of desktops */
- cwmcc_root_get_number_of_desktops(win, &desks);
-
- if (!cwmcc_prop_get_array32(win, CWMCC_ATOM(root, net_workarea),
- CWMCC_ATOM(type, cardinal), &data, &num)) {
- g_warning("Failed to read NET_DESKTOP_LAYOUT from 0x%lx", win);
- } else if (num != 4 * desks) {
- g_warning("Read invalid NET_DESKTOP_LAYOUT from 0x%lx", win);
- } else {
- *x = g_new(int, desks);
- *y = g_new(int, desks);
- *w = g_new(int, desks);
- *h = g_new(int, desks);
- for (i = 0; i < desks; ++i) {
- (*x)[i] = data[i * 4];
- (*y)[i] = data[i * 4 + 1];
- (*w)[i] = data[i * 4 + 2];
- (*h)[i] = data[i * 4 + 3];
- }
- }
-}
-
-void cwmcc_root_get_supporting_wm_check(Window win, Window *window)
-{
- if (!cwmcc_prop_get32(win, CWMCC_ATOM(root, net_supporting_wm_check),
- CWMCC_ATOM(type, window), window)) {
- g_warning("Failed to read NET_SUPPORTING_WM_CHECK from 0x%lx", win);
- *window = None;
- }
-}
-
-void cwmcc_root_get_desktop_layout(Window win,
- struct Cwmcc_DesktopLayout *layout)
-{
- gulong *data = NULL, num;
- gulong desks;
-
- /* need the number of desktops */
- cwmcc_root_get_number_of_desktops(win, &desks);
-
- layout->orientation = Cwmcc_Orientation_Horz;
- layout->start_corner = Cwmcc_Corner_TopLeft;
- layout->rows = 1;
- layout->columns = desks;
-
- if (!cwmcc_prop_get_array32(win, CWMCC_ATOM(root, net_desktop_layout),
- CWMCC_ATOM(type, cardinal), &data, &num)) {
- g_warning("Failed to read NET_DESKTOP_LAYOUT from 0x%lx", win);
- } else if (num != 4) {
- g_warning("Read invalid NET_DESKTOP_LAYOUT from 0x%lx", win);
- } else {
- if (data[0] == Cwmcc_Orientation_Horz ||
- data[0] == Cwmcc_Orientation_Vert)
- layout->orientation = data[0];
- if (data[3] == Cwmcc_Corner_TopLeft ||
- data[3] == Cwmcc_Corner_TopRight ||
- data[3] == Cwmcc_Corner_BottomLeft ||
- data[3] == Cwmcc_Corner_BottomRight)
- layout->start_corner = data[3];
- layout->rows = data[2];
- layout->columns = data[1];
-
- /* bounds checking */
- if (layout->orientation == Cwmcc_Orientation_Horz) {
- if (layout->rows > desks)
- layout->rows = desks;
- if (layout->columns > ((desks + desks % layout->rows) /
- layout->rows))
- layout->columns = ((desks + desks % layout->rows) /
- layout->rows);
- } else {
- if (layout->columns > desks)
- layout->columns = desks;
- if (layout->rows > ((desks + desks % layout->columns) /
- layout->columns))
- layout->rows = ((desks + desks % layout->columns) /
- layout->columns);
- }
- }
- g_free(data);
-}
-
-void cwmcc_root_get_showing_desktop(Window win, gboolean *showing)
-{
- gulong a;
-
- if (!cwmcc_prop_get32(win, CWMCC_ATOM(root, net_showing_desktop),
- CWMCC_ATOM(type, cardinal), &a)) {
- g_warning("Failed to read NET_SHOWING_DESKTOP from 0x%lx", win);
- a = FALSE;
- }
- *showing = !!a;
-}
-
-void cwmcc_root_get_openbox_pid(Window win, gulong *pid)
-{
- if (!cwmcc_prop_get32(win, CWMCC_ATOM(root, openbox_pid),
- CWMCC_ATOM(type, cardinal), pid)) {
- g_warning("Failed to read OPENBOX_PID from 0x%lx", win);
- *pid = 0;
- }
-}
-
+++ /dev/null
-/*#ifndef __cwmcc_root_props_h
- #define __cwmcc_root_props_h*/
-
-#include <X11/Xlib.h>
-#include <glib.h>
-
-void cwmcc_root_get_supported(Window win, Atom **atoms, gulong *num);
-
-void cwmcc_root_get_client_list(Window win, Window **windows, gulong *num);
-
-void cwmcc_root_get_client_list_stacking(Window win, Window **windows,
- gulong *num);
-
-void cwmcc_root_get_number_of_desktops(Window win, gulong *desktops);
-
-void cwmcc_root_get_desktop_geometry(Window win, gulong *w, gulong *h);
-
-void cwmcc_root_get_desktop_viewport(Window win, gulong *x, gulong *y);
-
-void cwmcc_root_get_current_desktop(Window win, gulong *desktop);
-
-void cwmcc_root_get_desktop_names(Window win, char ***names);
-
-void cwmcc_root_get_active_window(Window win, Window *window);
-
-void cwmcc_root_get_workarea(Window win, int **x, int **y, int **w, int **h);
-
-void cwmcc_root_get_supporting_wm_check(Window win, Window *window);
-
-/*! Orientation of the desktops */
-enum Cwmcc_Orientation {
- Cwmcc_Orientation_Horz = 0,
- Cwmcc_Orientation_Vert = 1
-};
-
-enum Cwmcc_Corner {
- Cwmcc_Corner_TopLeft = 0,
- Cwmcc_Corner_TopRight = 1,
- Cwmcc_Corner_BottomRight = 2,
- Cwmcc_Corner_BottomLeft = 3
-};
-
-struct Cwmcc_DesktopLayout {
- enum Cwmcc_Orientation orientation;
- enum Cwmcc_Corner start_corner;
- guint rows;
- guint columns;
-};
-
-void cwmcc_root_get_desktop_layout(Window win,
- struct Cwmcc_DesktopLayout *layout);
-
-void cwmcc_root_get_showing_desktop(Window win, gboolean *showing);
-
-void cwmcc_root_get_openbox_pid(Window win, gulong *pid);
-
-/*#endif*/