--- /dev/null
+/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
+
+ obt/prop.c for the Openbox window manager
+ Copyright (c) 2006 Mikael Magnusson
+ Copyright (c) 2003-2007 Dana Jansens
+
+ 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.
+
+ See the COPYING file for a copy of the GNU General Public License.
+*/
+
+#include "obt/prop.h"
+#include "obt/display.h"
+
+#include <X11/Xatom.h>
+#ifdef HAVE_STRING_H
+# include <string.h>
+#endif
+
+Atom prop_atoms[OBT_PROP_NUM_ATOMS];
+gboolean prop_started = FALSE;
+
+#define CREATE_NAME(var, name) (prop_atoms[OBT_PROP_##var] = \
+ XInternAtom((obt_display), (name), FALSE))
+#define CREATE(var) CREATE_NAME(var, #var)
+#define CREATE_(var) CREATE_NAME(var, "_" #var)
+
+void obt_prop_startup(void)
+{
+ if (prop_started) return;
+ prop_started = TRUE;
+
+ g_assert(obt_display);
+
+ CREATE(CARDINAL);
+ CREATE(WINDOW);
+ CREATE(PIXMAP);
+ CREATE(ATOM);
+ CREATE(STRING);
+ CREATE_NAME(UTF8, "UTF8_STRING");
+
+ CREATE(MANAGER);
+
+ CREATE(WM_COLORMAP_WINDOWS);
+ CREATE(WM_PROTOCOLS);
+ CREATE(WM_STATE);
+ CREATE(WM_CHANGE_STATE);
+ CREATE(WM_DELETE_WINDOW);
+ CREATE(WM_TAKE_FOCUS);
+ CREATE(WM_NAME);
+ CREATE(WM_ICON_NAME);
+ CREATE(WM_CLASS);
+ CREATE(WM_WINDOW_ROLE);
+ CREATE(WM_CLIENT_MACHINE);
+ CREATE(WM_COMMAND);
+ CREATE(WM_CLIENT_LEADER);
+ CREATE(WM_TRANSIENT_FOR);
+ CREATE_(MOTIF_WM_HINTS);
+ CREATE_(MOTIF_WM_INFO);
+
+ CREATE(SM_CLIENT_ID);
+
+ CREATE_(NET_WM_FULL_PLACEMENT);
+
+ CREATE_(NET_SUPPORTED);
+ CREATE_(NET_CLIENT_LIST);
+ CREATE_(NET_CLIENT_LIST_STACKING);
+ CREATE_(NET_NUMBER_OF_DESKTOPS);
+ CREATE_(NET_DESKTOP_GEOMETRY);
+ CREATE_(NET_DESKTOP_VIEWPORT);
+ CREATE_(NET_CURRENT_DESKTOP);
+ CREATE_(NET_DESKTOP_NAMES);
+ CREATE_(NET_ACTIVE_WINDOW);
+/* CREATE_(NET_RESTACK_WINDOW);*/
+ CREATE_(NET_WORKAREA);
+ CREATE_(NET_SUPPORTING_WM_CHECK);
+ CREATE_(NET_DESKTOP_LAYOUT);
+ CREATE_(NET_SHOWING_DESKTOP);
+
+ CREATE_(NET_CLOSE_WINDOW);
+ CREATE_(NET_WM_MOVERESIZE);
+ CREATE_(NET_MOVERESIZE_WINDOW);
+ CREATE_(NET_REQUEST_FRAME_EXTENTS);
+ CREATE_(NET_RESTACK_WINDOW);
+
+ CREATE_(NET_STARTUP_ID);
+
+ CREATE_(NET_WM_NAME);
+ CREATE_(NET_WM_VISIBLE_NAME);
+ CREATE_(NET_WM_ICON_NAME);
+ CREATE_(NET_WM_VISIBLE_ICON_NAME);
+ CREATE_(NET_WM_DESKTOP);
+ CREATE_(NET_WM_WINDOW_TYPE);
+ CREATE_(NET_WM_STATE);
+ CREATE_(NET_WM_STRUT);
+ CREATE_(NET_WM_STRUT_PARTIAL);
+ CREATE_(NET_WM_ICON);
+ CREATE_(NET_WM_ICON_GEOMETRY);
+ CREATE_(NET_WM_PID);
+ CREATE_(NET_WM_ALLOWED_ACTIONS);
+ CREATE_(NET_WM_USER_TIME);
+/* CREATE_(NET_WM_USER_TIME_WINDOW); */
+ CREATE_(KDE_NET_WM_FRAME_STRUT);
+ CREATE_(NET_FRAME_EXTENTS);
+
+ CREATE_(NET_WM_PING);
+#ifdef SYNC
+ CREATE_(NET_WM_SYNC_REQUEST);
+ CREATE_(NET_WM_SYNC_REQUEST_COUNTER);
+#endif
+
+ CREATE_(NET_WM_WINDOW_TYPE_DESKTOP);
+ CREATE_(NET_WM_WINDOW_TYPE_DOCK);
+ CREATE_(NET_WM_WINDOW_TYPE_TOOLBAR);
+ CREATE_(NET_WM_WINDOW_TYPE_MENU);
+ CREATE_(NET_WM_WINDOW_TYPE_UTILITY);
+ CREATE_(NET_WM_WINDOW_TYPE_SPLASH);
+ CREATE_(NET_WM_WINDOW_TYPE_DIALOG);
+ CREATE_(NET_WM_WINDOW_TYPE_NORMAL);
+ CREATE_(NET_WM_WINDOW_TYPE_POPUP_MENU);
+
+ prop_atoms[OBT_PROP_NET_WM_MOVERESIZE_SIZE_TOPLEFT] = 0;
+ prop_atoms[OBT_PROP_NET_WM_MOVERESIZE_SIZE_TOP] = 1;
+ prop_atoms[OBT_PROP_NET_WM_MOVERESIZE_SIZE_TOPRIGHT] = 2;
+ prop_atoms[OBT_PROP_NET_WM_MOVERESIZE_SIZE_RIGHT] = 3;
+ prop_atoms[OBT_PROP_NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT] = 4;
+ prop_atoms[OBT_PROP_NET_WM_MOVERESIZE_SIZE_BOTTOM] = 5;
+ prop_atoms[OBT_PROP_NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT] = 6;
+ prop_atoms[OBT_PROP_NET_WM_MOVERESIZE_SIZE_LEFT] = 7;
+ prop_atoms[OBT_PROP_NET_WM_MOVERESIZE_MOVE] = 8;
+ prop_atoms[OBT_PROP_NET_WM_MOVERESIZE_SIZE_KEYBOARD] = 9;
+ prop_atoms[OBT_PROP_NET_WM_MOVERESIZE_MOVE_KEYBOARD] = 10;
+ prop_atoms[OBT_PROP_NET_WM_MOVERESIZE_CANCEL] = 11;
+
+ CREATE_(NET_WM_ACTION_MOVE);
+ CREATE_(NET_WM_ACTION_RESIZE);
+ CREATE_(NET_WM_ACTION_MINIMIZE);
+ CREATE_(NET_WM_ACTION_SHADE);
+ CREATE_(NET_WM_ACTION_MAXIMIZE_HORZ);
+ CREATE_(NET_WM_ACTION_MAXIMIZE_VERT);
+ CREATE_(NET_WM_ACTION_FULLSCREEN);
+ CREATE_(NET_WM_ACTION_CHANGE_DESKTOP);
+ CREATE_(NET_WM_ACTION_CLOSE);
+ CREATE_(NET_WM_ACTION_ABOVE);
+ CREATE_(NET_WM_ACTION_BELOW);
+
+ CREATE_(NET_WM_STATE_MODAL);
+/* CREATE_(NET_WM_STATE_STICKY);*/
+ CREATE_(NET_WM_STATE_MAXIMIZED_VERT);
+ CREATE_(NET_WM_STATE_MAXIMIZED_HORZ);
+ CREATE_(NET_WM_STATE_SHADED);
+ CREATE_(NET_WM_STATE_SKIP_TASKBAR);
+ CREATE_(NET_WM_STATE_SKIP_PAGER);
+ CREATE_(NET_WM_STATE_HIDDEN);
+ CREATE_(NET_WM_STATE_FULLSCREEN);
+ CREATE_(NET_WM_STATE_ABOVE);
+ CREATE_(NET_WM_STATE_BELOW);
+ CREATE_(NET_WM_STATE_DEMANDS_ATTENTION);
+
+ prop_atoms[OBT_PROP_NET_WM_STATE_ADD] = 1;
+ prop_atoms[OBT_PROP_NET_WM_STATE_REMOVE] = 0;
+ prop_atoms[OBT_PROP_NET_WM_STATE_TOGGLE] = 2;
+
+ prop_atoms[OBT_PROP_NET_WM_ORIENTATION_HORZ] = 0;
+ prop_atoms[OBT_PROP_NET_WM_ORIENTATION_VERT] = 1;
+ prop_atoms[OBT_PROP_NET_WM_TOPLEFT] = 0;
+ prop_atoms[OBT_PROP_NET_WM_TOPRIGHT] = 1;
+ prop_atoms[OBT_PROP_NET_WM_BOTTOMRIGHT] = 2;
+ prop_atoms[OBT_PROP_NET_WM_BOTTOMLEFT] = 3;
+
+ CREATE_(KDE_WM_CHANGE_STATE);
+ CREATE_(KDE_NET_WM_WINDOW_TYPE_OVERRIDE);
+
+/*
+ CREATE_NAME(ROOTPMAPId, "_XROOTPMAP_ID");
+ CREATE_NAME(ESETROOTId, "ESETROOT_PMAP_ID");
+*/
+
+ CREATE_(OPENBOX_PID);
+ CREATE_(OB_THEME);
+ CREATE_(OB_CONFIG_FILE);
+ CREATE_(OB_WM_ACTION_UNDECORATE);
+ CREATE_(OB_WM_STATE_UNDECORATED);
+ CREATE_(OB_CONTROL);
++ CREATE_(OB_ROLE);
++ CREATE_(OB_NAME);
++ CREATE_(OB_CLASS);
+}
+
+Atom obt_prop_atom(ObtPropAtom a)
+{
+ g_assert(prop_started);
+ g_assert(a < OBT_PROP_NUM_ATOMS);
+ return prop_atoms[a];
+}
+
+static gboolean get_prealloc(Window win, Atom prop, Atom type, gint size,
+ guchar *data, gulong num)
+{
+ gboolean ret = FALSE;
+ gint res;
+ guchar *xdata = NULL;
+ Atom ret_type;
+ gint ret_size;
+ gulong ret_items, bytes_left;
+ glong num32 = 32 / size * num; /* num in 32-bit elements */
+
+ res = XGetWindowProperty(obt_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) {
+ guint i;
+ for (i = 0; i < num; ++i)
+ switch (size) {
+ case 8:
+ data[i] = xdata[i];
+ break;
+ case 16:
+ ((guint16*)data)[i] = ((gushort*)xdata)[i];
+ break;
+ case 32:
+ ((guint32*)data)[i] = ((gulong*)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, gint size,
+ guchar **data, guint *num)
+{
+ gboolean ret = FALSE;
+ gint res;
+ guchar *xdata = NULL;
+ Atom ret_type;
+ gint ret_size;
+ gulong ret_items, bytes_left;
+
+ res = XGetWindowProperty(obt_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) {
+ guint i;
+
+ *data = g_malloc(ret_items * (size / 8));
+ for (i = 0; i < ret_items; ++i)
+ switch (size) {
+ case 8:
+ (*data)[i] = xdata[i];
+ break;
+ case 16:
+ ((guint16*)*data)[i] = ((gushort*)xdata)[i];
+ break;
+ case 32:
+ ((guint32*)*data)[i] = ((gulong*)xdata)[i];
+ break;
+ default:
+ g_assert_not_reached(); /* unhandled size */
+ }
+ *num = ret_items;
+ ret = TRUE;
+ }
+ XFree(xdata);
+ }
+ return ret;
+}
+
+static gboolean get_stringlist(Window win, Atom prop, gchar ***list, gint *nstr)
+{
+ XTextProperty tprop;
+ gboolean ret = FALSE;
+
+ if (XGetTextProperty(obt_display, win, &tprop, prop) && tprop.nitems) {
+ if (XTextPropertyToStringList(&tprop, list, nstr))
+ ret = TRUE;
+ XFree(tprop.value);
+ }
+ return ret;
+}
+
+gboolean obt_prop_get32(Window win, Atom prop, Atom type, guint32 *ret)
+{
+ return get_prealloc(win, prop, type, 32, (guchar*)ret, 1);
+}
+
+gboolean obt_prop_get_array32(Window win, Atom prop, Atom type, guint32 **ret,
+ guint *nret)
+{
+ return get_all(win, prop, type, 32, (guchar**)ret, nret);
+}
+
+gboolean obt_prop_get_string_locale(Window win, Atom prop, gchar **ret)
+{
+ gchar **list;
+ gint nstr;
+ gchar *s;
+
+ if (get_stringlist(win, prop, &list, &nstr) && nstr) {
+ s = g_locale_to_utf8(list[0], -1, NULL, NULL, NULL);
+ XFreeStringList(list);
+ if (s) {
+ *ret = s;
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+gboolean obt_prop_get_strings_locale(Window win, Atom prop, gchar ***ret)
+{
+ GSList *strs = NULL, *it;
+ gchar *raw, *p;
+ guint num, i, count = 0;
+
+ if (get_all(win, prop, OBT_PROP_ATOM(STRING), 8,
+ (guchar**)&raw, &num))
+ {
+ p = raw;
+ while (p < raw + num) {
+ ++count;
+ strs = g_slist_append(strs, p);
+ p += strlen(p) + 1; /* next string */
+ }
+
+ *ret = g_new0(gchar*, count + 1);
+ (*ret)[count] = NULL; /* null terminated list */
+
+ for (i = 0, it = strs; it; ++i, it = g_slist_next(it)) {
+ (*ret)[i] = g_locale_to_utf8(it->data, -1, NULL, NULL, NULL);
+ /* make sure translation did not fail */
+ if (!(*ret)[i])
+ (*ret)[i] = g_strdup("");
+ }
+ g_free(raw);
+ g_slist_free(strs);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+gboolean obt_prop_get_string_utf8(Window win, Atom prop, gchar **ret)
+{
+ gchar *raw;
+ gchar *str;
+ guint num;
+
+ if (get_all(win, prop, OBT_PROP_ATOM(UTF8), 8,
+ (guchar**)&raw, &num))
+ {
+ str = g_strndup(raw, num); /* grab the first string from the list */
+ g_free(raw);
+ if (g_utf8_validate(str, -1, NULL)) {
+ *ret = str;
+ return TRUE;
+ }
+ g_free(str);
+ }
+ return FALSE;
+}
+
+gboolean obt_prop_get_strings_utf8(Window win, Atom prop, gchar ***ret)
+{
+ GSList *strs = NULL, *it;
+ gchar *raw, *p;
+ guint num, i, count = 0;
+
+ if (get_all(win, prop, OBT_PROP_ATOM(UTF8), 8,
+ (guchar**)&raw, &num))
+ {
+ p = raw;
+ while (p < raw + num) {
+ ++count;
+ strs = g_slist_append(strs, p);
+ p += strlen(p) + 1; /* next string */
+ }
+
+ *ret = g_new0(gchar*, count + 1);
+
+ for (i = 0, it = strs; it; ++i, it = g_slist_next(it)) {
+ if (g_utf8_validate(it->data, -1, NULL))
+ (*ret)[i] = g_strdup(it->data);
+ else
+ (*ret)[i] = g_strdup("");
+ }
+ g_free(raw);
+ g_slist_free(strs);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+void obt_prop_set32(Window win, Atom prop, Atom type, gulong val)
+{
+ XChangeProperty(obt_display, win, prop, type, 32, PropModeReplace,
+ (guchar*)&val, 1);
+}
+
+void obt_prop_set_array32(Window win, Atom prop, Atom type, gulong *val,
+ guint num)
+{
+ XChangeProperty(obt_display, win, prop, type, 32, PropModeReplace,
+ (guchar*)val, num);
+}
+
+void obt_prop_set_string_locale(Window win, Atom prop, const gchar *val)
+{
+ gchar const *s[2] = { val, NULL };
+ obt_prop_set_strings_locale(win, prop, s);
+}
+
+void obt_prop_set_strings_locale(Window win, Atom prop, const gchar **strs)
+{
+ gint i, count;
+ gchar **lstrs;
+ XTextProperty tprop;
+
+ /* count the strings in strs, and convert them to the locale format */
+ for (count = 0; strs[count]; ++count);
+ lstrs = g_new0(char*, count);
+ for (i = 0; i < count; ++i) {
+ lstrs[i] = g_locale_from_utf8(strs[i], -1, NULL, NULL, NULL);
+ if (!lstrs[i]) {
+ lstrs[i] = g_strdup(""); /* make it an empty string */
+ g_warning("Unable to translate string '%s' from UTF8 to locale "
+ "format", strs[i]);
+ }
+ }
+
+
+ XStringListToTextProperty(lstrs, count, &tprop);
+ XSetTextProperty(obt_display, win, &tprop, prop);
+ XFree(tprop.value);
+}
+
+void obt_prop_set_string_utf8(Window win, Atom prop, const gchar *val)
+{
+ XChangeProperty(obt_display, win, prop, OBT_PROP_ATOM(UTF8), 8,
+ PropModeReplace, (const guchar*)val, strlen(val));
+}
+
+void obt_prop_set_strings_utf8(Window win, Atom prop, const gchar **strs)
+{
+ GString *str;
+ gchar const **s;
+
+ str = g_string_sized_new(0);
+ for (s = strs; *s; ++s) {
+ str = g_string_append(str, *s);
+ str = g_string_append_c(str, '\0');
+ }
+ XChangeProperty(obt_display, win, prop, obt_prop_atom(OBT_PROP_UTF8), 8,
+ PropModeReplace, (guchar*)str->str, str->len);
+ g_string_free(str, TRUE);
+}
+
+void obt_prop_erase(Window win, Atom prop)
+{
+ XDeleteProperty(obt_display, win, prop);
+}
+
+void obt_prop_message(gint screen, Window about, Atom messagetype,
+ glong data0, glong data1, glong data2, glong data3,
+ glong data4, glong mask)
+{
+ obt_prop_message_to(obt_root(screen), about, messagetype,
+ data0, data1, data2, data3, data4, mask);
+}
+
+void obt_prop_message_to(Window to, Window about,
+ Atom messagetype,
+ glong data0, glong data1, glong data2, glong data3,
+ glong data4, glong mask)
+{
+ XEvent ce;
+ ce.xclient.type = ClientMessage;
+ ce.xclient.message_type = messagetype;
+ ce.xclient.display = obt_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;
+ ce.xclient.data.l[4] = data4;
+ XSendEvent(obt_display, to, FALSE, mask, &ce);
+}
--- /dev/null
+/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
+
+ obt/prop.h for the Openbox window manager
+ Copyright (c) 2006 Mikael Magnusson
+ Copyright (c) 2003-2007 Dana Jansens
+
+ 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.
+
+ See the COPYING file for a copy of the GNU General Public License.
+*/
+
+#ifndef __obt_prop_h
+#define __obt_prop_h
+
+#include <X11/Xlib.h>
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+typedef enum {
+ /* types */
+ OBT_PROP_CARDINAL, /*!< The atom which represents the Cardinal data type */
+ OBT_PROP_WINDOW, /*!< The atom which represents window ids */
+ OBT_PROP_PIXMAP, /*!< The atom which represents pixmap ids */
+ OBT_PROP_ATOM, /*!< The atom which represents atom values */
+ OBT_PROP_STRING, /*!< The atom which represents ascii strings */
+ OBT_PROP_UTF8, /*!< The atom which represents utf8-encoded strings */
+
+ /* selection stuff */
+ OBT_PROP_MANAGER,
+
+ /* window hints */
+ OBT_PROP_WM_COLORMAP_WINDOWS,
+ OBT_PROP_WM_PROTOCOLS,
+ OBT_PROP_WM_STATE,
+ OBT_PROP_WM_DELETE_WINDOW,
+ OBT_PROP_WM_TAKE_FOCUS,
+ OBT_PROP_WM_CHANGE_STATE,
+ OBT_PROP_WM_NAME,
+ OBT_PROP_WM_ICON_NAME,
+ OBT_PROP_WM_CLASS,
+ OBT_PROP_WM_WINDOW_ROLE,
+ OBT_PROP_WM_CLIENT_MACHINE,
+ OBT_PROP_WM_COMMAND,
+ OBT_PROP_WM_CLIENT_LEADER,
+ OBT_PROP_WM_TRANSIENT_FOR,
+ OBT_PROP_MOTIF_WM_HINTS,
+ OBT_PROP_MOTIF_WM_INFO,
+
+ /* SM atoms */
+ OBT_PROP_SM_CLIENT_ID,
+
+ /* NETWM atoms */
+
+ /* Atoms that are used inside messages - these don't go in net_supported */
+
+ OBT_PROP_NET_WM_MOVERESIZE_SIZE_TOPLEFT,
+ OBT_PROP_NET_WM_MOVERESIZE_SIZE_TOP,
+ OBT_PROP_NET_WM_MOVERESIZE_SIZE_TOPRIGHT,
+ OBT_PROP_NET_WM_MOVERESIZE_SIZE_RIGHT,
+ OBT_PROP_NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT,
+ OBT_PROP_NET_WM_MOVERESIZE_SIZE_BOTTOM,
+ OBT_PROP_NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT,
+ OBT_PROP_NET_WM_MOVERESIZE_SIZE_LEFT,
+ OBT_PROP_NET_WM_MOVERESIZE_MOVE,
+ OBT_PROP_NET_WM_MOVERESIZE_SIZE_KEYBOARD,
+ OBT_PROP_NET_WM_MOVERESIZE_MOVE_KEYBOARD,
+ OBT_PROP_NET_WM_MOVERESIZE_CANCEL,
+
+ OBT_PROP_NET_WM_STATE_ADD,
+ OBT_PROP_NET_WM_STATE_REMOVE,
+ OBT_PROP_NET_WM_STATE_TOGGLE,
+
+ OBT_PROP_NET_WM_ORIENTATION_HORZ,
+ OBT_PROP_NET_WM_ORIENTATION_VERT,
+ OBT_PROP_NET_WM_TOPLEFT,
+ OBT_PROP_NET_WM_TOPRIGHT,
+ OBT_PROP_NET_WM_BOTTOMRIGHT,
+ OBT_PROP_NET_WM_BOTTOMLEFT,
+
+ OBT_PROP_NET_WM_WINDOW_TYPE_POPUP_MENU,
+
+ OBT_PROP_PRIVATE_PADDING1,
+ OBT_PROP_PRIVATE_PADDING2,
+ OBT_PROP_PRIVATE_PADDING3,
+ OBT_PROP_PRIVATE_PADDING4,
+ OBT_PROP_PRIVATE_PADDING5,
+ OBT_PROP_PRIVATE_PADDING6,
+ OBT_PROP_PRIVATE_PADDING7,
+ OBT_PROP_PRIVATE_PADDING8,
+ OBT_PROP_PRIVATE_PADDING9,
+ OBT_PROP_PRIVATE_PADDING10,
+ OBT_PROP_PRIVATE_PADDING11,
+ OBT_PROP_PRIVATE_PADDING12,
+
+ /* Everything below here must go in net_supported on the root window */
+
+ /* root window properties */
+ OBT_PROP_NET_SUPPORTED,
+ OBT_PROP_NET_CLIENT_LIST,
+ OBT_PROP_NET_CLIENT_LIST_STACKING,
+ OBT_PROP_NET_NUMBER_OF_DESKTOPS,
+ OBT_PROP_NET_DESKTOP_GEOMETRY,
+ OBT_PROP_NET_DESKTOP_VIEWPORT,
+ OBT_PROP_NET_CURRENT_DESKTOP,
+ OBT_PROP_NET_DESKTOP_NAMES,
+ OBT_PROP_NET_ACTIVE_WINDOW,
+/* Atom net_restack_window;*/
+ OBT_PROP_NET_WORKAREA,
+ OBT_PROP_NET_SUPPORTING_WM_CHECK,
+ OBT_PROP_NET_DESKTOP_LAYOUT,
+ OBT_PROP_NET_SHOWING_DESKTOP,
+
+ /* root window messages */
+ OBT_PROP_NET_CLOSE_WINDOW,
+ OBT_PROP_NET_WM_MOVERESIZE,
+ OBT_PROP_NET_MOVERESIZE_WINDOW,
+ OBT_PROP_NET_REQUEST_FRAME_EXTENTS,
+ OBT_PROP_NET_RESTACK_WINDOW,
+
+ /* helpful hints to apps that aren't used for anything */
+ OBT_PROP_NET_WM_FULL_PLACEMENT,
+
+ /* startup-notification extension */
+ OBT_PROP_NET_STARTUP_ID,
+
+ /* application window properties */
+ OBT_PROP_NET_WM_NAME,
+ OBT_PROP_NET_WM_VISIBLE_NAME,
+ OBT_PROP_NET_WM_ICON_NAME,
+ OBT_PROP_NET_WM_VISIBLE_ICON_NAME,
+ OBT_PROP_NET_WM_DESKTOP,
+ OBT_PROP_NET_WM_WINDOW_TYPE,
+ OBT_PROP_NET_WM_STATE,
+ OBT_PROP_NET_WM_STRUT,
+ OBT_PROP_NET_WM_STRUT_PARTIAL,
+ OBT_PROP_NET_WM_ICON,
+ OBT_PROP_NET_WM_ICON_GEOMETRY,
+ OBT_PROP_NET_WM_PID,
+ OBT_PROP_NET_WM_ALLOWED_ACTIONS,
+ OBT_PROP_NET_WM_USER_TIME,
+/* OBT_PROP_NET_WM_USER_TIME_WINDOW, */
+ OBT_PROP_NET_FRAME_EXTENTS,
+
+ /* application protocols */
+ OBT_PROP_NET_WM_PING,
+#ifdef SYNC
+ OBT_PROP_NET_WM_SYNC_REQUEST,
+ OBT_PROP_NET_WM_SYNC_REQUEST_COUNTER,
+#endif
+
+ OBT_PROP_NET_WM_WINDOW_TYPE_DESKTOP,
+ OBT_PROP_NET_WM_WINDOW_TYPE_DOCK,
+ OBT_PROP_NET_WM_WINDOW_TYPE_TOOLBAR,
+ OBT_PROP_NET_WM_WINDOW_TYPE_MENU,
+ OBT_PROP_NET_WM_WINDOW_TYPE_UTILITY,
+ OBT_PROP_NET_WM_WINDOW_TYPE_SPLASH,
+ OBT_PROP_NET_WM_WINDOW_TYPE_DIALOG,
+ OBT_PROP_NET_WM_WINDOW_TYPE_NORMAL,
+
+ OBT_PROP_NET_WM_ACTION_MOVE,
+ OBT_PROP_NET_WM_ACTION_RESIZE,
+ OBT_PROP_NET_WM_ACTION_MINIMIZE,
+ OBT_PROP_NET_WM_ACTION_SHADE,
+/* OBT_PROP_NET_WM_ACTION_STICK,*/
+ OBT_PROP_NET_WM_ACTION_MAXIMIZE_HORZ,
+ OBT_PROP_NET_WM_ACTION_MAXIMIZE_VERT,
+ OBT_PROP_NET_WM_ACTION_FULLSCREEN,
+ OBT_PROP_NET_WM_ACTION_CHANGE_DESKTOP,
+ OBT_PROP_NET_WM_ACTION_CLOSE,
+ OBT_PROP_NET_WM_ACTION_ABOVE,
+ OBT_PROP_NET_WM_ACTION_BELOW,
+
+ OBT_PROP_NET_WM_STATE_MODAL,
+/* OBT_PROP_NET_WM_STATE_STICKY,*/
+ OBT_PROP_NET_WM_STATE_MAXIMIZED_VERT,
+ OBT_PROP_NET_WM_STATE_MAXIMIZED_HORZ,
+ OBT_PROP_NET_WM_STATE_SHADED,
+ OBT_PROP_NET_WM_STATE_SKIP_TASKBAR,
+ OBT_PROP_NET_WM_STATE_SKIP_PAGER,
+ OBT_PROP_NET_WM_STATE_HIDDEN,
+ OBT_PROP_NET_WM_STATE_FULLSCREEN,
+ OBT_PROP_NET_WM_STATE_ABOVE,
+ OBT_PROP_NET_WM_STATE_BELOW,
+ OBT_PROP_NET_WM_STATE_DEMANDS_ATTENTION,
+
+ /* KDE atoms */
+
+ OBT_PROP_KDE_WM_CHANGE_STATE,
+ OBT_PROP_KDE_NET_WM_FRAME_STRUT,
+ OBT_PROP_KDE_NET_WM_WINDOW_TYPE_OVERRIDE,
+
+/*
+ OBT_PROP_ROOTPMAPID,
+ OBT_PROP_ESETROOTID,
+*/
+
+ /* Openbox specific atoms */
+
+ OBT_PROP_OB_WM_ACTION_UNDECORATE,
+ OBT_PROP_OB_WM_STATE_UNDECORATED,
+ OBT_PROP_OPENBOX_PID, /* this is depreecated in favour of ob_control */
+ OBT_PROP_OB_THEME,
+ OBT_PROP_OB_CONFIG_FILE,
+ OBT_PROP_OB_CONTROL,
++ OBT_PROP_OB_ROLE,
++ OBT_PROP_OB_NAME,
++ OBT_PROP_OB_CLASS,
+
+ OBT_PROP_NUM_ATOMS
+} ObtPropAtom;
+
+Atom obt_prop_atom(ObtPropAtom a);
+
+gboolean obt_prop_get32(Window win, Atom prop, Atom type, guint32 *ret);
+gboolean obt_prop_get_array32(Window win, Atom prop, Atom type, guint32 **ret,
+ guint *nret);
+gboolean obt_prop_get_string_locale(Window win, Atom prop, gchar **ret);
+gboolean obt_prop_get_string_utf8(Window win, Atom prop, gchar **ret);
+gboolean obt_prop_get_strings_locale(Window win, Atom prop, gchar ***ret);
+gboolean obt_prop_get_strings_utf8(Window win, Atom prop, gchar ***ret);
+
+void obt_prop_set32(Window win, Atom prop, Atom type, gulong val);
+void obt_prop_set_array32(Window win, Atom prop, Atom type, gulong *val,
+ guint num);
+void obt_prop_set_string_locale(Window win, Atom prop, const gchar *val);
+void obt_prop_set_string_utf8(Window win, Atom prop, const gchar *val);
+void obt_prop_set_strings_locale(Window win, Atom prop, const gchar **strs);
+void obt_prop_set_strings_utf8(Window win, Atom prop, const gchar **strs);
+
+void obt_prop_erase(Window win, Atom prop);
+
+void obt_prop_message(gint screen, Window about, Atom messagetype,
+ glong data0, glong data1, glong data2, glong data3,
+ glong data4, glong mask);
+void obt_prop_message_to(Window to, Window about, Atom messagetype,
+ glong data0, glong data1, glong data2, glong data3,
+ glong data4, glong mask);
+
+#define OBT_PROP_ATOM(prop) obt_prop_atom(OBT_PROP_##prop)
+
+#define OBT_PROP_GET32(win, prop, type, ret) \
+ (obt_prop_get32(win, OBT_PROP_ATOM(prop), OBT_PROP_ATOM(type), ret))
+#define OBT_PROP_GETA32(win, prop, type, ret, nret) \
+ (obt_prop_get_array32(win, OBT_PROP_ATOM(prop), OBT_PROP_ATOM(type), \
+ ret, nret))
+#define OBT_PROP_GETS(win, prop, type, ret) \
+ (obt_prop_get_string_##type(win, OBT_PROP_ATOM(prop), ret))
+#define OBT_PROP_GETSS(win, prop, type, ret) \
+ (obt_prop_get_strings_##type(win, OBT_PROP_ATOM(prop), ret))
+
+#define OBT_PROP_SET32(win, prop, type, val) \
+ (obt_prop_set32(win, OBT_PROP_ATOM(prop), OBT_PROP_ATOM(type), val))
+#define OBT_PROP_SETA32(win, prop, type, val, num) \
+ (obt_prop_set_array32(win, OBT_PROP_ATOM(prop), OBT_PROP_ATOM(type), \
+ val, num))
+#define OBT_PROP_SETS(win, prop, type, val) \
+ (obt_prop_set_string_##type(win, OBT_PROP_ATOM(prop), val))
+#define OBT_PROP_SETSS(win, prop, type, strs) \
+ (obt_prop_set_strings_##type(win, OBT_PROP_ATOM(prop), strs))
+
+#define OBT_PROP_ERASE(win, prop) (obt_prop_erase(win, OBT_PROP_ATOM(prop)))
+
+#define OBT_PROP_MSG(screen, about, msgtype, data0, data1, data2, data3, \
+ data4) \
+ (obt_prop_message(screen, about, OBT_PROP_ATOM(msgtype), \
+ data0, data1, data2, data3, data4, \
+ SubstructureNotifyMask | SubstructureRedirectMask))
+
+#define OBT_PROP_MSG_TO(to, about, msgtype, data0, data1, data2, data3, \
+ data4, mask) \
+ (obt_prop_message_to(to, about, OBT_PROP_ATOM(msgtype), \
+ data0, data1, data2, data3, data4, mask))
+
+G_END_DECLS
+
+#endif /* __obt_prop_h */
}
}
- PROP_SETS(self->window, ob_role, self->role);
- PROP_SETS(self->window, ob_name, self->name);
- PROP_SETS(self->window, ob_class, self->class);
+ /*! Save the session IDs as seen by Openbox when the window mapped, so that
+ users can still access them later if the app changes them */
+ static void client_save_session_ids(ObClient *self)
+ {
++ OBT_PROP_SETS(self->window, OB_ROLE, utf8, self->role);
++ OBT_PROP_SETS(self->window, OB_NAME, utf8, self->name);
++ OBT_PROP_SETS(self->window, OB_CLASS, utf8, self->class);
+ }
+
static void client_change_wm_state(ObClient *self)
{
gulong state[2];
node = node->children;
- if ((n = parse_find_node("dragThreshold", node)))
- config_mouse_threshold = parse_int(doc, n);
- if ((n = parse_find_node("doubleClickTime", node)))
- config_mouse_dclicktime = parse_int(doc, n);
- if ((n = parse_find_node("screenEdgeWarpTime", node))) {
- config_mouse_screenedgetime = parse_int(doc, n);
+ if ((n = obt_parse_find_node(node, "dragThreshold")))
+ config_mouse_threshold = obt_parse_node_int(n);
+ if ((n = obt_parse_find_node(node, "doubleClickTime")))
+ config_mouse_dclicktime = obt_parse_node_int(n);
- if ((n = obt_parse_find_node(node, "screenEdgeWarpTime")))
++ if ((n = obt_parse_find_node(node, "screenEdgeWarpTime"))) {
+ config_mouse_screenedgetime = obt_parse_node_int(n);
+ /* minimum value of 25 for this property, when it is 1 and you hit the
+ edge it basically never stops */
+ if (config_mouse_screenedgetime && config_mouse_screenedgetime < 25)
+ config_mouse_screenedgetime = 25;
+ }
- n = parse_find_node("context", node);
+ n = obt_parse_find_node(node, "context");
while (n) {
- if (!parse_attr_string("name", n, &contextstr))
+ if (!obt_parse_attr_string(n, "name", &contextstr))
goto next_n;
- nbut = parse_find_node("mousebind", n->children);
+ nbut = obt_parse_find_node(n->children, "mousebind");
while (nbut) {
- if (!parse_attr_string("button", nbut, &buttonstr))
+ if (!obt_parse_attr_string(nbut, "button", &buttonstr))
goto next_nbut;
- if (parse_attr_contains("press", nbut, "action")) {
+ if (obt_parse_attr_contains(nbut, "action", "press")) {
mact = OB_MOUSE_ACTION_PRESS;
- } else if (parse_attr_contains("release", nbut, "action")) {
+ } else if (obt_parse_attr_contains(nbut, "action", "release")) {
mact = OB_MOUSE_ACTION_RELEASE;
- } else if (parse_attr_contains("click", nbut, "action")) {
+ } else if (obt_parse_attr_contains(nbut, "action", "click")) {
mact = OB_MOUSE_ACTION_CLICK;
- } else if (parse_attr_contains("doubleclick", nbut,"action")) {
+ } else if (obt_parse_attr_contains(nbut, "action","doubleclick")) {
mact = OB_MOUSE_ACTION_DOUBLE_CLICK;
- } else if (parse_attr_contains("drag", nbut, "action")) {
+ } else if (obt_parse_attr_contains(nbut, "action", "drag")) {
mact = OB_MOUSE_ACTION_MOTION;
} else
goto next_nbut;
node = node->children;
- if ((n = parse_find_node("policy", node)))
- if (parse_contains("UnderMouse", doc, n))
+ if ((n = obt_parse_find_node(node, "policy")))
+ if (obt_parse_node_contains(n, "UnderMouse"))
config_place_policy = OB_PLACE_POLICY_MOUSE;
- if ((n = parse_find_node("center", node)))
- config_place_center = parse_bool(doc, n);
- if ((n = parse_find_node("monitor", node))) {
- if (parse_contains("active", doc, n))
+ if ((n = obt_parse_find_node(node, "center")))
+ config_place_center = obt_parse_node_bool(n);
+ if ((n = obt_parse_find_node(node, "monitor"))) {
+ if (obt_parse_node_contains(n, "active"))
config_place_monitor = OB_PLACE_MONITOR_ACTIVE;
- else if (parse_contains("mouse", doc, n))
+ else if (obt_parse_node_contains(n, "mouse"))
config_place_monitor = OB_PLACE_MONITOR_MOUSE;
}
- if ((n = parse_find_node("primaryMonitor", node))) {
- config_primary_monitor_index = parse_int(doc, n);
++ if ((n = obt_parse_find_node(node, "primaryMonitor"))) {
++ config_primary_monitor_index = obt_parse_node_int(n);
+ if (!config_primary_monitor_index) {
- if (parse_contains("mouse", doc, n))
++ if (obt_parse_node_contains(n, "mouse"))
+ config_primary_monitor = OB_PLACE_MONITOR_MOUSE;
+ }
+ }
}
-static void parse_margins(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
- gpointer data)
+static void parse_margins(xmlNodePtr node, gpointer d)
{
xmlNodePtr n;
config_place_center = TRUE;
config_place_monitor = OB_PLACE_MONITOR_ANY;
- parse_register(i, "placement", parse_placement, NULL);
+ config_primary_monitor_index = 1;
+ config_primary_monitor = OB_PLACE_MONITOR_ACTIVE;
+
+ obt_parse_register(i, "placement", parse_placement, NULL);
STRUT_PARTIAL_SET(config_margins, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
} else
ob_debug_type(OB_DEBUG_APP_BUGS,
"_NET_ACTIVE_WINDOW message for window %s is "
- "missing source indication\n", client->title);
+ "missing source indication", client->title);
- client_activate(client, FALSE, TRUE, TRUE,
+ client_activate(client, FALSE, FALSE, TRUE, TRUE,
(e->xclient.data.l[0] == 0 ||
e->xclient.data.l[0] == 2));
- } else if (msgtype == prop_atoms.net_wm_moveresize) {
- ob_debug("net_wm_moveresize for 0x%lx direction %d\n",
+ } else if (msgtype == OBT_PROP_ATOM(NET_WM_MOVERESIZE)) {
+ ob_debug("net_wm_moveresize for 0x%lx direction %d",
client->window, e->xclient.data.l[2]);
if ((Atom)e->xclient.data.l[2] ==
- prop_atoms.net_wm_moveresize_size_topleft ||
+ OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOPLEFT) ||
(Atom)e->xclient.data.l[2] ==
- prop_atoms.net_wm_moveresize_size_top ||
+ OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOP) ||
(Atom)e->xclient.data.l[2] ==
- prop_atoms.net_wm_moveresize_size_topright ||
+ OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOPRIGHT) ||
(Atom)e->xclient.data.l[2] ==
- prop_atoms.net_wm_moveresize_size_right ||
+ OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_RIGHT) ||
(Atom)e->xclient.data.l[2] ==
- prop_atoms.net_wm_moveresize_size_right ||
+ OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_RIGHT) ||
(Atom)e->xclient.data.l[2] ==
- prop_atoms.net_wm_moveresize_size_bottomright ||
+ OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT) ||
(Atom)e->xclient.data.l[2] ==
- prop_atoms.net_wm_moveresize_size_bottom ||
+ OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOM) ||
(Atom)e->xclient.data.l[2] ==
- prop_atoms.net_wm_moveresize_size_bottomleft ||
+ OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT) ||
(Atom)e->xclient.data.l[2] ==
- prop_atoms.net_wm_moveresize_size_left ||
+ OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_LEFT) ||
(Atom)e->xclient.data.l[2] ==
- prop_atoms.net_wm_moveresize_move ||
+ OBT_PROP_ATOM(NET_WM_MOVERESIZE_MOVE) ||
(Atom)e->xclient.data.l[2] ==
- prop_atoms.net_wm_moveresize_size_keyboard ||
+ OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_KEYBOARD) ||
(Atom)e->xclient.data.l[2] ==
- prop_atoms.net_wm_moveresize_move_keyboard) {
-
+ OBT_PROP_ATOM(NET_WM_MOVERESIZE_MOVE_KEYBOARD))
+ {
moveresize_start(client, e->xclient.data.l[0],
e->xclient.data.l[1], e->xclient.data.l[3],
e->xclient.data.l[2]);
gint i;
GList *it;
const ObFocusCyclePopupTarget *newtarget;
- gint newtargetx, newtargety;
+ ObFocusCyclePopupMode mode = p->mode;
+ gint icons_per_row;
+ gint icon_rows;
+ gint textw, texth;
+ gint selected_pos;
+ gint last_scroll;
+
+ /* vars for icon mode */
+ gint icon_mode_textx;
+ gint icon_mode_texty;
+ gint icons_center_x;
+
+ /* vars for list mode */
+ gint list_mode_icon_column_w = HILITE_SIZE + OUTSIDE_BORDER;
+ gint up_arrow_x, down_arrow_x;
+ gint up_arrow_y, down_arrow_y;
+ gboolean showing_arrows = FALSE;
+
+ g_assert(mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS ||
+ mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST);
- screen_area = screen_physical_area_active();
+ screen_area = screen_physical_area_primary();
/* get the outside margins */
RrMargins(p->a_bg, &ml, &mt, &mr, &mb);
#include "frame.h"
#include "client.h"
#include "openbox.h"
-#include "extensions.h"
-#include "prop.h"
#include "grab.h"
+ #include "debug.h"
#include "config.h"
#include "framerender.h"
-#include "mainloop.h"
#include "focus_cycle.h"
#include "focus_cycle_indicator.h"
#include "moveresize.h"
*argc -= num;
}
-static void parse_env()
+static void parse_env(void)
{
+ const gchar *id;
+
/* unset this so we don't pass it on unknowingly */
unsetenv("DESKTOP_STARTUP_ID");
+
+ /* this is how gnome-session passes in a session client id */
+ id = g_getenv("DESKTOP_AUTOSTART_ID");
+ if (id) {
+ unsetenv("DESKTOP_AUTOSTART_ID");
+ if (ob_sm_id) g_free(ob_sm_id);
+ ob_sm_id = g_strdup(id);
+ ob_debug_type(OB_DEBUG_SM,
+ "DESKTOP_AUTOSTART_ID %s supercedes --sm-client-id\n",
+ ob_sm_id);
+ }
}
static void parse_args(gint *argc, gchar **argv)
/* set the _NET_SUPPORTED_ATOMS hint */
- /* this is all the atoms after net_supported in the prop_atoms struct */
- prop_atoms_start = (Atom*)&prop_atoms;
- wm_supported_pos = (Atom*)&(prop_atoms.net_supported);
- num_support = sizeof(prop_atoms) / sizeof(Atom) -
- (wm_supported_pos - prop_atoms_start) - 1;
+ /* this is all the atoms after NET_SUPPORTED in the ObtPropAtoms enum */
+ num_support = OBT_PROP_NUM_ATOMS - OBT_PROP_NET_SUPPORTED - 1;
i = 0;
supported = g_new(gulong, num_support);
- supported[i++] = prop_atoms.net_supporting_wm_check;
- supported[i++] = prop_atoms.net_wm_full_placement;
- supported[i++] = prop_atoms.net_current_desktop;
- supported[i++] = prop_atoms.net_number_of_desktops;
- supported[i++] = prop_atoms.net_desktop_geometry;
- supported[i++] = prop_atoms.net_desktop_viewport;
- supported[i++] = prop_atoms.net_active_window;
- supported[i++] = prop_atoms.net_workarea;
- supported[i++] = prop_atoms.net_client_list;
- supported[i++] = prop_atoms.net_client_list_stacking;
- supported[i++] = prop_atoms.net_desktop_names;
- supported[i++] = prop_atoms.net_close_window;
- supported[i++] = prop_atoms.net_desktop_layout;
- supported[i++] = prop_atoms.net_showing_desktop;
- supported[i++] = prop_atoms.net_wm_name;
- supported[i++] = prop_atoms.net_wm_visible_name;
- supported[i++] = prop_atoms.net_wm_icon_name;
- supported[i++] = prop_atoms.net_wm_visible_icon_name;
- supported[i++] = prop_atoms.net_wm_desktop;
- supported[i++] = prop_atoms.net_wm_strut;
- supported[i++] = prop_atoms.net_wm_strut_partial;
- supported[i++] = prop_atoms.net_wm_icon;
- supported[i++] = prop_atoms.net_wm_icon_geometry;
- supported[i++] = prop_atoms.net_wm_window_type;
- supported[i++] = prop_atoms.net_wm_window_type_desktop;
- supported[i++] = prop_atoms.net_wm_window_type_dock;
- supported[i++] = prop_atoms.net_wm_window_type_toolbar;
- supported[i++] = prop_atoms.net_wm_window_type_menu;
- supported[i++] = prop_atoms.net_wm_window_type_utility;
- supported[i++] = prop_atoms.net_wm_window_type_splash;
- supported[i++] = prop_atoms.net_wm_window_type_dialog;
- supported[i++] = prop_atoms.net_wm_window_type_normal;
- supported[i++] = prop_atoms.net_wm_allowed_actions;
- supported[i++] = prop_atoms.net_wm_action_move;
- supported[i++] = prop_atoms.net_wm_action_resize;
- supported[i++] = prop_atoms.net_wm_action_minimize;
- supported[i++] = prop_atoms.net_wm_action_shade;
- supported[i++] = prop_atoms.net_wm_action_maximize_horz;
- supported[i++] = prop_atoms.net_wm_action_maximize_vert;
- supported[i++] = prop_atoms.net_wm_action_fullscreen;
- supported[i++] = prop_atoms.net_wm_action_change_desktop;
- supported[i++] = prop_atoms.net_wm_action_close;
- supported[i++] = prop_atoms.net_wm_action_above;
- supported[i++] = prop_atoms.net_wm_action_below;
- supported[i++] = prop_atoms.net_wm_state;
- supported[i++] = prop_atoms.net_wm_state_modal;
- supported[i++] = prop_atoms.net_wm_state_maximized_vert;
- supported[i++] = prop_atoms.net_wm_state_maximized_horz;
- supported[i++] = prop_atoms.net_wm_state_shaded;
- supported[i++] = prop_atoms.net_wm_state_skip_taskbar;
- supported[i++] = prop_atoms.net_wm_state_skip_pager;
- supported[i++] = prop_atoms.net_wm_state_hidden;
- supported[i++] = prop_atoms.net_wm_state_fullscreen;
- supported[i++] = prop_atoms.net_wm_state_above;
- supported[i++] = prop_atoms.net_wm_state_below;
- supported[i++] = prop_atoms.net_wm_state_demands_attention;
- supported[i++] = prop_atoms.net_moveresize_window;
- supported[i++] = prop_atoms.net_wm_moveresize;
- supported[i++] = prop_atoms.net_wm_user_time;
+ supported[i++] = OBT_PROP_ATOM(NET_SUPPORTING_WM_CHECK);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_FULL_PLACEMENT);
+ supported[i++] = OBT_PROP_ATOM(NET_CURRENT_DESKTOP);
+ supported[i++] = OBT_PROP_ATOM(NET_NUMBER_OF_DESKTOPS);
+ supported[i++] = OBT_PROP_ATOM(NET_DESKTOP_GEOMETRY);
+ supported[i++] = OBT_PROP_ATOM(NET_DESKTOP_VIEWPORT);
+ supported[i++] = OBT_PROP_ATOM(NET_ACTIVE_WINDOW);
+ supported[i++] = OBT_PROP_ATOM(NET_WORKAREA);
+ supported[i++] = OBT_PROP_ATOM(NET_CLIENT_LIST);
+ supported[i++] = OBT_PROP_ATOM(NET_CLIENT_LIST_STACKING);
+ supported[i++] = OBT_PROP_ATOM(NET_DESKTOP_NAMES);
+ supported[i++] = OBT_PROP_ATOM(NET_CLOSE_WINDOW);
+ supported[i++] = OBT_PROP_ATOM(NET_DESKTOP_LAYOUT);
+ supported[i++] = OBT_PROP_ATOM(NET_SHOWING_DESKTOP);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_NAME);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_VISIBLE_NAME);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_ICON_NAME);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_VISIBLE_ICON_NAME);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_DESKTOP);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_STRUT);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_STRUT_PARTIAL);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_ICON);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_ICON_GEOMETRY);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_WINDOW_TYPE);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_DESKTOP);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_DOCK);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_TOOLBAR);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_MENU);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_UTILITY);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_SPLASH);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_DIALOG);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_NORMAL);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_ALLOWED_ACTIONS);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_ACTION_MOVE);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_ACTION_RESIZE);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_ACTION_MINIMIZE);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_ACTION_SHADE);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_ACTION_MAXIMIZE_HORZ);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_ACTION_MAXIMIZE_VERT);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_ACTION_FULLSCREEN);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_ACTION_CHANGE_DESKTOP);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_ACTION_CLOSE);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_ACTION_ABOVE);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_ACTION_BELOW);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_STATE);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_STATE_MODAL);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_STATE_MAXIMIZED_VERT);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_STATE_MAXIMIZED_HORZ);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_STATE_SHADED);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_STATE_SKIP_TASKBAR);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_STATE_SKIP_PAGER);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_STATE_HIDDEN);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_STATE_FULLSCREEN);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_STATE_ABOVE);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_STATE_BELOW);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_STATE_DEMANDS_ATTENTION);
+ supported[i++] = OBT_PROP_ATOM(NET_MOVERESIZE_WINDOW);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_MOVERESIZE);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_USER_TIME);
/*
- supported[i++] = prop_atoms.net_wm_user_time_window;
+ supported[i++] = OBT_PROP_ATOM(NET_WM_USER_TIME_WINDOW);
*/
- supported[i++] = prop_atoms.net_frame_extents;
- supported[i++] = prop_atoms.net_request_frame_extents;
- supported[i++] = prop_atoms.net_restack_window;
- supported[i++] = prop_atoms.net_startup_id;
+ supported[i++] = OBT_PROP_ATOM(NET_FRAME_EXTENTS);
+ supported[i++] = OBT_PROP_ATOM(NET_REQUEST_FRAME_EXTENTS);
+ supported[i++] = OBT_PROP_ATOM(NET_RESTACK_WINDOW);
+ supported[i++] = OBT_PROP_ATOM(NET_STARTUP_ID);
#ifdef SYNC
- supported[i++] = prop_atoms.net_wm_sync_request;
- supported[i++] = prop_atoms.net_wm_sync_request_counter;
+ supported[i++] = OBT_PROP_ATOM(NET_WM_SYNC_REQUEST);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_SYNC_REQUEST_COUNTER);
#endif
- supported[i++] = prop_atoms.net_wm_pid;
- supported[i++] = prop_atoms.net_wm_ping;
-
- supported[i++] = prop_atoms.kde_wm_change_state;
- supported[i++] = prop_atoms.kde_net_wm_frame_strut;
- supported[i++] = prop_atoms.kde_net_wm_window_type_override;
-
- supported[i++] = prop_atoms.ob_wm_action_undecorate;
- supported[i++] = prop_atoms.ob_wm_state_undecorated;
- supported[i++] = prop_atoms.openbox_pid;
- supported[i++] = prop_atoms.ob_theme;
- supported[i++] = prop_atoms.ob_config_file;
- supported[i++] = prop_atoms.ob_control;
- supported[i++] = prop_atoms.ob_role;
- supported[i++] = prop_atoms.ob_name;
- supported[i++] = prop_atoms.ob_class;
+ supported[i++] = OBT_PROP_ATOM(NET_WM_PID);
+ supported[i++] = OBT_PROP_ATOM(NET_WM_PING);
+
+ supported[i++] = OBT_PROP_ATOM(KDE_WM_CHANGE_STATE);
+ supported[i++] = OBT_PROP_ATOM(KDE_NET_WM_FRAME_STRUT);
+ supported[i++] = OBT_PROP_ATOM(KDE_NET_WM_WINDOW_TYPE_OVERRIDE);
+
+ supported[i++] = OBT_PROP_ATOM(OB_WM_ACTION_UNDECORATE);
+ supported[i++] = OBT_PROP_ATOM(OB_WM_STATE_UNDECORATED);
+ supported[i++] = OBT_PROP_ATOM(OPENBOX_PID);
+ supported[i++] = OBT_PROP_ATOM(OB_THEME);
+ supported[i++] = OBT_PROP_ATOM(OB_CONFIG_FILE);
+ supported[i++] = OBT_PROP_ATOM(OB_CONTROL);
++ supported[i++] = OBT_PROP_ATOM(OB_ROLE);
++ supported[i++] = OBT_PROP_ATOM(OB_NAME);
++ supported[i++] = OBT_PROP_ATOM(OB_CLASS);
g_assert(i == num_support);
- PROP_SETA32(RootWindow(ob_display, ob_screen),
- net_supported, atom, supported, num_support);
+ OBT_PROP_SETA32(obt_root(ob_screen),
+ NET_SUPPORTED, ATOM, supported, num_support);
g_free(supported);
screen_tell_ksplash();
/* 0 means don't show the popup */
if (!config_desktop_popup_time) return;
- for (i = 0; i < screen_num_monitors; i++) {
- a = screen_physical_area_monitor(i);
- pager_popup_position(desktop_popup[i], CenterGravity,
- a->x + a->width / 2, a->y + a->height / 2);
- pager_popup_icon_size_multiplier(desktop_popup[i],
- (screen_desktop_layout.columns /
- screen_desktop_layout.rows) / 2,
- (screen_desktop_layout.rows/
- screen_desktop_layout.columns) / 2);
- pager_popup_max_width(desktop_popup[i],
- MAX(a->width/3, POPUP_WIDTH));
- pager_popup_show(desktop_popup[i], screen_desktop_names[d], d);
-
- obt_main_loop_timeout_remove(ob_main_loop, hide_desktop_popup_func);
- obt_main_loop_timeout_add(ob_main_loop, config_desktop_popup_time * 1000,
- hide_desktop_popup_func, desktop_popup[i],
- g_direct_equal, NULL);
- g_free(a);
- }
+ a = screen_physical_area_primary();
+ pager_popup_position(desktop_popup, CenterGravity,
+ a->x + a->width / 2, a->y + a->height / 2);
+ pager_popup_icon_size_multiplier(desktop_popup,
+ (screen_desktop_layout.columns /
+ screen_desktop_layout.rows) / 2,
+ (screen_desktop_layout.rows/
+ screen_desktop_layout.columns) / 2);
+ pager_popup_max_width(desktop_popup,
+ MAX(a->width/3, POPUP_WIDTH));
+ pager_popup_show(desktop_popup, screen_desktop_names[d], d);
+
- ob_main_loop_timeout_remove(ob_main_loop, hide_desktop_popup_func);
- ob_main_loop_timeout_add(ob_main_loop, config_desktop_popup_time * 1000,
- hide_desktop_popup_func, NULL, NULL, NULL);
++ obt_main_loop_timeout_remove(ob_main_loop, hide_desktop_popup_func);
++ obt_main_loop_timeout_add(ob_main_loop, config_desktop_popup_time * 1000,
++ hide_desktop_popup_func, desktop_popup,
++ g_direct_equal, NULL);
+ g_free(a);
}
void screen_hide_desktop_popup(void)
{
- guint i;
-
- for (i = 0; i < screen_num_monitors; i++) {
- obt_main_loop_timeout_remove_data(ob_main_loop, hide_desktop_popup_func,
- desktop_popup[i], FALSE);
- pager_popup_hide(desktop_popup[i]);
- }
- ob_main_loop_timeout_remove(ob_main_loop, hide_desktop_popup_func);
++ obt_main_loop_timeout_remove_data(ob_main_loop, hide_desktop_popup_func,
++ desktop_popup, FALSE);
+ pager_popup_hide(desktop_popup);
}
guint screen_find_desktop(guint from, ObDirection dir,
} \
}
+static void get_xinerama_screens(Rect **xin_areas, guint *nxin)
+{
+ guint i;
+ gint n, l, r, t, b;
+#ifdef XINERAMA
+ XineramaScreenInfo *info;
+#endif
+
+ if (ob_debug_xinerama) {
+ gint w = WidthOfScreen(ScreenOfDisplay(obt_display, ob_screen));
+ gint h = HeightOfScreen(ScreenOfDisplay(obt_display, ob_screen));
+ *nxin = 2;
+ *xin_areas = g_new(Rect, *nxin + 1);
+ RECT_SET((*xin_areas)[0], 0, 0, w/2, h);
+ RECT_SET((*xin_areas)[1], w/2, 0, w-(w/2), h);
+ }
+#ifdef XINERAMA
+ else if (obt_display_extension_xinerama &&
+ (info = XineramaQueryScreens(obt_display, &n))) {
+ *nxin = n;
+ *xin_areas = g_new(Rect, *nxin + 1);
+ for (i = 0; i < *nxin; ++i)
+ RECT_SET((*xin_areas)[i], info[i].x_org, info[i].y_org,
+ info[i].width, info[i].height);
+ XFree(info);
+ }
+#endif
+ else {
+ *nxin = 1;
+ *xin_areas = g_new(Rect, *nxin + 1);
+ RECT_SET((*xin_areas)[0], 0, 0,
+ WidthOfScreen(ScreenOfDisplay(obt_display, ob_screen)),
+ HeightOfScreen(ScreenOfDisplay(obt_display, ob_screen)));
+ }
+
+ /* returns one extra with the total area in it */
+ l = (*xin_areas)[0].x;
+ t = (*xin_areas)[0].y;
+ r = (*xin_areas)[0].x + (*xin_areas)[0].width - 1;
+ b = (*xin_areas)[0].y + (*xin_areas)[0].height - 1;
+ for (i = 1; i < *nxin; ++i) {
+ l = MIN(l, (*xin_areas)[i].x);
+ t = MIN(l, (*xin_areas)[i].y);
+ r = MAX(r, (*xin_areas)[i].x + (*xin_areas)[i].width - 1);
+ b = MAX(b, (*xin_areas)[i].y + (*xin_areas)[i].height - 1);
+ }
+ RECT_SET((*xin_areas)[*nxin], l, t, r - l + 1, b - t + 1);
+}
+
void screen_update_areas(void)
{
- guint i, j, onum;
+ guint i, j;
gulong *dims;
GList *it;
GSList *sit;
- onum = screen_num_monitors;
-
g_free(monitor_area);
- extensions_xinerama_screens(&monitor_area, &screen_num_monitors);
+ get_xinerama_screens(&monitor_area, &screen_num_monitors);
- if (screen_num_monitors < onum) {
- /* free some of the pager popups */
- for (i = screen_num_monitors; i < onum; ++i)
- pager_popup_free(desktop_popup[i]);
- desktop_popup = g_renew(ObPagerPopup*, desktop_popup,
- screen_num_monitors);
- }
- else {
- /* add some more pager popups */
- desktop_popup = g_renew(ObPagerPopup*, desktop_popup,
- screen_num_monitors);
- for (i = onum; i < screen_num_monitors; ++i) {
- desktop_popup[i] = pager_popup_new();
- pager_popup_height(desktop_popup[i], POPUP_HEIGHT);
- if (screen_desktop_names) /* the areas are initialized before the
- desktop names */
- pager_popup_text_width_to_strings(desktop_popup[i],
- screen_desktop_names,
- screen_num_desktops);
- }
- }
-
/* set up the user-specified margins */
config_margins.top_start = RECT_LEFT(monitor_area[screen_num_monitors]);
config_margins.top_end = RECT_RIGHT(monitor_area[screen_num_monitors]);