redo otk::Property. make it static.

This commit is contained in:
Dana Jansens 2003-01-16 08:44:52 +00:00
parent 8b0daa912e
commit d8aff44a6a
12 changed files with 4087 additions and 1406 deletions

View file

@ -8,6 +8,8 @@
#include "display.hh" #include "display.hh"
extern "C" { extern "C" {
#include <X11/Xatom.h>
#include <assert.h> #include <assert.h>
} }
@ -15,168 +17,124 @@ extern "C" {
namespace otk { namespace otk {
Property::Property() Atoms Property::atoms;
static Atom create(char *name) { return XInternAtom(**display, name, false); }
void Property::initialize()
{ {
assert(**display); assert(display);
// make sure asserts fire if there is a problem // make sure asserts fire if there is a problem
memset(_atoms, 0, sizeof(_atoms)); memset(&atoms, 0, sizeof(Atoms));
_atoms[Atom_Cardinal] = XA_CARDINAL; atoms.cardinal = XA_CARDINAL;
_atoms[Atom_Window] = XA_WINDOW; atoms.window = XA_WINDOW;
_atoms[Atom_Pixmap] = XA_PIXMAP; atoms.pixmap = XA_PIXMAP;
_atoms[Atom_Atom] = XA_ATOM; atoms.atom = XA_ATOM;
_atoms[Atom_String] = XA_STRING; atoms.string = XA_STRING;
_atoms[Atom_Utf8] = create("UTF8_STRING"); atoms.utf8 = create("UTF8_STRING");
_atoms[openbox_pid] = create("_OPENBOX_PID"); atoms.openbox_pid = create("_OPENBOX_PID");
_atoms[wm_colormap_windows] = create("WM_COLORMAP_WINDOWS"); atoms.wm_colormap_windows = create("WM_COLORMAP_WINDOWS");
_atoms[wm_protocols] = create("WM_PROTOCOLS"); atoms.wm_protocols = create("WM_PROTOCOLS");
_atoms[wm_state] = create("WM_STATE"); atoms.wm_state = create("WM_STATE");
_atoms[wm_change_state] = create("WM_CHANGE_STATE"); atoms.wm_change_state = create("WM_CHANGE_STATE");
_atoms[wm_delete_window] = create("WM_DELETE_WINDOW"); atoms.wm_delete_window = create("WM_DELETE_WINDOW");
_atoms[wm_take_focus] = create("WM_TAKE_FOCUS"); atoms.wm_take_focus = create("WM_TAKE_FOCUS");
_atoms[wm_name] = create("WM_NAME"); atoms.wm_name = create("WM_NAME");
_atoms[wm_icon_name] = create("WM_ICON_NAME"); atoms.wm_icon_name = create("WM_ICON_NAME");
_atoms[wm_class] = create("WM_CLASS"); atoms.wm_class = create("WM_CLASS");
_atoms[wm_window_role] = create("WM_WINDOW_ROLE"); atoms.wm_window_role = create("WM_WINDOW_ROLE");
_atoms[motif_wm_hints] = create("_MOTIF_WM_HINTS"); atoms.motif_wm_hints = create("_MOTIF_WM_HINTS");
_atoms[blackbox_hints] = create("_BLACKBOX_HINTS");
_atoms[blackbox_attributes] = create("_BLACKBOX_ATTRIBUTES"); atoms.openbox_show_root_menu = create("_OPENBOX_SHOW_ROOT_MENU");
_atoms[blackbox_change_attributes] = create("_BLACKBOX_CHANGE_ATTRIBUTES"); atoms.openbox_show_workspace_menu = create("_OPENBOX_SHOW_WORKSPACE_MENU");
_atoms[blackbox_structure_messages] = create("_BLACKBOX_STRUCTURE_MESSAGES");
_atoms[blackbox_notify_startup] = create("_BLACKBOX_NOTIFY_STARTUP"); atoms.net_supported = create("_NET_SUPPORTED");
_atoms[blackbox_notify_window_add] = create("_BLACKBOX_NOTIFY_WINDOW_ADD"); atoms.net_client_list = create("_NET_CLIENT_LIST");
_atoms[blackbox_notify_window_del] = create("_BLACKBOX_NOTIFY_WINDOW_DEL"); atoms.net_client_list_stacking = create("_NET_CLIENT_LIST_STACKING");
_atoms[blackbox_notify_current_workspace] = atoms.net_number_of_desktops = create("_NET_NUMBER_OF_DESKTOPS");
create("_BLACKBOX_NOTIFY_CURRENT_WORKSPACE"); atoms.net_desktop_geometry = create("_NET_DESKTOP_GEOMETRY");
_atoms[blackbox_notify_workspace_count] = atoms.net_desktop_viewport = create("_NET_DESKTOP_VIEWPORT");
create("_BLACKBOX_NOTIFY_WORKSPACE_COUNT"); atoms.net_current_desktop = create("_NET_CURRENT_DESKTOP");
_atoms[blackbox_notify_window_focus] = atoms.net_desktop_names = create("_NET_DESKTOP_NAMES");
create("_BLACKBOX_NOTIFY_WINDOW_FOCUS"); atoms.net_active_window = create("_NET_ACTIVE_WINDOW");
_atoms[blackbox_notify_window_raise] = atoms.net_workarea = create("_NET_WORKAREA");
create("_BLACKBOX_NOTIFY_WINDOW_RAISE"); atoms.net_supporting_wm_check = create("_NET_SUPPORTING_WM_CHECK");
_atoms[blackbox_notify_window_lower] = // atoms.net_virtual_roots = create("_NET_VIRTUAL_ROOTS");
create("_BLACKBOX_NOTIFY_WINDOW_LOWER");
atoms.net_close_window = create("_NET_CLOSE_WINDOW");
atoms.net_wm_moveresize = create("_NET_WM_MOVERESIZE");
// atoms.net_properties = create("_NET_PROPERTIES");
atoms.net_wm_name = create("_NET_WM_NAME");
atoms.net_wm_visible_name = create("_NET_WM_VISIBLE_NAME");
atoms.net_wm_icon_name = create("_NET_WM_ICON_NAME");
atoms.net_wm_visible_icon_name = create("_NET_WM_VISIBLE_ICON_NAME");
atoms.net_wm_desktop = create("_NET_WM_DESKTOP");
atoms.net_wm_window_type = create("_NET_WM_WINDOW_TYPE");
atoms.net_wm_state = create("_NET_WM_STATE");
atoms.net_wm_strut = create("_NET_WM_STRUT");
// atoms.net_wm_icon_geometry = create("_NET_WM_ICON_GEOMETRY");
// atoms.net_wm_icon = create("_NET_WM_ICON");
// atoms.net_wm_pid = create("_NET_WM_PID");
// atoms.net_wm_handled_icons = create("_NET_WM_HANDLED_ICONS");
atoms.net_wm_allowed_actions = create("_NET_WM_ALLOWED_ACTIONS");
// atoms.net_wm_ping = create("_NET_WM_PING");
_atoms[blackbox_change_workspace] = create("_BLACKBOX_CHANGE_WORKSPACE"); atoms.net_wm_window_type_desktop = create("_NET_WM_WINDOW_TYPE_DESKTOP");
_atoms[blackbox_change_window_focus] = atoms.net_wm_window_type_dock = create("_NET_WM_WINDOW_TYPE_DOCK");
create("_BLACKBOX_CHANGE_WINDOW_FOCUS"); atoms.net_wm_window_type_toolbar = create("_NET_WM_WINDOW_TYPE_TOOLBAR");
_atoms[blackbox_cycle_window_focus] = create("_BLACKBOX_CYCLE_WINDOW_FOCUS"); atoms.net_wm_window_type_menu = create("_NET_WM_WINDOW_TYPE_MENU");
atoms.net_wm_window_type_utility = create("_NET_WM_WINDOW_TYPE_UTILITY");
atoms.net_wm_window_type_splash = create("_NET_WM_WINDOW_TYPE_SPLASH");
atoms.net_wm_window_type_dialog = create("_NET_WM_WINDOW_TYPE_DIALOG");
atoms.net_wm_window_type_normal = create("_NET_WM_WINDOW_TYPE_NORMAL");
_atoms[openbox_show_root_menu] = create("_OPENBOX_SHOW_ROOT_MENU"); atoms.net_wm_moveresize_size_topleft =
_atoms[openbox_show_workspace_menu] = create("_OPENBOX_SHOW_WORKSPACE_MENU");
_atoms[net_supported] = create("_NET_SUPPORTED");
_atoms[net_client_list] = create("_NET_CLIENT_LIST");
_atoms[net_client_list_stacking] = create("_NET_CLIENT_LIST_STACKING");
_atoms[net_number_of_desktops] = create("_NET_NUMBER_OF_DESKTOPS");
_atoms[net_desktop_geometry] = create("_NET_DESKTOP_GEOMETRY");
_atoms[net_desktop_viewport] = create("_NET_DESKTOP_VIEWPORT");
_atoms[net_current_desktop] = create("_NET_CURRENT_DESKTOP");
_atoms[net_desktop_names] = create("_NET_DESKTOP_NAMES");
_atoms[net_active_window] = create("_NET_ACTIVE_WINDOW");
_atoms[net_workarea] = create("_NET_WORKAREA");
_atoms[net_supporting_wm_check] = create("_NET_SUPPORTING_WM_CHECK");
// _atoms[net_virtual_roots] = create("_NET_VIRTUAL_ROOTS");
_atoms[net_close_window] = create("_NET_CLOSE_WINDOW");
_atoms[net_wm_moveresize] = create("_NET_WM_MOVERESIZE");
// _atoms[net_properties] = create("_NET_PROPERTIES");
_atoms[net_wm_name] = create("_NET_WM_NAME");
_atoms[net_wm_visible_name] = create("_NET_WM_VISIBLE_NAME");
_atoms[net_wm_icon_name] = create("_NET_WM_ICON_NAME");
_atoms[net_wm_visible_icon_name] = create("_NET_WM_VISIBLE_ICON_NAME");
_atoms[net_wm_desktop] = create("_NET_WM_DESKTOP");
_atoms[net_wm_window_type] = create("_NET_WM_WINDOW_TYPE");
_atoms[net_wm_state] = create("_NET_WM_STATE");
_atoms[net_wm_strut] = create("_NET_WM_STRUT");
// _atoms[net_wm_icon_geometry] = create("_NET_WM_ICON_GEOMETRY");
// _atoms[net_wm_icon] = create("_NET_WM_ICON");
// _atoms[net_wm_pid] = create("_NET_WM_PID");
// _atoms[net_wm_handled_icons] = create("_NET_WM_HANDLED_ICONS");
_atoms[net_wm_allowed_actions] = create("_NET_WM_ALLOWED_ACTIONS");
// _atoms[net_wm_ping] = create("_NET_WM_PING");
_atoms[net_wm_window_type_desktop] = create("_NET_WM_WINDOW_TYPE_DESKTOP");
_atoms[net_wm_window_type_dock] = create("_NET_WM_WINDOW_TYPE_DOCK");
_atoms[net_wm_window_type_toolbar] = create("_NET_WM_WINDOW_TYPE_TOOLBAR");
_atoms[net_wm_window_type_menu] = create("_NET_WM_WINDOW_TYPE_MENU");
_atoms[net_wm_window_type_utility] = create("_NET_WM_WINDOW_TYPE_UTILITY");
_atoms[net_wm_window_type_splash] = create("_NET_WM_WINDOW_TYPE_SPLASH");
_atoms[net_wm_window_type_dialog] = create("_NET_WM_WINDOW_TYPE_DIALOG");
_atoms[net_wm_window_type_normal] = create("_NET_WM_WINDOW_TYPE_NORMAL");
_atoms[net_wm_moveresize_size_topleft] =
create("_NET_WM_MOVERESIZE_SIZE_TOPLEFT"); create("_NET_WM_MOVERESIZE_SIZE_TOPLEFT");
_atoms[net_wm_moveresize_size_topright] = atoms.net_wm_moveresize_size_topright =
create("_NET_WM_MOVERESIZE_SIZE_TOPRIGHT"); create("_NET_WM_MOVERESIZE_SIZE_TOPRIGHT");
_atoms[net_wm_moveresize_size_bottomleft] = atoms.net_wm_moveresize_size_bottomleft =
create("_NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT"); create("_NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT");
_atoms[net_wm_moveresize_size_bottomright] = atoms.net_wm_moveresize_size_bottomright =
create("_NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT"); create("_NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT");
_atoms[net_wm_moveresize_move] = atoms.net_wm_moveresize_move =
create("_NET_WM_MOVERESIZE_MOVE"); create("_NET_WM_MOVERESIZE_MOVE");
_atoms[net_wm_action_move] = create("_NET_WM_ACTION_MOVE"); atoms.net_wm_action_move = create("_NET_WM_ACTION_MOVE");
_atoms[net_wm_action_resize] = create("_NET_WM_ACTION_RESIZE"); atoms.net_wm_action_resize = create("_NET_WM_ACTION_RESIZE");
_atoms[net_wm_action_shade] = create("_NET_WM_ACTION_SHADE"); atoms.net_wm_action_shade = create("_NET_WM_ACTION_SHADE");
_atoms[net_wm_action_maximize_horz] = create("_NET_WM_ACTION_MAXIMIZE_HORZ"); atoms.net_wm_action_maximize_horz = create("_NET_WM_ACTION_MAXIMIZE_HORZ");
_atoms[net_wm_action_maximize_vert] = create("_NET_WM_ACTION_MAXIMIZE_VERT"); atoms.net_wm_action_maximize_vert = create("_NET_WM_ACTION_MAXIMIZE_VERT");
_atoms[net_wm_action_change_desktop] = atoms.net_wm_action_change_desktop =
create("_NET_WM_ACTION_CHANGE_DESKTOP"); create("_NET_WM_ACTION_CHANGE_DESKTOP");
_atoms[net_wm_action_close] = create("_NET_WM_ACTION_CLOSE"); atoms.net_wm_action_close = create("_NET_WM_ACTION_CLOSE");
_atoms[net_wm_state_modal] = create("_NET_WM_STATE_MODAL"); atoms.net_wm_state_modal = create("_NET_WM_STATE_MODAL");
_atoms[net_wm_state_sticky] = create("_NET_WM_STATE_STICKY"); atoms.net_wm_state_sticky = create("_NET_WM_STATE_STICKY");
_atoms[net_wm_state_maximized_vert] = create("_NET_WM_STATE_MAXIMIZED_VERT"); atoms.net_wm_state_maximized_vert = create("_NET_WM_STATE_MAXIMIZED_VERT");
_atoms[net_wm_state_maximized_horz] = create("_NET_WM_STATE_MAXIMIZED_HORZ"); atoms.net_wm_state_maximized_horz = create("_NET_WM_STATE_MAXIMIZED_HORZ");
_atoms[net_wm_state_shaded] = create("_NET_WM_STATE_SHADED"); atoms.net_wm_state_shaded = create("_NET_WM_STATE_SHADED");
_atoms[net_wm_state_skip_taskbar] = create("_NET_WM_STATE_SKIP_TASKBAR"); atoms.net_wm_state_skip_taskbar = create("_NET_WM_STATE_SKIP_TASKBAR");
_atoms[net_wm_state_skip_pager] = create("_NET_WM_STATE_SKIP_PAGER"); atoms.net_wm_state_skip_pager = create("_NET_WM_STATE_SKIP_PAGER");
_atoms[net_wm_state_hidden] = create("_NET_WM_STATE_HIDDEN"); atoms.net_wm_state_hidden = create("_NET_WM_STATE_HIDDEN");
_atoms[net_wm_state_fullscreen] = create("_NET_WM_STATE_FULLSCREEN"); atoms.net_wm_state_fullscreen = create("_NET_WM_STATE_FULLSCREEN");
_atoms[net_wm_state_above] = create("_NET_WM_STATE_ABOVE"); atoms.net_wm_state_above = create("_NET_WM_STATE_ABOVE");
_atoms[net_wm_state_below] = create("_NET_WM_STATE_BELOW"); atoms.net_wm_state_below = create("_NET_WM_STATE_BELOW");
_atoms[kde_net_system_tray_windows] = create("_KDE_NET_SYSTEM_TRAY_WINDOWS"); atoms.kde_net_system_tray_windows = create("_KDE_NET_SYSTEM_TRAY_WINDOWS");
_atoms[kde_net_wm_system_tray_window_for] = atoms.kde_net_wm_system_tray_window_for =
create("_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR"); create("_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR");
_atoms[kde_net_wm_window_type_override] = atoms.kde_net_wm_window_type_override =
create("_KDE_NET_WM_WINDOW_TYPE_OVERRIDE"); create("_KDE_NET_WM_WINDOW_TYPE_OVERRIDE");
} }
void Property::set(Window win, Atom atom, Atom type, unsigned char* data,
/* int size, int nelements, bool append)
* clean up the class' members
*/
Property::~Property()
{
}
/*
* Returns an atom from the Xserver, creating it if necessary.
*/
Atom Property::create(const char *name) const
{
Atom a = XInternAtom(**display, name, False);
assert(a);
return a;
}
/*
* Internal set.
* Sets a window property on a window, optionally appending to the existing
* value.
*/
void Property::set(Window win, Atom atom, Atom type,
unsigned char* data, int size, int nelements,
bool append) const
{ {
assert(win != None); assert(atom != None); assert(type != None); assert(win != None); assert(atom != None); assert(type != None);
assert(nelements == 0 || (nelements > 0 && data != (unsigned char *) 0)); assert(nelements == 0 || (nelements > 0 && data != (unsigned char *) 0));
@ -186,74 +144,44 @@ void Property::set(Window win, Atom atom, Atom type,
data, nelements); data, nelements);
} }
void Property::set(Window win, Atom atom, Atom type, unsigned long value)
/*
* Set a 32-bit property value on a window.
*/
void Property::set(Window win, Atoms atom, Atoms type,
unsigned long value) const
{ {
assert(atom >= 0 && atom < NUM_ATOMS); set(win, atom, type, (unsigned char*) &value, 32, 1, false);
assert(type >= 0 && type < NUM_ATOMS);
set(win, _atoms[atom], _atoms[type],
reinterpret_cast<unsigned char*>(&value), 32, 1, False);
} }
void Property::set(Window win, Atom atom, Atom type, unsigned long value[],
/* int elements)
* Set an array of 32-bit properties value on a window.
*/
void Property::set(Window win, Atoms atom, Atoms type,
unsigned long value[], int elements) const
{ {
assert(atom >= 0 && atom < NUM_ATOMS); set(win, atom, type, (unsigned char*) value, 32, elements, false);
assert(type >= 0 && type < NUM_ATOMS);
set(win, _atoms[atom], _atoms[type],
reinterpret_cast<unsigned char*>(value), 32, elements, False);
} }
void Property::set(Window win, Atom atom, StringType type,
/* const ustring &value)
* Set an string property value on a window.
*/
void Property::set(Window win, Atoms atom, StringType type,
const ustring &value) const
{ {
assert(atom >= 0 && atom < NUM_ATOMS);
assert(type >= 0 && type < NUM_STRING_TYPE);
Atom t; Atom t;
switch (type) { switch (type) {
case ascii: t = _atoms[Atom_String]; assert(!value.utf8()); break; case ascii: t = atoms.string; assert(!value.utf8()); break;
case utf8: t = _atoms[Atom_Utf8]; assert(value.utf8()); break; case utf8: t = atoms.utf8; assert(value.utf8()); break;
default: assert(False); return; // unhandled StringType default: assert(false); return; // unhandled StringType
} }
set(win, _atoms[atom], t, // add 1 to the size to include the trailing null
reinterpret_cast<unsigned char *>(const_cast<char *>(value.c_str())), set(win, atom, t, (unsigned char*) value.c_str(), 8, value.bytes() + 1,
8, value.size() + 1, False); // add 1 to the size to include the null false);
} }
void Property::set(Window win, Atom atom, StringType type,
/* const StringVect &strings)
* Set an array of string property values on a window.
*/
void Property::set(Window win, Atoms atom, StringType type,
const StringVect &strings) const
{ {
assert(atom >= 0 && atom < NUM_ATOMS);
assert(type >= 0 && type < NUM_STRING_TYPE);
Atom t; Atom t;
bool u; // utf8 encoded? bool u; // utf8 encoded?
switch (type) { switch (type) {
case ascii: t = _atoms[Atom_String]; u = false; break; case ascii: t = atoms.string; u = false; break;
case utf8: t = _atoms[Atom_Utf8]; u = true; break; case utf8: t = atoms.utf8; u = true; break;
default: assert(False); return; // unhandled StringType default: assert(false); return; // unhandled StringType
} }
ustring value; ustring value(u);
value.setUtf8(u);
StringVect::const_iterator it = strings.begin(); StringVect::const_iterator it = strings.begin();
const StringVect::const_iterator end = strings.end(); const StringVect::const_iterator end = strings.end();
@ -263,22 +191,13 @@ void Property::set(Window win, Atoms atom, StringType type,
value += '\0'; value += '\0';
} }
set(win, _atoms[atom], t, // add 1 to the size to include the trailing null
reinterpret_cast<unsigned char *>(const_cast<char *>(value.c_str())), set(win, atom, t, (unsigned char*)value.c_str(), 8,
8, value.size(), False); value.bytes() + 1, false);
} }
bool Property::get(Window win, Atom atom, Atom type, unsigned long *nelements,
/* unsigned char **value, int size)
* Internal get function used by all of the typed get functions.
* Gets an property's value from a window.
* Returns True if the property was successfully retrieved; False if the
* property did not exist on the window, or has a different type/size format
* than the user tried to retrieve.
*/
bool Property::get(Window win, Atom atom, Atom type,
unsigned long *nelements, unsigned char **value,
int size) const
{ {
assert(win != None); assert(atom != None); assert(type != None); assert(win != None); assert(atom != None); assert(type != None);
assert(size == 8 || size == 16 || size == 32); assert(size == 8 || size == 16 || size == 32);
@ -289,11 +208,11 @@ bool Property::get(Window win, Atom atom, Atom type,
unsigned long ret_bytes; unsigned long ret_bytes;
int result; int result;
unsigned long maxread = *nelements; unsigned long maxread = *nelements;
bool ret = False; bool ret = false;
// try get the first element // try get the first element
result = XGetWindowProperty(**display, win, atom, 0l, 1l, result = XGetWindowProperty(**display, win, atom, 0l, 1l,
False, AnyPropertyType, &ret_type, &ret_size, false, AnyPropertyType, &ret_type, &ret_size,
nelements, &ret_bytes, &c_val); nelements, &ret_bytes, &c_val);
ret = (result == Success && ret_type == type && ret_size == size && ret = (result == Success && ret_type == type && ret_size == size &&
*nelements > 0); *nelements > 0);
@ -311,7 +230,7 @@ bool Property::get(Window win, Atom atom, Atom type,
if (remain > size/8 * (signed)maxread) // dont get more than the max if (remain > size/8 * (signed)maxread) // dont get more than the max
remain = size/8 * (signed)maxread; remain = size/8 * (signed)maxread;
result = XGetWindowProperty(**display, win, atom, 0l, result = XGetWindowProperty(**display, win, atom, 0l,
remain, False, type, &ret_type, &ret_size, remain, false, type, &ret_type, &ret_size,
nelements, &ret_bytes, &c_val); nelements, &ret_bytes, &c_val);
ret = (result == Success && ret_type == type && ret_size == size && ret = (result == Success && ret_type == type && ret_size == size &&
ret_bytes == 0); ret_bytes == 0);
@ -331,79 +250,54 @@ bool Property::get(Window win, Atom atom, Atom type,
return ret; return ret;
} }
bool Property::get(Window win, Atom atom, Atom type, unsigned long *nelements,
/* unsigned long **value)
* Gets a 32-bit property's value from a window.
*/
bool Property::get(Window win, Atoms atom, Atoms type,
unsigned long *nelements,
unsigned long **value) const
{ {
assert(atom >= 0 && atom < NUM_ATOMS); return get(win, atom, type, nelements, (unsigned char**) value, 32);
assert(type >= 0 && type < NUM_ATOMS);
return get(win, _atoms[atom], _atoms[type], nelements,
reinterpret_cast<unsigned char **>(value), 32);
} }
bool Property::get(Window win, Atom atom, Atom type, unsigned long *value)
/*
* Gets a single 32-bit property's value from a window.
*/
bool Property::get(Window win, Atoms atom, Atoms type,
unsigned long *value) const
{ {
assert(atom >= 0 && atom < NUM_ATOMS);
assert(type >= 0 && type < NUM_ATOMS);
unsigned long *temp; unsigned long *temp;
unsigned long num = 1; unsigned long num = 1;
if (! get(win, _atoms[atom], _atoms[type], &num, if (! get(win, atom, type, &num, (unsigned char **) &temp, 32))
reinterpret_cast<unsigned char **>(&temp), 32)) return false;
return False;
*value = temp[0]; *value = temp[0];
delete [] temp; delete [] temp;
return True; return true;
} }
bool Property::get(Window win, Atom atom, StringType type, ustring *value)
/*
* Gets an string property's value from a window.
*/
bool Property::get(Window win, Atoms atom, StringType type,
ustring *value) const
{ {
unsigned long n = 1; unsigned long n = 1;
StringVect s; StringVect s;
if (get(win, atom, type, &n, &s)) { if (get(win, atom, type, &n, &s)) {
*value = s[0]; *value = s[0];
return True; return true;
} }
return False; return false;
} }
bool Property::get(Window win, Atom atom, StringType type,
bool Property::get(Window win, Atoms atom, StringType type, unsigned long *nelements, StringVect *strings)
unsigned long *nelements, StringVect *strings) const
{ {
assert(atom >= 0 && atom < NUM_ATOMS);
assert(type >= 0 && type < NUM_STRING_TYPE);
assert(win != None); assert(_atoms[atom] != None);
assert(*nelements > 0); assert(*nelements > 0);
Atom t; Atom t;
bool u; // utf8 encoded? bool u; // utf8 encoded?
switch (type) { switch (type) {
case ascii: t = _atoms[Atom_String]; u = false; break; case ascii: t = atoms.string; u = false; break;
case utf8: t = _atoms[Atom_Utf8]; u = true; break; case utf8: t = atoms.utf8; u = true; break;
default: assert(False); return False; // unhandled StringType default: assert(false); return false; // unhandled StringType
} }
unsigned char *value; unsigned char *value;
unsigned long elements = (unsigned) -1; unsigned long elements = (unsigned) -1;
if (!get(win, _atoms[atom], t, &elements, &value, 8) || elements < 1) if (!get(win, atom, t, &elements, &value, 8) || elements < 1)
return False; return false;
std::string s(reinterpret_cast<char *>(value), elements); std::string s((char*)value, elements);
delete [] value; delete [] value;
std::string::const_iterator it = s.begin(), end = s.end(); std::string::const_iterator it = s.begin(), end = s.end();
@ -412,7 +306,7 @@ bool Property::get(Window win, Atoms atom, StringType type,
std::string::const_iterator tmp = it; // current string.begin() std::string::const_iterator tmp = it; // current string.begin()
it = std::find(tmp, end, '\0'); // look for null between tmp and end it = std::find(tmp, end, '\0'); // look for null between tmp and end
strings->push_back(std::string(tmp, it)); // s[tmp:it) strings->push_back(std::string(tmp, it)); // s[tmp:it)
if (!u) strings->back().setUtf8(false); strings->back().setUtf8(u);
++num; ++num;
if (it == end) break; if (it == end) break;
++it; ++it;
@ -421,17 +315,16 @@ bool Property::get(Window win, Atoms atom, StringType type,
*nelements = num; *nelements = num;
return True; return true;
} }
/* /*
* Removes a property entirely from a window. * Removes a property entirely from a window.
*/ */
void Property::erase(Window win, Atoms atom) const void Property::erase(Window win, Atom atom)
{ {
assert(atom >= 0 && atom < NUM_ATOMS); XDeleteProperty(**display, win, atom);
XDeleteProperty(**display, win, _atoms[atom]);
} }
} }

View file

@ -11,7 +11,6 @@
extern "C" { extern "C" {
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <assert.h> #include <assert.h>
} }
@ -20,135 +19,114 @@ extern "C" {
namespace otk { namespace otk {
//! The atoms on the X server which this class will cache
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
Atom openbox_pid;
// 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;
Atom openbox_show_root_menu;
Atom openbox_show_workspace_menu;
// 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;
// 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_shade;
Atom net_wm_action_maximize_horz;
Atom net_wm_action_maximize_vert;
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 kde_net_system_tray_windows;
Atom kde_net_wm_system_tray_window_for;
Atom kde_net_wm_window_type_override;
};
//! Provides easy access to window properties. //! Provides easy access to window properties.
class Property { class Property {
public: public:
//! The atoms on the X server which this class will cache
enum 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
openbox_pid,
// window hints
wm_colormap_windows,
wm_protocols,
wm_state,
wm_delete_window,
wm_take_focus,
wm_change_state,
wm_name,
wm_icon_name,
wm_class,
wm_window_role,
motif_wm_hints,
blackbox_attributes,
blackbox_change_attributes,
blackbox_hints,
// blackbox-protocol atoms (wm -> client)
blackbox_structure_messages,
blackbox_notify_startup,
blackbox_notify_window_add,
blackbox_notify_window_del,
blackbox_notify_window_focus,
blackbox_notify_current_workspace,
blackbox_notify_workspace_count,
blackbox_notify_window_raise,
blackbox_notify_window_lower,
// blackbox-protocol atoms (client -> wm)
blackbox_change_workspace,
blackbox_change_window_focus,
blackbox_cycle_window_focus,
openbox_show_root_menu,
openbox_show_workspace_menu,
// NETWM atoms
// root window properties
net_supported,
net_client_list,
net_client_list_stacking,
net_number_of_desktops,
net_desktop_geometry,
net_desktop_viewport,
net_current_desktop,
net_desktop_names,
net_active_window,
net_workarea,
net_supporting_wm_check,
// net_virtual_roots,
// root window messages
net_close_window,
net_wm_moveresize,
// application window properties
// net_properties,
net_wm_name,
net_wm_visible_name,
net_wm_icon_name,
net_wm_visible_icon_name,
net_wm_desktop,
net_wm_window_type,
net_wm_state,
net_wm_strut,
// net_wm_icon_geometry,
// net_wm_icon,
// net_wm_pid,
// net_wm_handled_icons,
net_wm_allowed_actions,
// application protocols
// net_wm_ping,
net_wm_window_type_desktop,
net_wm_window_type_dock,
net_wm_window_type_toolbar,
net_wm_window_type_menu,
net_wm_window_type_utility,
net_wm_window_type_splash,
net_wm_window_type_dialog,
net_wm_window_type_normal,
net_wm_moveresize_size_topleft,
net_wm_moveresize_size_topright,
net_wm_moveresize_size_bottomleft,
net_wm_moveresize_size_bottomright,
net_wm_moveresize_move,
net_wm_action_move,
net_wm_action_resize,
net_wm_action_shade,
net_wm_action_maximize_horz,
net_wm_action_maximize_vert,
net_wm_action_change_desktop,
net_wm_action_close,
net_wm_state_modal,
net_wm_state_sticky,
net_wm_state_maximized_vert,
net_wm_state_maximized_horz,
net_wm_state_shaded,
net_wm_state_skip_taskbar,
net_wm_state_skip_pager,
net_wm_state_hidden,
net_wm_state_fullscreen,
net_wm_state_above,
net_wm_state_below,
kde_net_system_tray_windows,
kde_net_wm_system_tray_window_for,
kde_net_wm_window_type_override,
#ifndef DOXYGEN_IGNORE
// constant for how many atoms exist in the enumerator
NUM_ATOMS
#endif
};
//! The possible types/encodings of strings //! The possible types/encodings of strings
enum StringType { enum StringType {
ascii, //!< Standard 8-bit ascii string ascii, //!< Standard 8-bit ascii string
@ -158,88 +136,83 @@ public:
#endif #endif
}; };
private: //! A list of ustrings
//! The value of all atoms on the X server that exist in the
//! Property::Atoms enum
Atom _atoms[NUM_ATOMS];
//! Gets the value of an Atom from the X server, creating it if nessesary
Atom create(const char *name) const;
//! Sets a property on a window
void set(Window win, Atom atom, Atom type, unsigned char *data,
int size, int nelements, bool append) const;
//! Gets a property's value from a window
bool get(Window win, Atom atom, Atom type,
unsigned long *nelements, unsigned char **value,
int size) const;
public:
//! A list of strings
typedef std::vector<ustring> StringVect; typedef std::vector<ustring> StringVect;
//! Constructs a new Atom object //! The value of all atoms on the X server that exist in the
//! Atoms struct
static Atoms atoms;
private:
//! Sets a property on a window
static void set(Window win, Atom atom, Atom type, unsigned char *data,
int size, int nelements, bool append);
//! Gets a property's value from a window
static bool get(Window win, Atom atom, Atom type,
unsigned long *nelements, unsigned char **value,
int size);
public:
//! Initializes the Property class.
/*! /*!
CAUTION: This constructor uses Display::display, so ensure that it is CAUTION: This function uses otk::Display, so ensure that
initialized before initializing this class! otk::Display::initialize has been called before initializing this class!
*/ */
Property(); static void initialize();
//! Destroys the Atom object
virtual ~Property();
//! Sets a single-value property on a window to a new value //! Sets a single-value property on a window to a new value
/*! /*!
@param win The window id of the window on which to set the property's value @param win The window id of the window on which to set the property's value
@param atom A member of the Property::Atoms enum that specifies which @param atom The Atom value of the property to set. This can be found in the
property to set struct returned by Property::atoms.
@param type A member of the Property::Atoms enum that specifies the type @param type The Atom value of the property type. This can be found in the
of the property to set struct returned by Property::atoms.
@param value The value to set the property to @param value The value to set the property to
*/ */
void set(Window win, Atoms atom, Atoms type, unsigned long value) const; static void set(Window win, Atom atom, Atom type, unsigned long value);
//! Sets an multiple-value property on a window to a new value //! Sets an multiple-value property on a window to a new value
/*! /*!
@param win The window id of the window on which to set the property's value @param win The window id of the window on which to set the property's value
@param atom A member of the Property::Atoms enum that specifies which @param atom The Atom value of the property to set. This can be found in the
property to set struct returned by Property::atoms.
@param type A member of the Property::Atoms enum that specifies the type @param type The Atom value of the property type. This can be found in the
of the property to set struct returned by Property::atoms.
@param value Any array of values to set the property to. The array must @param value Any array of values to set the property to. The array must
contain <i>elements</i> number of elements contain <i>elements</i> number of elements
@param elements The number of elements in the <i>value</i> array @param elements The number of elements in the <i>value</i> array
*/ */
void set(Window win, Atoms atom, Atoms type, static void set(Window win, Atom atom, Atom type,
unsigned long value[], int elements) const; unsigned long value[], int elements);
//! Sets a string property on a window to a new value //! Sets a string property on a window to a new value
/*! /*!
@param win The window id of the window on which to set the property's value @param win The window id of the window on which to set the property's value
@param atom A member of the Property::Atoms enum that specifies which @param atom The Atom value of the property to set. This can be found in the
property to set struct returned by Property::atoms.
@param type A member of the Property::StringType enum that specifies the @param type A member of the Property::StringType enum that specifies the
type of the string the property is being set to type of the string the property is being set to
@param value The string to set the property to @param value The string to set the property to
*/ */
void set(Window win, Atoms atom, StringType type, static void set(Window win, Atom atom, StringType type,
const ustring &value) const; const ustring &value);
//! Sets a string-array property on a window to a new value //! Sets a string-array property on a window to a new value
/*! /*!
@param win The window id of the window on which to set the property's value @param win The window id of the window on which to set the property's value
@param atom A member of the Property::Atoms enum that specifies which @param atom The Atom value of the property to set. This can be found in the
property to set struct returned by Property::atoms.
@param type A member of the Property::StringType enum that specifies the @param type A member of the Property::StringType enum that specifies the
type of the string the property is being set to type of the string the property is being set to
@param strings A list of strings to set the property to @param strings A list of strings to set the property to
*/ */
void set(Window win, Atoms atom, StringType type, static void set(Window win, Atom atom, StringType type,
const StringVect &strings) const; const StringVect &strings);
//! Gets the value of a property on a window //! Gets the value of a property on a window
/*! /*!
@param win The window id of the window to get the property value from @param win The window id of the window to get the property value from
@param atom A member of the Property::Atoms enum that specifies which @param atom The Atom value of the property to set. This can be found in the
property to retrieve struct returned by Property::atoms.
@param type A member of the Property::Atoms enum that specifies the type @param type The Atom value of the property type. This can be found in the
of the property to retrieve struct returned by Property::atoms.
@param nelements The maximum number of elements to retrieve from the @param nelements The maximum number of elements to retrieve from the
property (assuming it has more than 1 value in it). To property (assuming it has more than 1 value in it). To
retrieve all possible elements, use "(unsigned) -1".<br> retrieve all possible elements, use "(unsigned) -1".<br>
@ -255,27 +228,27 @@ public:
@return true if retrieval of the specified property with the specified @return true if retrieval of the specified property with the specified
type was successful; otherwise, false type was successful; otherwise, false
*/ */
bool get(Window win, Atoms atom, Atoms type, static bool get(Window win, Atom atom, Atom type,
unsigned long *nelements, unsigned long **value) const; unsigned long *nelements, unsigned long **value);
//! Gets a single element from the value of a property on a window //! Gets a single element from the value of a property on a window
/*! /*!
@param win The window id of the window to get the property value from @param win The window id of the window to get the property value from
@param atom A member of the Property::Atoms enum that specifies which @param atom The Atom value of the property to set. This can be found in the
property to retrieve struct returned by Property::atoms.
@param type A member of the Property::Atoms enum that specifies the type @param type The Atom value of the property type. This can be found in the
of the property to retrieve struct returned by Property::atoms.
@param value If the function returns true, then this contains the first @param value If the function returns true, then this contains the first
(and possibly only) element in the value of the specified (and possibly only) element in the value of the specified
property. property.
@return true if retrieval of the specified property with the specified @return true if retrieval of the specified property with the specified
type was successful; otherwise, false type was successful; otherwise, false
*/ */
bool get(Window win, Atoms atom, Atoms type, unsigned long *value) const; static bool get(Window win, Atom atom, Atom type, unsigned long *value);
//! Gets a single string from the value of a property on a window //! Gets a single string from the value of a property on a window
/*! /*!
@param win The window id of the window to get the property value from @param win The window id of the window to get the property value from
@param atom A member of the Property::Atoms enum that specifies which @param atom The Atom value of the property to set. This can be found in the
property to retrieve struct returned by Property::atoms.
@param type A member of the Property::StringType enum that specifies the @param type A member of the Property::StringType enum that specifies the
type of the string property to retrieve type of the string property to retrieve
@param value If the function returns true, then this contains the first @param value If the function returns true, then this contains the first
@ -284,12 +257,12 @@ public:
@return true if retrieval of the specified property with the specified @return true if retrieval of the specified property with the specified
type was successful; otherwise, false type was successful; otherwise, false
*/ */
bool get(Window win, Atoms atom, StringType type, ustring *value) const; static bool get(Window win, Atom atom, StringType type, ustring *value);
//! Gets strings from the value of a property on a window //! Gets strings from the value of a property on a window
/*! /*!
@param win The window id of the window to get the property value from @param win The window id of the window to get the property value from
@param atom A member of the Property::Atoms enum that specifies which @param atom The Atom value of the property to set. This can be found in the
property to retrieve struct returned by Property::atoms.
@param type A member of the Property::StringType enum that specifies the @param type A member of the Property::StringType enum that specifies the
type of the string property to retrieve type of the string property to retrieve
@param nelements The maximum number of strings to retrieve from the @param nelements The maximum number of strings to retrieve from the
@ -302,27 +275,16 @@ public:
@return true if retrieval of the specified property with the specified @return true if retrieval of the specified property with the specified
type was successful; otherwise, false type was successful; otherwise, false
*/ */
bool get(Window win, Atoms atom, StringType type, static bool get(Window win, Atom atom, StringType type,
unsigned long *nelements, StringVect *strings) const; unsigned long *nelements, StringVect *strings);
//! Removes a property from a window //! Removes a property from a window
/*! /*!
@param win The window id of the window to remove the property from @param win The window id of the window to remove the property from
@param atom A member of the Property::Atoms enum that specifies which @param atom The Atom value of the property to set. This can be found in the
property to remove from the window struct returned by Property::atoms.
*/ */
void erase(Window win, Atoms atom) const; static void erase(Window win, Atom atom);
//! Gets the value of an atom on the X server
/*!
@param a A member of the Property::Atoms enum that specifies which Atom's
value to return
@return The value of the specified Atom
*/
inline Atom atom(Atoms a) const {
assert(a >= 0 && a < NUM_ATOMS); Atom ret = _atoms[a]; assert(ret != 0);
return ret;
}
}; };
} }

View file

@ -6,28 +6,28 @@ def state_above(data, add=2):
"""Toggles, adds or removes the 'above' state on a window.""" """Toggles, adds or removes the 'above' state on a window."""
if not data.client: return if not data.client: return
send_client_msg(display.screenInfo(data.screen).rootWindow(), send_client_msg(display.screenInfo(data.screen).rootWindow(),
Property.net_wm_state, data.client.window(), add, Property_atoms().net_wm_state, data.client.window(), add,
openbox.property().atom(Property.net_wm_state_above)) Property_atoms().net_wm_state_above)
def state_below(data, add=2): def state_below(data, add=2):
"""Toggles, adds or removes the 'below' state on a window.""" """Toggles, adds or removes the 'below' state on a window."""
if not data.client: return if not data.client: return
send_client_msg(display.screenInfo(data.screen).rootWindow(), send_client_msg(display.screenInfo(data.screen).rootWindow(),
Property.net_wm_state, data.client.window(), add, Property_atoms().net_wm_state, data.client.window(), add,
openbox.property().atom(Property.net_wm_state_below)) Property_atoms().net_wm_state_below)
def state_shaded(data, add=2): def state_shaded(data, add=2):
"""Toggles, adds or removes the 'shaded' state on a window.""" """Toggles, adds or removes the 'shaded' state on a window."""
if not data.client: return if not data.client: return
send_client_msg(display.screenInfo(data.screen).rootWindow(), send_client_msg(display.screenInfo(data.screen).rootWindow(),
Property.net_wm_state, data.client.window(), add, Property_atoms().net_wm_state, data.client.window(), add,
openbox.property().atom(Property.net_wm_state_shaded)) Property_atoms().net_wm_state_shaded)
def close(data): def close(data):
"""Closes the window on which the event occured""" """Closes the window on which the event occured"""
if not data.client: return if not data.client: return
send_client_msg(display.screenInfo(data.screen).rootWindow(), send_client_msg(display.screenInfo(data.screen).rootWindow(),
Property.net_close_window, data.client.window(), 0) Property_atoms().net_close_window, data.client.window(), 0)
def focus(data): def focus(data):
"""Focuses the window on which the event occured""" """Focuses the window on which the event occured"""
@ -115,7 +115,7 @@ def unshade(data):
def change_desktop(data, num): def change_desktop(data, num):
"""Switches to a specified desktop""" """Switches to a specified desktop"""
root = display.screenInfo(data.screen).rootWindow() root = display.screenInfo(data.screen).rootWindow()
send_client_msg(root, Property.net_current_desktop, root, num) send_client_msg(root, Property_atoms().net_current_desktop, root, num)
def next_desktop(data, no_wrap=0): def next_desktop(data, no_wrap=0):
"""Switches to the next desktop, optionally (by default) cycling around to """Switches to the next desktop, optionally (by default) cycling around to
@ -145,13 +145,14 @@ def send_to_all_desktops(data):
"""Sends a client to all desktops""" """Sends a client to all desktops"""
if not data.client: return if not data.client: return
send_client_msg(display.screenInfo(data.screen).rootWindow(), send_client_msg(display.screenInfo(data.screen).rootWindow(),
Property.net_wm_desktop, data.client.window(), 0xffffffff) Property_atoms().net_wm_desktop, data.client.window(),
0xffffffff)
def send_to_desktop(data, num): def send_to_desktop(data, num):
"""Sends a client to a specified desktop""" """Sends a client to a specified desktop"""
if not data.client: return if not data.client: return
send_client_msg(display.screenInfo(data.screen).rootWindow(), send_client_msg(display.screenInfo(data.screen).rootWindow(),
Property.net_wm_desktop, data.client.window(), num) Property_atoms().net_wm_desktop, data.client.window(), num)
def send_to_next_desktop(data, no_wrap=0, follow=1): def send_to_next_desktop(data, no_wrap=0, follow=1):
"""Sends a window to the next desktop, optionally (by default) cycling """Sends a window to the next desktop, optionally (by default) cycling

View file

@ -14,6 +14,7 @@
extern "C" { extern "C" {
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <assert.h> #include <assert.h>
@ -72,8 +73,6 @@ Client::Client(int screen, Window window)
Client::~Client() Client::~Client()
{ {
const otk::Property *property = openbox->property();
// clean up childrens' references // clean up childrens' references
while (!_transients.empty()) { while (!_transients.empty()) {
_transients.front()->_transient_for = 0; _transients.front()->_transient_for = 0;
@ -86,72 +85,56 @@ Client::~Client()
if (openbox->state() != Openbox::State_Exiting) { if (openbox->state() != Openbox::State_Exiting) {
// these values should not be persisted across a window unmapping/mapping // these values should not be persisted across a window unmapping/mapping
property->erase(_window, otk::Property::net_wm_desktop); otk::Property::erase(_window, otk::Property::atoms.net_wm_desktop);
property->erase(_window, otk::Property::net_wm_state); otk::Property::erase(_window, otk::Property::atoms.net_wm_state);
} }
} }
void Client::getDesktop() void Client::getDesktop()
{ {
const otk::Property *property = openbox->property();
// defaults to the current desktop // defaults to the current desktop
_desktop = openbox->screen(_screen)->desktop(); _desktop = openbox->screen(_screen)->desktop();
if (!property->get(_window, otk::Property::net_wm_desktop, if (!otk::Property::get(_window, otk::Property::atoms.net_wm_desktop,
otk::Property::Atom_Cardinal, otk::Property::atoms.cardinal,
(long unsigned*)&_desktop)) { (long unsigned*)&_desktop)) {
// make sure the hint exists // make sure the hint exists
openbox->property()->set(_window, otk::Property::set(_window, otk::Property::atoms.net_wm_desktop,
otk::Property::net_wm_desktop, otk::Property::atoms.cardinal, (unsigned)_desktop);
otk::Property::Atom_Cardinal,
(unsigned)_desktop);
} }
} }
void Client::getType() void Client::getType()
{ {
const otk::Property *property = openbox->property();
_type = (WindowType) -1; _type = (WindowType) -1;
unsigned long *val; unsigned long *val;
unsigned long num = (unsigned) -1; unsigned long num = (unsigned) -1;
if (property->get(_window, otk::Property::net_wm_window_type, if (otk::Property::get(_window, otk::Property::atoms.net_wm_window_type,
otk::Property::Atom_Atom, otk::Property::atoms.atom, &num, &val)) {
&num, &val)) {
// use the first value that we know about in the array // use the first value that we know about in the array
for (unsigned long i = 0; i < num; ++i) { for (unsigned long i = 0; i < num; ++i) {
if (val[i] == if (val[i] == otk::Property::atoms.net_wm_window_type_desktop)
property->atom(otk::Property::net_wm_window_type_desktop))
_type = Type_Desktop; _type = Type_Desktop;
else if (val[i] == else if (val[i] == otk::Property::atoms.net_wm_window_type_dock)
property->atom(otk::Property::net_wm_window_type_dock))
_type = Type_Dock; _type = Type_Dock;
else if (val[i] == else if (val[i] == otk::Property::atoms.net_wm_window_type_toolbar)
property->atom(otk::Property::net_wm_window_type_toolbar))
_type = Type_Toolbar; _type = Type_Toolbar;
else if (val[i] == else if (val[i] == otk::Property::atoms.net_wm_window_type_menu)
property->atom(otk::Property::net_wm_window_type_menu))
_type = Type_Menu; _type = Type_Menu;
else if (val[i] == else if (val[i] == otk::Property::atoms.net_wm_window_type_utility)
property->atom(otk::Property::net_wm_window_type_utility))
_type = Type_Utility; _type = Type_Utility;
else if (val[i] == else if (val[i] == otk::Property::atoms.net_wm_window_type_splash)
property->atom(otk::Property::net_wm_window_type_splash))
_type = Type_Splash; _type = Type_Splash;
else if (val[i] == else if (val[i] == otk::Property::atoms.net_wm_window_type_dialog)
property->atom(otk::Property::net_wm_window_type_dialog))
_type = Type_Dialog; _type = Type_Dialog;
else if (val[i] == else if (val[i] == otk::Property::atoms.net_wm_window_type_normal)
property->atom(otk::Property::net_wm_window_type_normal))
_type = Type_Normal; _type = Type_Normal;
// else if (val[i] == // XXX: make this work again
// property->atom(otk::Property::kde_net_wm_window_type_override)) // else if (val[i] == otk::Property::atoms.kde_net_wm_window_type_override)
// mwm_decorations = 0; // prevent this window from getting any decor // mwm_decorations = 0; // prevent this window from getting any decor
// XXX: make this work again
if (_type != (WindowType) -1) if (_type != (WindowType) -1)
break; // grab the first known type break; // grab the first known type
} }
@ -245,16 +228,14 @@ void Client::setupDecorAndFunctions()
void Client::getMwmHints() void Client::getMwmHints()
{ {
const otk::Property *property = openbox->property();
unsigned long num = MwmHints::elements; unsigned long num = MwmHints::elements;
unsigned long *hints; unsigned long *hints;
_mwmhints.flags = 0; // default to none _mwmhints.flags = 0; // default to none
if (!property->get(_window, otk::Property::motif_wm_hints, if (!otk::Property::get(_window, otk::Property::atoms.motif_wm_hints,
otk::Property::motif_wm_hints, &num, otk::Property::atoms.motif_wm_hints, &num,
(unsigned long **)&hints)) (unsigned long **)&hints))
return; return;
if (num >= MwmHints::elements) { if (num >= MwmHints::elements) {
@ -283,43 +264,33 @@ void Client::getArea()
void Client::getState() void Client::getState()
{ {
const otk::Property *property = openbox->property();
_modal = _shaded = _max_horz = _max_vert = _fullscreen = _above = _below = _modal = _shaded = _max_horz = _max_vert = _fullscreen = _above = _below =
_skip_taskbar = _skip_pager = false; _skip_taskbar = _skip_pager = false;
unsigned long *state; unsigned long *state;
unsigned long num = (unsigned) -1; unsigned long num = (unsigned) -1;
if (property->get(_window, otk::Property::net_wm_state, if (otk::Property::get(_window, otk::Property::atoms.net_wm_state,
otk::Property::Atom_Atom, &num, &state)) { otk::Property::atoms.atom, &num, &state)) {
for (unsigned long i = 0; i < num; ++i) { for (unsigned long i = 0; i < num; ++i) {
if (state[i] == property->atom(otk::Property::net_wm_state_modal)) if (state[i] == otk::Property::atoms.net_wm_state_modal)
_modal = true; _modal = true;
else if (state[i] == else if (state[i] == otk::Property::atoms.net_wm_state_shaded) {
property->atom(otk::Property::net_wm_state_shaded)) {
_shaded = true; _shaded = true;
_wmstate = IconicState; _wmstate = IconicState;
} else if (state[i] == } else if (state[i] == otk::Property::atoms.net_wm_state_skip_taskbar)
property->atom(otk::Property::net_wm_state_skip_taskbar))
_skip_taskbar = true; _skip_taskbar = true;
else if (state[i] == else if (state[i] == otk::Property::atoms.net_wm_state_skip_pager)
property->atom(otk::Property::net_wm_state_skip_pager))
_skip_pager = true; _skip_pager = true;
else if (state[i] == else if (state[i] == otk::Property::atoms.net_wm_state_fullscreen)
property->atom(otk::Property::net_wm_state_fullscreen))
_fullscreen = true; _fullscreen = true;
else if (state[i] == else if (state[i] == otk::Property::atoms.net_wm_state_maximized_vert)
property->atom(otk::Property::net_wm_state_maximized_vert))
_max_vert = true; _max_vert = true;
else if (state[i] == else if (state[i] == otk::Property::atoms.net_wm_state_maximized_horz)
property->atom(otk::Property::net_wm_state_maximized_horz))
_max_horz = true; _max_horz = true;
else if (state[i] == else if (state[i] == otk::Property::atoms.net_wm_state_above)
property->atom(otk::Property::net_wm_state_above))
_above = true; _above = true;
else if (state[i] == else if (state[i] == otk::Property::atoms.net_wm_state_below)
property->atom(otk::Property::net_wm_state_below))
_below = true; _below = true;
} }
@ -376,8 +347,6 @@ void Client::calcLayer() {
void Client::updateProtocols() void Client::updateProtocols()
{ {
const otk::Property *property = openbox->property();
Atom *proto; Atom *proto;
int num_return = 0; int num_return = 0;
@ -387,12 +356,12 @@ void Client::updateProtocols()
if (XGetWMProtocols(**otk::display, _window, &proto, &num_return)) { if (XGetWMProtocols(**otk::display, _window, &proto, &num_return)) {
for (int i = 0; i < num_return; ++i) { for (int i = 0; i < num_return; ++i) {
if (proto[i] == property->atom(otk::Property::wm_delete_window)) { if (proto[i] == otk::Property::atoms.wm_delete_window) {
_decorations |= Decor_Close; _decorations |= Decor_Close;
_functions |= Func_Close; _functions |= Func_Close;
if (frame) if (frame)
frame->adjustSize(); // update the decorations frame->adjustSize(); // update the decorations
} else if (proto[i] == property->atom(otk::Property::wm_take_focus)) } else if (proto[i] == otk::Property::atoms.wm_take_focus)
// if this protocol is requested, then the window will be notified // if this protocol is requested, then the window will be notified
// by the window manager whenever it receives focus // by the window manager whenever it receives focus
_focus_notify = true; _focus_notify = true;
@ -480,16 +449,14 @@ void Client::updateWMHints()
void Client::updateTitle() void Client::updateTitle()
{ {
const otk::Property *property = openbox->property();
_title = ""; _title = "";
// try netwm // try netwm
if (! property->get(_window, otk::Property::net_wm_name, if (!otk::Property::get(_window, otk::Property::atoms.net_wm_name,
otk::Property::utf8, &_title)) { otk::Property::utf8, &_title)) {
// try old x stuff // try old x stuff
property->get(_window, otk::Property::wm_name, otk::Property::get(_window, otk::Property::atoms.wm_name,
otk::Property::ascii, &_title); otk::Property::ascii, &_title);
} }
if (_title.empty()) if (_title.empty())
@ -502,16 +469,14 @@ void Client::updateTitle()
void Client::updateIconTitle() void Client::updateIconTitle()
{ {
const otk::Property *property = openbox->property();
_icon_title = ""; _icon_title = "";
// try netwm // try netwm
if (! property->get(_window, otk::Property::net_wm_icon_name, if (!otk::Property::get(_window, otk::Property::atoms.net_wm_icon_name,
otk::Property::utf8, &_icon_title)) { otk::Property::utf8, &_icon_title)) {
// try old x stuff // try old x stuff
property->get(_window, otk::Property::wm_icon_name, otk::Property::get(_window, otk::Property::atoms.wm_icon_name,
otk::Property::ascii, &_icon_title); otk::Property::ascii, &_icon_title);
} }
if (_title.empty()) if (_title.empty())
@ -521,24 +486,22 @@ void Client::updateIconTitle()
void Client::updateClass() void Client::updateClass()
{ {
const otk::Property *property = openbox->property();
// set the defaults // set the defaults
_app_name = _app_class = _role = ""; _app_name = _app_class = _role = "";
otk::Property::StringVect v; otk::Property::StringVect v;
unsigned long num = 2; unsigned long num = 2;
if (property->get(_window, otk::Property::wm_class, if (otk::Property::get(_window, otk::Property::atoms.wm_class,
otk::Property::ascii, &num, &v)) { otk::Property::ascii, &num, &v)) {
if (num > 0) _app_name = v[0].c_str(); if (num > 0) _app_name = v[0].c_str();
if (num > 1) _app_class = v[1].c_str(); if (num > 1) _app_class = v[1].c_str();
} }
v.clear(); v.clear();
num = 1; num = 1;
if (property->get(_window, otk::Property::wm_window_role, if (otk::Property::get(_window, otk::Property::atoms.wm_window_role,
otk::Property::ascii, &num, &v)) { otk::Property::ascii, &num, &v)) {
if (num > 0) _role = v[0].c_str(); if (num > 0) _role = v[0].c_str();
} }
} }
@ -548,10 +511,8 @@ void Client::updateStrut()
{ {
unsigned long num = 4; unsigned long num = 4;
unsigned long *data; unsigned long *data;
if (!openbox->property()->get(_window, if (!otk::Property::get(_window, otk::Property::atoms.net_wm_strut,
otk::Property::net_wm_strut, otk::Property::atoms.cardinal, &num, &data))
otk::Property::Atom_Cardinal,
&num, &data))
return; return;
if (num == 4) { if (num == 4) {
@ -606,8 +567,6 @@ void Client::propertyHandler(const XPropertyEvent &e)
{ {
otk::EventHandler::propertyHandler(e); otk::EventHandler::propertyHandler(e);
const otk::Property *property = openbox->property();
// compress changes to a single property into a single change // compress changes to a single property into a single change
XEvent ce; XEvent ce;
while (XCheckTypedEvent(**otk::display, e.type, &ce)) { while (XCheckTypedEvent(**otk::display, e.type, &ce)) {
@ -630,17 +589,17 @@ void Client::propertyHandler(const XPropertyEvent &e)
setupDecorAndFunctions(); setupDecorAndFunctions();
frame->adjustSize(); // this updates the frame for any new decor settings frame->adjustSize(); // this updates the frame for any new decor settings
} }
else if (e.atom == property->atom(otk::Property::net_wm_name) || else if (e.atom == otk::Property::atoms.net_wm_name ||
e.atom == property->atom(otk::Property::wm_name)) e.atom == otk::Property::atoms.wm_name)
updateTitle(); updateTitle();
else if (e.atom == property->atom(otk::Property::net_wm_icon_name) || else if (e.atom == otk::Property::atoms.net_wm_icon_name ||
e.atom == property->atom(otk::Property::wm_icon_name)) e.atom == otk::Property::atoms.wm_icon_name)
updateIconTitle(); updateIconTitle();
else if (e.atom == property->atom(otk::Property::wm_class)) else if (e.atom == otk::Property::atoms.wm_class)
updateClass(); updateClass();
else if (e.atom == property->atom(otk::Property::wm_protocols)) else if (e.atom == otk::Property::atoms.wm_protocols)
updateProtocols(); updateProtocols();
else if (e.atom == property->atom(otk::Property::net_wm_strut)) else if (e.atom == otk::Property::atoms.net_wm_strut)
updateStrut(); updateStrut();
} }
@ -671,10 +630,8 @@ void Client::setDesktop(long target)
_desktop = target; _desktop = target;
openbox->property()->set(_window, otk::Property::set(_window, otk::Property::atoms.net_wm_desktop,
otk::Property::net_wm_desktop, otk::Property::atoms.cardinal, (unsigned)_desktop);
otk::Property::Atom_Cardinal,
(unsigned)_desktop);
// 'move' the window to the new desktop // 'move' the window to the new desktop
if (_desktop == openbox->screen(_screen)->desktop() || if (_desktop == openbox->screen(_screen)->desktop() ||
@ -687,7 +644,6 @@ void Client::setDesktop(long target)
void Client::setState(StateAction action, long data1, long data2) void Client::setState(StateAction action, long data1, long data2)
{ {
const otk::Property *property = openbox->property();
bool shadestate = _shaded; bool shadestate = _shaded;
if (!(action == State_Add || action == State_Remove || if (!(action == State_Add || action == State_Remove ||
@ -701,106 +657,85 @@ void Client::setState(StateAction action, long data1, long data2)
// if toggling, then pick whether we're adding or removing // if toggling, then pick whether we're adding or removing
if (action == State_Toggle) { if (action == State_Toggle) {
if (state == property->atom(otk::Property::net_wm_state_modal)) if (state == otk::Property::atoms.net_wm_state_modal)
action = _modal ? State_Remove : State_Add; action = _modal ? State_Remove : State_Add;
else if (state == else if (state == otk::Property::atoms.net_wm_state_maximized_vert)
property->atom(otk::Property::net_wm_state_maximized_vert))
action = _max_vert ? State_Remove : State_Add; action = _max_vert ? State_Remove : State_Add;
else if (state == else if (state == otk::Property::atoms.net_wm_state_maximized_horz)
property->atom(otk::Property::net_wm_state_maximized_horz))
action = _max_horz ? State_Remove : State_Add; action = _max_horz ? State_Remove : State_Add;
else if (state == property->atom(otk::Property::net_wm_state_shaded)) else if (state == otk::Property::atoms.net_wm_state_shaded)
action = _shaded ? State_Remove : State_Add; action = _shaded ? State_Remove : State_Add;
else if (state == else if (state == otk::Property::atoms.net_wm_state_skip_taskbar)
property->atom(otk::Property::net_wm_state_skip_taskbar))
action = _skip_taskbar ? State_Remove : State_Add; action = _skip_taskbar ? State_Remove : State_Add;
else if (state == else if (state == otk::Property::atoms.net_wm_state_skip_pager)
property->atom(otk::Property::net_wm_state_skip_pager))
action = _skip_pager ? State_Remove : State_Add; action = _skip_pager ? State_Remove : State_Add;
else if (state == else if (state == otk::Property::atoms.net_wm_state_fullscreen)
property->atom(otk::Property::net_wm_state_fullscreen))
action = _fullscreen ? State_Remove : State_Add; action = _fullscreen ? State_Remove : State_Add;
else if (state == property->atom(otk::Property::net_wm_state_above)) else if (state == otk::Property::atoms.net_wm_state_above)
action = _above ? State_Remove : State_Add; action = _above ? State_Remove : State_Add;
else if (state == property->atom(otk::Property::net_wm_state_below)) else if (state == otk::Property::atoms.net_wm_state_below)
action = _below ? State_Remove : State_Add; action = _below ? State_Remove : State_Add;
} }
if (action == State_Add) { if (action == State_Add) {
if (state == property->atom(otk::Property::net_wm_state_modal)) { if (state == otk::Property::atoms.net_wm_state_modal) {
if (_modal) continue; if (_modal) continue;
_modal = true; _modal = true;
// XXX: give it focus if another window has focus that shouldnt now // XXX: give it focus if another window has focus that shouldnt now
} else if (state == } else if (state == otk::Property::atoms.net_wm_state_maximized_vert) {
property->atom(otk::Property::net_wm_state_maximized_vert)){
if (_max_vert) continue; if (_max_vert) continue;
_max_vert = true; _max_vert = true;
// XXX: resize the window etc // XXX: resize the window etc
} else if (state == } else if (state == otk::Property::atoms.net_wm_state_maximized_horz) {
property->atom(otk::Property::net_wm_state_maximized_horz)){
if (_max_horz) continue; if (_max_horz) continue;
_max_horz = true; _max_horz = true;
// XXX: resize the window etc // XXX: resize the window etc
} else if (state == } else if (state == otk::Property::atoms.net_wm_state_shaded) {
property->atom(otk::Property::net_wm_state_shaded)) {
if (_shaded) continue; if (_shaded) continue;
// shade when we're all thru here // shade when we're all thru here
shadestate = true; shadestate = true;
} else if (state == } else if (state == otk::Property::atoms.net_wm_state_skip_taskbar) {
property->atom(otk::Property::net_wm_state_skip_taskbar)) {
_skip_taskbar = true; _skip_taskbar = true;
} else if (state == } else if (state == otk::Property::atoms.net_wm_state_skip_pager) {
property->atom(otk::Property::net_wm_state_skip_pager)) {
_skip_pager = true; _skip_pager = true;
} else if (state == } else if (state == otk::Property::atoms.net_wm_state_fullscreen) {
property->atom(otk::Property::net_wm_state_fullscreen)) {
if (_fullscreen) continue; if (_fullscreen) continue;
_fullscreen = true; _fullscreen = true;
} else if (state == } else if (state == otk::Property::atoms.net_wm_state_above) {
property->atom(otk::Property::net_wm_state_above)) {
if (_above) continue; if (_above) continue;
_above = true; _above = true;
} else if (state == } else if (state == otk::Property::atoms.net_wm_state_below) {
property->atom(otk::Property::net_wm_state_below)) {
if (_below) continue; if (_below) continue;
_below = true; _below = true;
} }
} else { // action == State_Remove } else { // action == State_Remove
if (state == property->atom(otk::Property::net_wm_state_modal)) { if (state == otk::Property::atoms.net_wm_state_modal) {
if (!_modal) continue; if (!_modal) continue;
_modal = false; _modal = false;
} else if (state == } else if (state == otk::Property::atoms.net_wm_state_maximized_vert) {
property->atom(otk::Property::net_wm_state_maximized_vert)){
if (!_max_vert) continue; if (!_max_vert) continue;
_max_vert = false; _max_vert = false;
// XXX: resize the window etc // XXX: resize the window etc
} else if (state == } else if (state == otk::Property::atoms.net_wm_state_maximized_horz) {
property->atom(otk::Property::net_wm_state_maximized_horz)){
if (!_max_horz) continue; if (!_max_horz) continue;
_max_horz = false; _max_horz = false;
// XXX: resize the window etc // XXX: resize the window etc
} else if (state == } else if (state == otk::Property::atoms.net_wm_state_shaded) {
property->atom(otk::Property::net_wm_state_shaded)) {
if (!_shaded) continue; if (!_shaded) continue;
// unshade when we're all thru here // unshade when we're all thru here
shadestate = false; shadestate = false;
} else if (state == } else if (state == otk::Property::atoms.net_wm_state_skip_taskbar) {
property->atom(otk::Property::net_wm_state_skip_taskbar)) {
_skip_taskbar = false; _skip_taskbar = false;
} else if (state == } else if (state == otk::Property::atoms.net_wm_state_skip_pager) {
property->atom(otk::Property::net_wm_state_skip_pager)) {
_skip_pager = false; _skip_pager = false;
} else if (state == } else if (state == otk::Property::atoms.net_wm_state_fullscreen) {
property->atom(otk::Property::net_wm_state_fullscreen)) {
if (!_fullscreen) continue; if (!_fullscreen) continue;
_fullscreen = false; _fullscreen = false;
} else if (state == } else if (state == otk::Property::atoms.net_wm_state_above) {
property->atom(otk::Property::net_wm_state_above)) {
if (!_above) continue; if (!_above) continue;
_above = false; _above = false;
} else if (state == } else if (state == otk::Property::atoms.net_wm_state_below) {
property->atom(otk::Property::net_wm_state_below)) {
if (!_below) continue; if (!_below) continue;
_below = false; _below = false;
} }
@ -865,9 +800,7 @@ void Client::clientMessageHandler(const XClientMessageEvent &e)
if (e.format != 32) return; if (e.format != 32) return;
const otk::Property *property = openbox->property(); if (e.message_type == otk::Property::atoms.wm_change_state) {
if (e.message_type == property->atom(otk::Property::wm_change_state)) {
// compress changes into a single change // compress changes into a single change
bool compress = false; bool compress = false;
XEvent ce; XEvent ce;
@ -884,8 +817,7 @@ void Client::clientMessageHandler(const XClientMessageEvent &e)
setWMState(ce.xclient.data.l[0]); // use the found event setWMState(ce.xclient.data.l[0]); // use the found event
else else
setWMState(e.data.l[0]); // use the original event setWMState(e.data.l[0]); // use the original event
} else if (e.message_type == } else if (e.message_type == otk::Property::atoms.net_wm_desktop) {
property->atom(otk::Property::net_wm_desktop)) {
// compress changes into a single change // compress changes into a single change
bool compress = false; bool compress = false;
XEvent ce; XEvent ce;
@ -902,7 +834,7 @@ void Client::clientMessageHandler(const XClientMessageEvent &e)
setDesktop(e.data.l[0]); // use the found event setDesktop(e.data.l[0]); // use the found event
else else
setDesktop(e.data.l[0]); // use the original event setDesktop(e.data.l[0]); // use the original event
} else if (e.message_type == property->atom(otk::Property::net_wm_state)) { } else if (e.message_type == otk::Property::atoms.net_wm_state) {
// can't compress these // can't compress these
#ifdef DEBUG #ifdef DEBUG
printf("net_wm_state %s %ld %ld for 0x%lx\n", printf("net_wm_state %s %ld %ld for 0x%lx\n",
@ -911,14 +843,12 @@ void Client::clientMessageHandler(const XClientMessageEvent &e)
e.data.l[1], e.data.l[2], _window); e.data.l[1], e.data.l[2], _window);
#endif #endif
setState((StateAction)e.data.l[0], e.data.l[1], e.data.l[2]); setState((StateAction)e.data.l[0], e.data.l[1], e.data.l[2]);
} else if (e.message_type == } else if (e.message_type == otk::Property::atoms.net_close_window) {
property->atom(otk::Property::net_close_window)) {
#ifdef DEBUG #ifdef DEBUG
printf("net_close_window for 0x%lx\n", _window); printf("net_close_window for 0x%lx\n", _window);
#endif #endif
close(); close();
} else if (e.message_type == } else if (e.message_type == otk::Property::atoms.net_active_window) {
property->atom(otk::Property::net_active_window)) {
#ifdef DEBUG #ifdef DEBUG
printf("net_active_window for 0x%lx\n", _window); printf("net_active_window for 0x%lx\n", _window);
#endif #endif
@ -1041,7 +971,6 @@ void Client::move(int x, int y)
void Client::close() void Client::close()
{ {
XEvent ce; XEvent ce;
const otk::Property *property = openbox->property();
if (!(_functions & Func_Close)) return; if (!(_functions & Func_Close)) return;
@ -1052,11 +981,11 @@ void Client::close()
// explicitly killed. // explicitly killed.
ce.xclient.type = ClientMessage; ce.xclient.type = ClientMessage;
ce.xclient.message_type = property->atom(otk::Property::wm_protocols); ce.xclient.message_type = otk::Property::atoms.wm_protocols;
ce.xclient.display = **otk::display; ce.xclient.display = **otk::display;
ce.xclient.window = _window; ce.xclient.window = _window;
ce.xclient.format = 32; ce.xclient.format = 32;
ce.xclient.data.l[0] = property->atom(otk::Property::wm_delete_window); ce.xclient.data.l[0] = otk::Property::atoms.wm_delete_window;
ce.xclient.data.l[1] = CurrentTime; ce.xclient.data.l[1] = CurrentTime;
ce.xclient.data.l[2] = 0l; ce.xclient.data.l[2] = 0l;
ce.xclient.data.l[3] = 0l; ce.xclient.data.l[3] = 0l;
@ -1067,41 +996,36 @@ void Client::close()
void Client::changeState() void Client::changeState()
{ {
const otk::Property *property = openbox->property();
unsigned long state[2]; unsigned long state[2];
state[0] = _wmstate; state[0] = _wmstate;
state[1] = None; state[1] = None;
property->set(_window, otk::Property::wm_state, otk::Property::wm_state, otk::Property::set(_window, otk::Property::atoms.wm_state,
state, 2); otk::Property::atoms.wm_state, state, 2);
Atom netstate[10]; Atom netstate[10];
int num = 0; int num = 0;
if (_modal) if (_modal)
netstate[num++] = property->atom(otk::Property::net_wm_state_modal); netstate[num++] = otk::Property::atoms.net_wm_state_modal;
if (_shaded) if (_shaded)
netstate[num++] = property->atom(otk::Property::net_wm_state_shaded); netstate[num++] = otk::Property::atoms.net_wm_state_shaded;
if (_iconic) if (_iconic)
netstate[num++] = property->atom(otk::Property::net_wm_state_hidden); netstate[num++] = otk::Property::atoms.net_wm_state_hidden;
if (_skip_taskbar) if (_skip_taskbar)
netstate[num++] = netstate[num++] = otk::Property::atoms.net_wm_state_skip_taskbar;
property->atom(otk::Property::net_wm_state_skip_taskbar);
if (_skip_pager) if (_skip_pager)
netstate[num++] = property->atom(otk::Property::net_wm_state_skip_pager); netstate[num++] = otk::Property::atoms.net_wm_state_skip_pager;
if (_fullscreen) if (_fullscreen)
netstate[num++] = property->atom(otk::Property::net_wm_state_fullscreen); netstate[num++] = otk::Property::atoms.net_wm_state_fullscreen;
if (_max_vert) if (_max_vert)
netstate[num++] = netstate[num++] = otk::Property::atoms.net_wm_state_maximized_vert;
property->atom(otk::Property::net_wm_state_maximized_vert);
if (_max_horz) if (_max_horz)
netstate[num++] = netstate[num++] = otk::Property::atoms.net_wm_state_maximized_horz;
property->atom(otk::Property::net_wm_state_maximized_horz);
if (_above) if (_above)
netstate[num++] = property->atom(otk::Property::net_wm_state_above); netstate[num++] = otk::Property::atoms.net_wm_state_above;
if (_below) if (_below)
netstate[num++] = property->atom(otk::Property::net_wm_state_below); netstate[num++] = otk::Property::atoms.net_wm_state_below;
property->set(_window, otk::Property::net_wm_state, otk::Property::set(_window, otk::Property::atoms.net_wm_state,
otk::Property::Atom_Atom, netstate, num); otk::Property::atoms.atom, netstate, num);
calcLayer(); calcLayer();
} }
@ -1132,14 +1056,12 @@ bool Client::focus() const
if (_focus_notify) { if (_focus_notify) {
XEvent ce; XEvent ce;
const otk::Property *property = openbox->property();
ce.xclient.type = ClientMessage; ce.xclient.type = ClientMessage;
ce.xclient.message_type = property->atom(otk::Property::wm_protocols); ce.xclient.message_type = otk::Property::atoms.wm_protocols;
ce.xclient.display = **otk::display; ce.xclient.display = **otk::display;
ce.xclient.window = _window; ce.xclient.window = _window;
ce.xclient.format = 32; ce.xclient.format = 32;
ce.xclient.data.l[0] = property->atom(otk::Property::wm_take_focus); ce.xclient.data.l[0] = otk::Property::atoms.wm_take_focus;
ce.xclient.data.l[1] = openbox->lastTime(); ce.xclient.data.l[1] = openbox->lastTime();
ce.xclient.data.l[2] = 0l; ce.xclient.data.l[2] = 0l;
ce.xclient.data.l[3] = 0l; ce.xclient.data.l[3] = 0l;

View file

@ -12,6 +12,7 @@
#include "python.hh" #include "python.hh"
#include "otk/property.hh" #include "otk/property.hh"
#include "otk/assassin.hh" #include "otk/assassin.hh"
#include "otk/property.hh"
#include "otk/util.hh" #include "otk/util.hh"
extern "C" { extern "C" {
@ -114,7 +115,7 @@ Openbox::Openbox(int argc, char **argv)
sigaction(SIGHUP, &action, (struct sigaction *) 0); sigaction(SIGHUP, &action, (struct sigaction *) 0);
otk::Timer::initialize(); otk::Timer::initialize();
_property = new otk::Property(); otk::Property::initialize();
_actions = new Actions(); _actions = new Actions();
_bindings = new Bindings(); _bindings = new Bindings();
@ -182,7 +183,6 @@ Openbox::~Openbox()
delete _bindings; delete _bindings;
delete _actions; delete _actions;
delete _property;
python_destroy(); python_destroy();
@ -370,9 +370,9 @@ void Openbox::setFocusedClient(Client *c)
for (it = _screens.begin(); it != end; ++it) { for (it = _screens.begin(); it != end; ++it) {
int num = (*it)->number(); int num = (*it)->number();
Window root = otk::display->screenInfo(num)->rootWindow(); Window root = otk::display->screenInfo(num)->rootWindow();
_property->set(root, otk::Property::net_active_window, otk::Property::set(root, otk::Property::atoms.net_active_window,
otk::Property::Atom_Window, otk::Property::atoms.window,
(c && _focused_screen == *it) ? c->window() : None); (c && _focused_screen == *it) ? c->window() : None);
} }
// call the python Focus callbacks // call the python Focus callbacks

View file

@ -16,7 +16,6 @@ extern "C" {
#include "otk/display.hh" #include "otk/display.hh"
#include "otk/screeninfo.hh" #include "otk/screeninfo.hh"
#include "otk/property.hh"
#include "otk/configuration.hh" #include "otk/configuration.hh"
#include "otk/eventdispatcher.hh" #include "otk/eventdispatcher.hh"
#include "otk/eventhandler.hh" #include "otk/eventhandler.hh"
@ -108,14 +107,6 @@ private:
//! A list of all the managed screens //! A list of all the managed screens
ScreenList _screens; ScreenList _screens;
//! Cached atoms on the display
/*!
This is a pointer because the Property class uses otk::Display::display
in its constructor, so, it needs to be initialized <b>after</b> the display
is initialized in this class' constructor.
*/
otk::Property *_property;
//! The action interface through which all user-available actions occur //! The action interface through which all user-available actions occur
Actions *_actions; Actions *_actions;
@ -177,9 +168,6 @@ public:
//! Returns the state of the window manager (starting, exiting, etc) //! Returns the state of the window manager (starting, exiting, etc)
inline RunState state() const { return _state; } inline RunState state() const { return _state; }
//! Returns the otk::Property instance for the window manager
inline const otk::Property *property() const { return _property; }
//! Returns the Actions instance for the window manager //! Returns the Actions instance for the window manager
inline Actions *actions() const { return _actions; } inline Actions *actions() const { return _actions; }

View file

@ -109,12 +109,17 @@ void python_callback(PyObject *func, KeyData *data)
} }
}; };
%include "../otk/ustring.i"
%ignore otk::display; %ignore otk::display;
%inline %{ %inline %{
otk::Display *Display_instance() { return otk::display; } otk::Display *Display_instance() { return otk::display; }
%}; %};
%include "../otk/ustring.i" %ignore otk::Property::atoms;
%inline %{
const otk::Atoms& Property_atoms() { return otk::Property::atoms; }
%};
%include "../otk/display.hh" %include "../otk/display.hh"
%include "../otk/point.hh" %include "../otk/point.hh"

View file

@ -31,6 +31,8 @@ Openbox_instance = _openbox.Openbox_instance
Display_instance = _openbox.Display_instance Display_instance = _openbox.Display_instance
Property_atoms = _openbox.Property_atoms
class Display(_object): class Display(_object):
__swig_setmethods__ = {} __swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, Display, name, value) __setattr__ = lambda self, name, value: _swig_setattr(self, Display, name, value)
@ -93,117 +95,279 @@ class PointPtr(Point):
self.__class__ = Point self.__class__ = Point
_openbox.Point_swigregister(PointPtr) _openbox.Point_swigregister(PointPtr)
class Atoms(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, Atoms, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, Atoms, name)
__swig_setmethods__["cardinal"] = _openbox.Atoms_cardinal_set
__swig_getmethods__["cardinal"] = _openbox.Atoms_cardinal_get
if _newclass:cardinal = property(_openbox.Atoms_cardinal_get,_openbox.Atoms_cardinal_set)
__swig_setmethods__["window"] = _openbox.Atoms_window_set
__swig_getmethods__["window"] = _openbox.Atoms_window_get
if _newclass:window = property(_openbox.Atoms_window_get,_openbox.Atoms_window_set)
__swig_setmethods__["pixmap"] = _openbox.Atoms_pixmap_set
__swig_getmethods__["pixmap"] = _openbox.Atoms_pixmap_get
if _newclass:pixmap = property(_openbox.Atoms_pixmap_get,_openbox.Atoms_pixmap_set)
__swig_setmethods__["atom"] = _openbox.Atoms_atom_set
__swig_getmethods__["atom"] = _openbox.Atoms_atom_get
if _newclass:atom = property(_openbox.Atoms_atom_get,_openbox.Atoms_atom_set)
__swig_setmethods__["string"] = _openbox.Atoms_string_set
__swig_getmethods__["string"] = _openbox.Atoms_string_get
if _newclass:string = property(_openbox.Atoms_string_get,_openbox.Atoms_string_set)
__swig_setmethods__["utf8"] = _openbox.Atoms_utf8_set
__swig_getmethods__["utf8"] = _openbox.Atoms_utf8_get
if _newclass:utf8 = property(_openbox.Atoms_utf8_get,_openbox.Atoms_utf8_set)
__swig_setmethods__["openbox_pid"] = _openbox.Atoms_openbox_pid_set
__swig_getmethods__["openbox_pid"] = _openbox.Atoms_openbox_pid_get
if _newclass:openbox_pid = property(_openbox.Atoms_openbox_pid_get,_openbox.Atoms_openbox_pid_set)
__swig_setmethods__["wm_colormap_windows"] = _openbox.Atoms_wm_colormap_windows_set
__swig_getmethods__["wm_colormap_windows"] = _openbox.Atoms_wm_colormap_windows_get
if _newclass:wm_colormap_windows = property(_openbox.Atoms_wm_colormap_windows_get,_openbox.Atoms_wm_colormap_windows_set)
__swig_setmethods__["wm_protocols"] = _openbox.Atoms_wm_protocols_set
__swig_getmethods__["wm_protocols"] = _openbox.Atoms_wm_protocols_get
if _newclass:wm_protocols = property(_openbox.Atoms_wm_protocols_get,_openbox.Atoms_wm_protocols_set)
__swig_setmethods__["wm_state"] = _openbox.Atoms_wm_state_set
__swig_getmethods__["wm_state"] = _openbox.Atoms_wm_state_get
if _newclass:wm_state = property(_openbox.Atoms_wm_state_get,_openbox.Atoms_wm_state_set)
__swig_setmethods__["wm_delete_window"] = _openbox.Atoms_wm_delete_window_set
__swig_getmethods__["wm_delete_window"] = _openbox.Atoms_wm_delete_window_get
if _newclass:wm_delete_window = property(_openbox.Atoms_wm_delete_window_get,_openbox.Atoms_wm_delete_window_set)
__swig_setmethods__["wm_take_focus"] = _openbox.Atoms_wm_take_focus_set
__swig_getmethods__["wm_take_focus"] = _openbox.Atoms_wm_take_focus_get
if _newclass:wm_take_focus = property(_openbox.Atoms_wm_take_focus_get,_openbox.Atoms_wm_take_focus_set)
__swig_setmethods__["wm_change_state"] = _openbox.Atoms_wm_change_state_set
__swig_getmethods__["wm_change_state"] = _openbox.Atoms_wm_change_state_get
if _newclass:wm_change_state = property(_openbox.Atoms_wm_change_state_get,_openbox.Atoms_wm_change_state_set)
__swig_setmethods__["wm_name"] = _openbox.Atoms_wm_name_set
__swig_getmethods__["wm_name"] = _openbox.Atoms_wm_name_get
if _newclass:wm_name = property(_openbox.Atoms_wm_name_get,_openbox.Atoms_wm_name_set)
__swig_setmethods__["wm_icon_name"] = _openbox.Atoms_wm_icon_name_set
__swig_getmethods__["wm_icon_name"] = _openbox.Atoms_wm_icon_name_get
if _newclass:wm_icon_name = property(_openbox.Atoms_wm_icon_name_get,_openbox.Atoms_wm_icon_name_set)
__swig_setmethods__["wm_class"] = _openbox.Atoms_wm_class_set
__swig_getmethods__["wm_class"] = _openbox.Atoms_wm_class_get
if _newclass:wm_class = property(_openbox.Atoms_wm_class_get,_openbox.Atoms_wm_class_set)
__swig_setmethods__["wm_window_role"] = _openbox.Atoms_wm_window_role_set
__swig_getmethods__["wm_window_role"] = _openbox.Atoms_wm_window_role_get
if _newclass:wm_window_role = property(_openbox.Atoms_wm_window_role_get,_openbox.Atoms_wm_window_role_set)
__swig_setmethods__["motif_wm_hints"] = _openbox.Atoms_motif_wm_hints_set
__swig_getmethods__["motif_wm_hints"] = _openbox.Atoms_motif_wm_hints_get
if _newclass:motif_wm_hints = property(_openbox.Atoms_motif_wm_hints_get,_openbox.Atoms_motif_wm_hints_set)
__swig_setmethods__["openbox_show_root_menu"] = _openbox.Atoms_openbox_show_root_menu_set
__swig_getmethods__["openbox_show_root_menu"] = _openbox.Atoms_openbox_show_root_menu_get
if _newclass:openbox_show_root_menu = property(_openbox.Atoms_openbox_show_root_menu_get,_openbox.Atoms_openbox_show_root_menu_set)
__swig_setmethods__["openbox_show_workspace_menu"] = _openbox.Atoms_openbox_show_workspace_menu_set
__swig_getmethods__["openbox_show_workspace_menu"] = _openbox.Atoms_openbox_show_workspace_menu_get
if _newclass:openbox_show_workspace_menu = property(_openbox.Atoms_openbox_show_workspace_menu_get,_openbox.Atoms_openbox_show_workspace_menu_set)
__swig_setmethods__["net_supported"] = _openbox.Atoms_net_supported_set
__swig_getmethods__["net_supported"] = _openbox.Atoms_net_supported_get
if _newclass:net_supported = property(_openbox.Atoms_net_supported_get,_openbox.Atoms_net_supported_set)
__swig_setmethods__["net_client_list"] = _openbox.Atoms_net_client_list_set
__swig_getmethods__["net_client_list"] = _openbox.Atoms_net_client_list_get
if _newclass:net_client_list = property(_openbox.Atoms_net_client_list_get,_openbox.Atoms_net_client_list_set)
__swig_setmethods__["net_client_list_stacking"] = _openbox.Atoms_net_client_list_stacking_set
__swig_getmethods__["net_client_list_stacking"] = _openbox.Atoms_net_client_list_stacking_get
if _newclass:net_client_list_stacking = property(_openbox.Atoms_net_client_list_stacking_get,_openbox.Atoms_net_client_list_stacking_set)
__swig_setmethods__["net_number_of_desktops"] = _openbox.Atoms_net_number_of_desktops_set
__swig_getmethods__["net_number_of_desktops"] = _openbox.Atoms_net_number_of_desktops_get
if _newclass:net_number_of_desktops = property(_openbox.Atoms_net_number_of_desktops_get,_openbox.Atoms_net_number_of_desktops_set)
__swig_setmethods__["net_desktop_geometry"] = _openbox.Atoms_net_desktop_geometry_set
__swig_getmethods__["net_desktop_geometry"] = _openbox.Atoms_net_desktop_geometry_get
if _newclass:net_desktop_geometry = property(_openbox.Atoms_net_desktop_geometry_get,_openbox.Atoms_net_desktop_geometry_set)
__swig_setmethods__["net_desktop_viewport"] = _openbox.Atoms_net_desktop_viewport_set
__swig_getmethods__["net_desktop_viewport"] = _openbox.Atoms_net_desktop_viewport_get
if _newclass:net_desktop_viewport = property(_openbox.Atoms_net_desktop_viewport_get,_openbox.Atoms_net_desktop_viewport_set)
__swig_setmethods__["net_current_desktop"] = _openbox.Atoms_net_current_desktop_set
__swig_getmethods__["net_current_desktop"] = _openbox.Atoms_net_current_desktop_get
if _newclass:net_current_desktop = property(_openbox.Atoms_net_current_desktop_get,_openbox.Atoms_net_current_desktop_set)
__swig_setmethods__["net_desktop_names"] = _openbox.Atoms_net_desktop_names_set
__swig_getmethods__["net_desktop_names"] = _openbox.Atoms_net_desktop_names_get
if _newclass:net_desktop_names = property(_openbox.Atoms_net_desktop_names_get,_openbox.Atoms_net_desktop_names_set)
__swig_setmethods__["net_active_window"] = _openbox.Atoms_net_active_window_set
__swig_getmethods__["net_active_window"] = _openbox.Atoms_net_active_window_get
if _newclass:net_active_window = property(_openbox.Atoms_net_active_window_get,_openbox.Atoms_net_active_window_set)
__swig_setmethods__["net_workarea"] = _openbox.Atoms_net_workarea_set
__swig_getmethods__["net_workarea"] = _openbox.Atoms_net_workarea_get
if _newclass:net_workarea = property(_openbox.Atoms_net_workarea_get,_openbox.Atoms_net_workarea_set)
__swig_setmethods__["net_supporting_wm_check"] = _openbox.Atoms_net_supporting_wm_check_set
__swig_getmethods__["net_supporting_wm_check"] = _openbox.Atoms_net_supporting_wm_check_get
if _newclass:net_supporting_wm_check = property(_openbox.Atoms_net_supporting_wm_check_get,_openbox.Atoms_net_supporting_wm_check_set)
__swig_setmethods__["net_close_window"] = _openbox.Atoms_net_close_window_set
__swig_getmethods__["net_close_window"] = _openbox.Atoms_net_close_window_get
if _newclass:net_close_window = property(_openbox.Atoms_net_close_window_get,_openbox.Atoms_net_close_window_set)
__swig_setmethods__["net_wm_moveresize"] = _openbox.Atoms_net_wm_moveresize_set
__swig_getmethods__["net_wm_moveresize"] = _openbox.Atoms_net_wm_moveresize_get
if _newclass:net_wm_moveresize = property(_openbox.Atoms_net_wm_moveresize_get,_openbox.Atoms_net_wm_moveresize_set)
__swig_setmethods__["net_wm_name"] = _openbox.Atoms_net_wm_name_set
__swig_getmethods__["net_wm_name"] = _openbox.Atoms_net_wm_name_get
if _newclass:net_wm_name = property(_openbox.Atoms_net_wm_name_get,_openbox.Atoms_net_wm_name_set)
__swig_setmethods__["net_wm_visible_name"] = _openbox.Atoms_net_wm_visible_name_set
__swig_getmethods__["net_wm_visible_name"] = _openbox.Atoms_net_wm_visible_name_get
if _newclass:net_wm_visible_name = property(_openbox.Atoms_net_wm_visible_name_get,_openbox.Atoms_net_wm_visible_name_set)
__swig_setmethods__["net_wm_icon_name"] = _openbox.Atoms_net_wm_icon_name_set
__swig_getmethods__["net_wm_icon_name"] = _openbox.Atoms_net_wm_icon_name_get
if _newclass:net_wm_icon_name = property(_openbox.Atoms_net_wm_icon_name_get,_openbox.Atoms_net_wm_icon_name_set)
__swig_setmethods__["net_wm_visible_icon_name"] = _openbox.Atoms_net_wm_visible_icon_name_set
__swig_getmethods__["net_wm_visible_icon_name"] = _openbox.Atoms_net_wm_visible_icon_name_get
if _newclass:net_wm_visible_icon_name = property(_openbox.Atoms_net_wm_visible_icon_name_get,_openbox.Atoms_net_wm_visible_icon_name_set)
__swig_setmethods__["net_wm_desktop"] = _openbox.Atoms_net_wm_desktop_set
__swig_getmethods__["net_wm_desktop"] = _openbox.Atoms_net_wm_desktop_get
if _newclass:net_wm_desktop = property(_openbox.Atoms_net_wm_desktop_get,_openbox.Atoms_net_wm_desktop_set)
__swig_setmethods__["net_wm_window_type"] = _openbox.Atoms_net_wm_window_type_set
__swig_getmethods__["net_wm_window_type"] = _openbox.Atoms_net_wm_window_type_get
if _newclass:net_wm_window_type = property(_openbox.Atoms_net_wm_window_type_get,_openbox.Atoms_net_wm_window_type_set)
__swig_setmethods__["net_wm_state"] = _openbox.Atoms_net_wm_state_set
__swig_getmethods__["net_wm_state"] = _openbox.Atoms_net_wm_state_get
if _newclass:net_wm_state = property(_openbox.Atoms_net_wm_state_get,_openbox.Atoms_net_wm_state_set)
__swig_setmethods__["net_wm_strut"] = _openbox.Atoms_net_wm_strut_set
__swig_getmethods__["net_wm_strut"] = _openbox.Atoms_net_wm_strut_get
if _newclass:net_wm_strut = property(_openbox.Atoms_net_wm_strut_get,_openbox.Atoms_net_wm_strut_set)
__swig_setmethods__["net_wm_allowed_actions"] = _openbox.Atoms_net_wm_allowed_actions_set
__swig_getmethods__["net_wm_allowed_actions"] = _openbox.Atoms_net_wm_allowed_actions_get
if _newclass:net_wm_allowed_actions = property(_openbox.Atoms_net_wm_allowed_actions_get,_openbox.Atoms_net_wm_allowed_actions_set)
__swig_setmethods__["net_wm_window_type_desktop"] = _openbox.Atoms_net_wm_window_type_desktop_set
__swig_getmethods__["net_wm_window_type_desktop"] = _openbox.Atoms_net_wm_window_type_desktop_get
if _newclass:net_wm_window_type_desktop = property(_openbox.Atoms_net_wm_window_type_desktop_get,_openbox.Atoms_net_wm_window_type_desktop_set)
__swig_setmethods__["net_wm_window_type_dock"] = _openbox.Atoms_net_wm_window_type_dock_set
__swig_getmethods__["net_wm_window_type_dock"] = _openbox.Atoms_net_wm_window_type_dock_get
if _newclass:net_wm_window_type_dock = property(_openbox.Atoms_net_wm_window_type_dock_get,_openbox.Atoms_net_wm_window_type_dock_set)
__swig_setmethods__["net_wm_window_type_toolbar"] = _openbox.Atoms_net_wm_window_type_toolbar_set
__swig_getmethods__["net_wm_window_type_toolbar"] = _openbox.Atoms_net_wm_window_type_toolbar_get
if _newclass:net_wm_window_type_toolbar = property(_openbox.Atoms_net_wm_window_type_toolbar_get,_openbox.Atoms_net_wm_window_type_toolbar_set)
__swig_setmethods__["net_wm_window_type_menu"] = _openbox.Atoms_net_wm_window_type_menu_set
__swig_getmethods__["net_wm_window_type_menu"] = _openbox.Atoms_net_wm_window_type_menu_get
if _newclass:net_wm_window_type_menu = property(_openbox.Atoms_net_wm_window_type_menu_get,_openbox.Atoms_net_wm_window_type_menu_set)
__swig_setmethods__["net_wm_window_type_utility"] = _openbox.Atoms_net_wm_window_type_utility_set
__swig_getmethods__["net_wm_window_type_utility"] = _openbox.Atoms_net_wm_window_type_utility_get
if _newclass:net_wm_window_type_utility = property(_openbox.Atoms_net_wm_window_type_utility_get,_openbox.Atoms_net_wm_window_type_utility_set)
__swig_setmethods__["net_wm_window_type_splash"] = _openbox.Atoms_net_wm_window_type_splash_set
__swig_getmethods__["net_wm_window_type_splash"] = _openbox.Atoms_net_wm_window_type_splash_get
if _newclass:net_wm_window_type_splash = property(_openbox.Atoms_net_wm_window_type_splash_get,_openbox.Atoms_net_wm_window_type_splash_set)
__swig_setmethods__["net_wm_window_type_dialog"] = _openbox.Atoms_net_wm_window_type_dialog_set
__swig_getmethods__["net_wm_window_type_dialog"] = _openbox.Atoms_net_wm_window_type_dialog_get
if _newclass:net_wm_window_type_dialog = property(_openbox.Atoms_net_wm_window_type_dialog_get,_openbox.Atoms_net_wm_window_type_dialog_set)
__swig_setmethods__["net_wm_window_type_normal"] = _openbox.Atoms_net_wm_window_type_normal_set
__swig_getmethods__["net_wm_window_type_normal"] = _openbox.Atoms_net_wm_window_type_normal_get
if _newclass:net_wm_window_type_normal = property(_openbox.Atoms_net_wm_window_type_normal_get,_openbox.Atoms_net_wm_window_type_normal_set)
__swig_setmethods__["net_wm_moveresize_size_topleft"] = _openbox.Atoms_net_wm_moveresize_size_topleft_set
__swig_getmethods__["net_wm_moveresize_size_topleft"] = _openbox.Atoms_net_wm_moveresize_size_topleft_get
if _newclass:net_wm_moveresize_size_topleft = property(_openbox.Atoms_net_wm_moveresize_size_topleft_get,_openbox.Atoms_net_wm_moveresize_size_topleft_set)
__swig_setmethods__["net_wm_moveresize_size_topright"] = _openbox.Atoms_net_wm_moveresize_size_topright_set
__swig_getmethods__["net_wm_moveresize_size_topright"] = _openbox.Atoms_net_wm_moveresize_size_topright_get
if _newclass:net_wm_moveresize_size_topright = property(_openbox.Atoms_net_wm_moveresize_size_topright_get,_openbox.Atoms_net_wm_moveresize_size_topright_set)
__swig_setmethods__["net_wm_moveresize_size_bottomleft"] = _openbox.Atoms_net_wm_moveresize_size_bottomleft_set
__swig_getmethods__["net_wm_moveresize_size_bottomleft"] = _openbox.Atoms_net_wm_moveresize_size_bottomleft_get
if _newclass:net_wm_moveresize_size_bottomleft = property(_openbox.Atoms_net_wm_moveresize_size_bottomleft_get,_openbox.Atoms_net_wm_moveresize_size_bottomleft_set)
__swig_setmethods__["net_wm_moveresize_size_bottomright"] = _openbox.Atoms_net_wm_moveresize_size_bottomright_set
__swig_getmethods__["net_wm_moveresize_size_bottomright"] = _openbox.Atoms_net_wm_moveresize_size_bottomright_get
if _newclass:net_wm_moveresize_size_bottomright = property(_openbox.Atoms_net_wm_moveresize_size_bottomright_get,_openbox.Atoms_net_wm_moveresize_size_bottomright_set)
__swig_setmethods__["net_wm_moveresize_move"] = _openbox.Atoms_net_wm_moveresize_move_set
__swig_getmethods__["net_wm_moveresize_move"] = _openbox.Atoms_net_wm_moveresize_move_get
if _newclass:net_wm_moveresize_move = property(_openbox.Atoms_net_wm_moveresize_move_get,_openbox.Atoms_net_wm_moveresize_move_set)
__swig_setmethods__["net_wm_action_move"] = _openbox.Atoms_net_wm_action_move_set
__swig_getmethods__["net_wm_action_move"] = _openbox.Atoms_net_wm_action_move_get
if _newclass:net_wm_action_move = property(_openbox.Atoms_net_wm_action_move_get,_openbox.Atoms_net_wm_action_move_set)
__swig_setmethods__["net_wm_action_resize"] = _openbox.Atoms_net_wm_action_resize_set
__swig_getmethods__["net_wm_action_resize"] = _openbox.Atoms_net_wm_action_resize_get
if _newclass:net_wm_action_resize = property(_openbox.Atoms_net_wm_action_resize_get,_openbox.Atoms_net_wm_action_resize_set)
__swig_setmethods__["net_wm_action_shade"] = _openbox.Atoms_net_wm_action_shade_set
__swig_getmethods__["net_wm_action_shade"] = _openbox.Atoms_net_wm_action_shade_get
if _newclass:net_wm_action_shade = property(_openbox.Atoms_net_wm_action_shade_get,_openbox.Atoms_net_wm_action_shade_set)
__swig_setmethods__["net_wm_action_maximize_horz"] = _openbox.Atoms_net_wm_action_maximize_horz_set
__swig_getmethods__["net_wm_action_maximize_horz"] = _openbox.Atoms_net_wm_action_maximize_horz_get
if _newclass:net_wm_action_maximize_horz = property(_openbox.Atoms_net_wm_action_maximize_horz_get,_openbox.Atoms_net_wm_action_maximize_horz_set)
__swig_setmethods__["net_wm_action_maximize_vert"] = _openbox.Atoms_net_wm_action_maximize_vert_set
__swig_getmethods__["net_wm_action_maximize_vert"] = _openbox.Atoms_net_wm_action_maximize_vert_get
if _newclass:net_wm_action_maximize_vert = property(_openbox.Atoms_net_wm_action_maximize_vert_get,_openbox.Atoms_net_wm_action_maximize_vert_set)
__swig_setmethods__["net_wm_action_change_desktop"] = _openbox.Atoms_net_wm_action_change_desktop_set
__swig_getmethods__["net_wm_action_change_desktop"] = _openbox.Atoms_net_wm_action_change_desktop_get
if _newclass:net_wm_action_change_desktop = property(_openbox.Atoms_net_wm_action_change_desktop_get,_openbox.Atoms_net_wm_action_change_desktop_set)
__swig_setmethods__["net_wm_action_close"] = _openbox.Atoms_net_wm_action_close_set
__swig_getmethods__["net_wm_action_close"] = _openbox.Atoms_net_wm_action_close_get
if _newclass:net_wm_action_close = property(_openbox.Atoms_net_wm_action_close_get,_openbox.Atoms_net_wm_action_close_set)
__swig_setmethods__["net_wm_state_modal"] = _openbox.Atoms_net_wm_state_modal_set
__swig_getmethods__["net_wm_state_modal"] = _openbox.Atoms_net_wm_state_modal_get
if _newclass:net_wm_state_modal = property(_openbox.Atoms_net_wm_state_modal_get,_openbox.Atoms_net_wm_state_modal_set)
__swig_setmethods__["net_wm_state_sticky"] = _openbox.Atoms_net_wm_state_sticky_set
__swig_getmethods__["net_wm_state_sticky"] = _openbox.Atoms_net_wm_state_sticky_get
if _newclass:net_wm_state_sticky = property(_openbox.Atoms_net_wm_state_sticky_get,_openbox.Atoms_net_wm_state_sticky_set)
__swig_setmethods__["net_wm_state_maximized_vert"] = _openbox.Atoms_net_wm_state_maximized_vert_set
__swig_getmethods__["net_wm_state_maximized_vert"] = _openbox.Atoms_net_wm_state_maximized_vert_get
if _newclass:net_wm_state_maximized_vert = property(_openbox.Atoms_net_wm_state_maximized_vert_get,_openbox.Atoms_net_wm_state_maximized_vert_set)
__swig_setmethods__["net_wm_state_maximized_horz"] = _openbox.Atoms_net_wm_state_maximized_horz_set
__swig_getmethods__["net_wm_state_maximized_horz"] = _openbox.Atoms_net_wm_state_maximized_horz_get
if _newclass:net_wm_state_maximized_horz = property(_openbox.Atoms_net_wm_state_maximized_horz_get,_openbox.Atoms_net_wm_state_maximized_horz_set)
__swig_setmethods__["net_wm_state_shaded"] = _openbox.Atoms_net_wm_state_shaded_set
__swig_getmethods__["net_wm_state_shaded"] = _openbox.Atoms_net_wm_state_shaded_get
if _newclass:net_wm_state_shaded = property(_openbox.Atoms_net_wm_state_shaded_get,_openbox.Atoms_net_wm_state_shaded_set)
__swig_setmethods__["net_wm_state_skip_taskbar"] = _openbox.Atoms_net_wm_state_skip_taskbar_set
__swig_getmethods__["net_wm_state_skip_taskbar"] = _openbox.Atoms_net_wm_state_skip_taskbar_get
if _newclass:net_wm_state_skip_taskbar = property(_openbox.Atoms_net_wm_state_skip_taskbar_get,_openbox.Atoms_net_wm_state_skip_taskbar_set)
__swig_setmethods__["net_wm_state_skip_pager"] = _openbox.Atoms_net_wm_state_skip_pager_set
__swig_getmethods__["net_wm_state_skip_pager"] = _openbox.Atoms_net_wm_state_skip_pager_get
if _newclass:net_wm_state_skip_pager = property(_openbox.Atoms_net_wm_state_skip_pager_get,_openbox.Atoms_net_wm_state_skip_pager_set)
__swig_setmethods__["net_wm_state_hidden"] = _openbox.Atoms_net_wm_state_hidden_set
__swig_getmethods__["net_wm_state_hidden"] = _openbox.Atoms_net_wm_state_hidden_get
if _newclass:net_wm_state_hidden = property(_openbox.Atoms_net_wm_state_hidden_get,_openbox.Atoms_net_wm_state_hidden_set)
__swig_setmethods__["net_wm_state_fullscreen"] = _openbox.Atoms_net_wm_state_fullscreen_set
__swig_getmethods__["net_wm_state_fullscreen"] = _openbox.Atoms_net_wm_state_fullscreen_get
if _newclass:net_wm_state_fullscreen = property(_openbox.Atoms_net_wm_state_fullscreen_get,_openbox.Atoms_net_wm_state_fullscreen_set)
__swig_setmethods__["net_wm_state_above"] = _openbox.Atoms_net_wm_state_above_set
__swig_getmethods__["net_wm_state_above"] = _openbox.Atoms_net_wm_state_above_get
if _newclass:net_wm_state_above = property(_openbox.Atoms_net_wm_state_above_get,_openbox.Atoms_net_wm_state_above_set)
__swig_setmethods__["net_wm_state_below"] = _openbox.Atoms_net_wm_state_below_set
__swig_getmethods__["net_wm_state_below"] = _openbox.Atoms_net_wm_state_below_get
if _newclass:net_wm_state_below = property(_openbox.Atoms_net_wm_state_below_get,_openbox.Atoms_net_wm_state_below_set)
__swig_setmethods__["kde_net_system_tray_windows"] = _openbox.Atoms_kde_net_system_tray_windows_set
__swig_getmethods__["kde_net_system_tray_windows"] = _openbox.Atoms_kde_net_system_tray_windows_get
if _newclass:kde_net_system_tray_windows = property(_openbox.Atoms_kde_net_system_tray_windows_get,_openbox.Atoms_kde_net_system_tray_windows_set)
__swig_setmethods__["kde_net_wm_system_tray_window_for"] = _openbox.Atoms_kde_net_wm_system_tray_window_for_set
__swig_getmethods__["kde_net_wm_system_tray_window_for"] = _openbox.Atoms_kde_net_wm_system_tray_window_for_get
if _newclass:kde_net_wm_system_tray_window_for = property(_openbox.Atoms_kde_net_wm_system_tray_window_for_get,_openbox.Atoms_kde_net_wm_system_tray_window_for_set)
__swig_setmethods__["kde_net_wm_window_type_override"] = _openbox.Atoms_kde_net_wm_window_type_override_set
__swig_getmethods__["kde_net_wm_window_type_override"] = _openbox.Atoms_kde_net_wm_window_type_override_get
if _newclass:kde_net_wm_window_type_override = property(_openbox.Atoms_kde_net_wm_window_type_override_get,_openbox.Atoms_kde_net_wm_window_type_override_set)
def __init__(self): raise RuntimeError, "No constructor defined"
def __repr__(self):
return "<C Atoms instance at %s>" % (self.this,)
class AtomsPtr(Atoms):
def __init__(self,this):
self.this = this
if not hasattr(self,"thisown"): self.thisown = 0
self.__class__ = Atoms
_openbox.Atoms_swigregister(AtomsPtr)
class Property(_object): class Property(_object):
__swig_setmethods__ = {} __swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, Property, name, value) __setattr__ = lambda self, name, value: _swig_setattr(self, Property, name, value)
__swig_getmethods__ = {} __swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, Property, name) __getattr__ = lambda self, name: _swig_getattr(self, Property, name)
Atom_Cardinal = _openbox.Property_Atom_Cardinal
Atom_Window = _openbox.Property_Atom_Window
Atom_Pixmap = _openbox.Property_Atom_Pixmap
Atom_Atom = _openbox.Property_Atom_Atom
Atom_String = _openbox.Property_Atom_String
Atom_Utf8 = _openbox.Property_Atom_Utf8
openbox_pid = _openbox.Property_openbox_pid
wm_colormap_windows = _openbox.Property_wm_colormap_windows
wm_protocols = _openbox.Property_wm_protocols
wm_state = _openbox.Property_wm_state
wm_delete_window = _openbox.Property_wm_delete_window
wm_take_focus = _openbox.Property_wm_take_focus
wm_change_state = _openbox.Property_wm_change_state
wm_name = _openbox.Property_wm_name
wm_icon_name = _openbox.Property_wm_icon_name
wm_class = _openbox.Property_wm_class
wm_window_role = _openbox.Property_wm_window_role
motif_wm_hints = _openbox.Property_motif_wm_hints
blackbox_attributes = _openbox.Property_blackbox_attributes
blackbox_change_attributes = _openbox.Property_blackbox_change_attributes
blackbox_hints = _openbox.Property_blackbox_hints
blackbox_structure_messages = _openbox.Property_blackbox_structure_messages
blackbox_notify_startup = _openbox.Property_blackbox_notify_startup
blackbox_notify_window_add = _openbox.Property_blackbox_notify_window_add
blackbox_notify_window_del = _openbox.Property_blackbox_notify_window_del
blackbox_notify_window_focus = _openbox.Property_blackbox_notify_window_focus
blackbox_notify_current_workspace = _openbox.Property_blackbox_notify_current_workspace
blackbox_notify_workspace_count = _openbox.Property_blackbox_notify_workspace_count
blackbox_notify_window_raise = _openbox.Property_blackbox_notify_window_raise
blackbox_notify_window_lower = _openbox.Property_blackbox_notify_window_lower
blackbox_change_workspace = _openbox.Property_blackbox_change_workspace
blackbox_change_window_focus = _openbox.Property_blackbox_change_window_focus
blackbox_cycle_window_focus = _openbox.Property_blackbox_cycle_window_focus
openbox_show_root_menu = _openbox.Property_openbox_show_root_menu
openbox_show_workspace_menu = _openbox.Property_openbox_show_workspace_menu
net_supported = _openbox.Property_net_supported
net_client_list = _openbox.Property_net_client_list
net_client_list_stacking = _openbox.Property_net_client_list_stacking
net_number_of_desktops = _openbox.Property_net_number_of_desktops
net_desktop_geometry = _openbox.Property_net_desktop_geometry
net_desktop_viewport = _openbox.Property_net_desktop_viewport
net_current_desktop = _openbox.Property_net_current_desktop
net_desktop_names = _openbox.Property_net_desktop_names
net_active_window = _openbox.Property_net_active_window
net_workarea = _openbox.Property_net_workarea
net_supporting_wm_check = _openbox.Property_net_supporting_wm_check
net_close_window = _openbox.Property_net_close_window
net_wm_moveresize = _openbox.Property_net_wm_moveresize
net_wm_name = _openbox.Property_net_wm_name
net_wm_visible_name = _openbox.Property_net_wm_visible_name
net_wm_icon_name = _openbox.Property_net_wm_icon_name
net_wm_visible_icon_name = _openbox.Property_net_wm_visible_icon_name
net_wm_desktop = _openbox.Property_net_wm_desktop
net_wm_window_type = _openbox.Property_net_wm_window_type
net_wm_state = _openbox.Property_net_wm_state
net_wm_strut = _openbox.Property_net_wm_strut
net_wm_allowed_actions = _openbox.Property_net_wm_allowed_actions
net_wm_window_type_desktop = _openbox.Property_net_wm_window_type_desktop
net_wm_window_type_dock = _openbox.Property_net_wm_window_type_dock
net_wm_window_type_toolbar = _openbox.Property_net_wm_window_type_toolbar
net_wm_window_type_menu = _openbox.Property_net_wm_window_type_menu
net_wm_window_type_utility = _openbox.Property_net_wm_window_type_utility
net_wm_window_type_splash = _openbox.Property_net_wm_window_type_splash
net_wm_window_type_dialog = _openbox.Property_net_wm_window_type_dialog
net_wm_window_type_normal = _openbox.Property_net_wm_window_type_normal
net_wm_moveresize_size_topleft = _openbox.Property_net_wm_moveresize_size_topleft
net_wm_moveresize_size_topright = _openbox.Property_net_wm_moveresize_size_topright
net_wm_moveresize_size_bottomleft = _openbox.Property_net_wm_moveresize_size_bottomleft
net_wm_moveresize_size_bottomright = _openbox.Property_net_wm_moveresize_size_bottomright
net_wm_moveresize_move = _openbox.Property_net_wm_moveresize_move
net_wm_action_move = _openbox.Property_net_wm_action_move
net_wm_action_resize = _openbox.Property_net_wm_action_resize
net_wm_action_shade = _openbox.Property_net_wm_action_shade
net_wm_action_maximize_horz = _openbox.Property_net_wm_action_maximize_horz
net_wm_action_maximize_vert = _openbox.Property_net_wm_action_maximize_vert
net_wm_action_change_desktop = _openbox.Property_net_wm_action_change_desktop
net_wm_action_close = _openbox.Property_net_wm_action_close
net_wm_state_modal = _openbox.Property_net_wm_state_modal
net_wm_state_sticky = _openbox.Property_net_wm_state_sticky
net_wm_state_maximized_vert = _openbox.Property_net_wm_state_maximized_vert
net_wm_state_maximized_horz = _openbox.Property_net_wm_state_maximized_horz
net_wm_state_shaded = _openbox.Property_net_wm_state_shaded
net_wm_state_skip_taskbar = _openbox.Property_net_wm_state_skip_taskbar
net_wm_state_skip_pager = _openbox.Property_net_wm_state_skip_pager
net_wm_state_hidden = _openbox.Property_net_wm_state_hidden
net_wm_state_fullscreen = _openbox.Property_net_wm_state_fullscreen
net_wm_state_above = _openbox.Property_net_wm_state_above
net_wm_state_below = _openbox.Property_net_wm_state_below
kde_net_system_tray_windows = _openbox.Property_kde_net_system_tray_windows
kde_net_wm_system_tray_window_for = _openbox.Property_kde_net_wm_system_tray_window_for
kde_net_wm_window_type_override = _openbox.Property_kde_net_wm_window_type_override
NUM_ATOMS = _openbox.Property_NUM_ATOMS
ascii = _openbox.Property_ascii ascii = _openbox.Property_ascii
utf8 = _openbox.Property_utf8 utf8 = _openbox.Property_utf8
NUM_STRING_TYPE = _openbox.Property_NUM_STRING_TYPE NUM_STRING_TYPE = _openbox.Property_NUM_STRING_TYPE
def __init__(self,*args): __swig_getmethods__["initialize"] = lambda x: _openbox.Property_initialize
self.this = apply(_openbox.new_Property,args) if _newclass:initialize = staticmethod(_openbox.Property_initialize)
self.thisown = 1 __swig_getmethods__["set"] = lambda x: _openbox.Property_set
def __del__(self, destroy= _openbox.delete_Property): if _newclass:set = staticmethod(_openbox.Property_set)
try: __swig_getmethods__["set"] = lambda x: _openbox.Property_set
if self.thisown: destroy(self) if _newclass:set = staticmethod(_openbox.Property_set)
except: pass __swig_getmethods__["set"] = lambda x: _openbox.Property_set
def set(*args): return apply(_openbox.Property_set,args) if _newclass:set = staticmethod(_openbox.Property_set)
def get(*args): return apply(_openbox.Property_get,args) __swig_getmethods__["set"] = lambda x: _openbox.Property_set
def erase(*args): return apply(_openbox.Property_erase,args) if _newclass:set = staticmethod(_openbox.Property_set)
def atom(*args): return apply(_openbox.Property_atom,args) __swig_getmethods__["get"] = lambda x: _openbox.Property_get
if _newclass:get = staticmethod(_openbox.Property_get)
__swig_getmethods__["get"] = lambda x: _openbox.Property_get
if _newclass:get = staticmethod(_openbox.Property_get)
__swig_getmethods__["get"] = lambda x: _openbox.Property_get
if _newclass:get = staticmethod(_openbox.Property_get)
__swig_getmethods__["get"] = lambda x: _openbox.Property_get
if _newclass:get = staticmethod(_openbox.Property_get)
__swig_getmethods__["erase"] = lambda x: _openbox.Property_erase
if _newclass:erase = staticmethod(_openbox.Property_erase)
def __init__(self): raise RuntimeError, "No constructor defined"
def __repr__(self): def __repr__(self):
return "<C Property instance at %s>" % (self.this,) return "<C Property instance at %s>" % (self.this,)
@ -213,6 +377,14 @@ class PropertyPtr(Property):
if not hasattr(self,"thisown"): self.thisown = 0 if not hasattr(self,"thisown"): self.thisown = 0
self.__class__ = Property self.__class__ = Property
_openbox.Property_swigregister(PropertyPtr) _openbox.Property_swigregister(PropertyPtr)
Property_initialize = _openbox.Property_initialize
Property_set = _openbox.Property_set
Property_get = _openbox.Property_get
Property_erase = _openbox.Property_erase
class Rect(_object): class Rect(_object):
__swig_setmethods__ = {} __swig_setmethods__ = {}
@ -446,7 +618,6 @@ class Openbox(EventDispatcher,EventHandler):
State_Normal = _openbox.Openbox_State_Normal State_Normal = _openbox.Openbox_State_Normal
State_Exiting = _openbox.Openbox_State_Exiting State_Exiting = _openbox.Openbox_State_Exiting
def state(*args): return apply(_openbox.Openbox_state,args) def state(*args): return apply(_openbox.Openbox_state,args)
def property(*args): return apply(_openbox.Openbox_property,args)
def actions(*args): return apply(_openbox.Openbox_actions,args) def actions(*args): return apply(_openbox.Openbox_actions,args)
def bindings(*args): return apply(_openbox.Openbox_bindings,args) def bindings(*args): return apply(_openbox.Openbox_bindings,args)
def screen(*args): return apply(_openbox.Openbox_screen,args) def screen(*args): return apply(_openbox.Openbox_screen,args)

File diff suppressed because it is too large Load diff

View file

@ -192,21 +192,14 @@ void set_reset_key(const std::string &key)
ob::openbox->bindings()->setResetKey(key); ob::openbox->bindings()->setResetKey(key);
} }
PyObject *send_client_msg(Window target, int type, Window about, PyObject *send_client_msg(Window target, Atom type, Window about,
long data, long data1, long data2, long data, long data1, long data2,
long data3, long data4) long data3, long data4)
{ {
if (type < 0 || type >= otk::Property::NUM_ATOMS) {
PyErr_SetString(PyExc_TypeError,
"Invalid atom type. Must be from otk::Property::Atoms");
return NULL;
}
XEvent e; XEvent e;
e.xclient.type = ClientMessage; e.xclient.type = ClientMessage;
e.xclient.format = 32; e.xclient.format = 32;
e.xclient.message_type = e.xclient.message_type = type;
openbox->property()->atom((otk::Property::Atoms)type);
e.xclient.window = about; e.xclient.window = about;
e.xclient.data.l[0] = data; e.xclient.data.l[0] = data;
e.xclient.data.l[1] = data1; e.xclient.data.l[1] = data1;

View file

@ -187,7 +187,7 @@ PyObject *ebind(ob::EventAction action, PyObject *func);
void set_reset_key(const std::string &key); void set_reset_key(const std::string &key);
PyObject *send_client_msg(Window target, int type, Window about, PyObject *send_client_msg(Window target, Atom type, Window about,
long data, long data1 = 0, long data2 = 0, long data, long data1 = 0, long data2 = 0,
long data3 = 0, long data4 = 0); long data3 = 0, long data4 = 0);
} }

View file

@ -29,6 +29,7 @@ extern "C" {
#include "bindings.hh" #include "bindings.hh"
#include "python.hh" #include "python.hh"
#include "otk/display.hh" #include "otk/display.hh"
#include "otk/property.hh"
#include <vector> #include <vector>
#include <algorithm> #include <algorithm>
@ -65,10 +66,8 @@ Screen::Screen(int screen)
printf(_("Managing screen %d: visual 0x%lx, depth %d\n"), printf(_("Managing screen %d: visual 0x%lx, depth %d\n"),
_number, XVisualIDFromVisual(_info->visual()), _info->depth()); _number, XVisualIDFromVisual(_info->visual()), _info->depth());
openbox->property()->set(_info->rootWindow(), otk::Property::set(_info->rootWindow(), otk::Property::atoms.openbox_pid,
otk::Property::openbox_pid, otk::Property::atoms.cardinal, (unsigned long) getpid());
otk::Property::Atom_Cardinal,
(unsigned long) getpid());
// set the mouse cursor for the root window (the default cursor) // set the mouse cursor for the root window (the default cursor)
XDefineCursor(**otk::display, _info->rootWindow(), XDefineCursor(**otk::display, _info->rootWindow(),
@ -100,18 +99,16 @@ Screen::Screen(int screen)
// Set the netwm properties for geometry // Set the netwm properties for geometry
unsigned long geometry[] = { _info->width(), unsigned long geometry[] = { _info->width(),
_info->height() }; _info->height() };
openbox->property()->set(_info->rootWindow(), otk::Property::set(_info->rootWindow(),
otk::Property::net_desktop_geometry, otk::Property::atoms.net_desktop_geometry,
otk::Property::Atom_Cardinal, otk::Property::atoms.cardinal, geometry, 2);
geometry, 2);
// Set the net_desktop_names property // Set the net_desktop_names property
std::vector<otk::ustring> names; std::vector<otk::ustring> names;
python_get_stringlist("desktop_names", &names); python_get_stringlist("desktop_names", &names);
openbox->property()->set(_info->rootWindow(), otk::Property::set(_info->rootWindow(),
otk::Property::net_desktop_names, otk::Property::atoms.net_desktop_names,
otk::Property::utf8, otk::Property::utf8, names);
names);
// the above set() will cause the updateDesktopNames to fire right away so // the above set() will cause the updateDesktopNames to fire right away so
// we have a list of desktop names // we have a list of desktop names
@ -283,91 +280,80 @@ void Screen::changeSupportedAtoms()
0, 0, 1, 1, 0, 0, 0); 0, 0, 1, 1, 0, 0, 0);
// set supporting window // set supporting window
openbox->property()->set(_info->rootWindow(), otk::Property::set(_info->rootWindow(),
otk::Property::net_supporting_wm_check, otk::Property::atoms.net_supporting_wm_check,
otk::Property::Atom_Window, otk::Property::atoms.window, _supportwindow);
_supportwindow);
//set properties on the supporting window //set properties on the supporting window
openbox->property()->set(_supportwindow, otk::Property::set(_supportwindow, otk::Property::atoms.net_wm_name,
otk::Property::net_wm_name, otk::Property::utf8, "Openbox");
otk::Property::utf8, otk::Property::set(_supportwindow,
"Openbox"); otk::Property::atoms.net_supporting_wm_check,
openbox->property()->set(_supportwindow, otk::Property::atoms.window, _supportwindow);
otk::Property::net_supporting_wm_check,
otk::Property::Atom_Window,
_supportwindow);
Atom supported[] = { Atom supported[] = {
otk::Property::net_current_desktop, otk::Property::atoms.net_current_desktop,
otk::Property::net_number_of_desktops, otk::Property::atoms.net_number_of_desktops,
otk::Property::net_desktop_geometry, otk::Property::atoms.net_desktop_geometry,
otk::Property::net_desktop_viewport, otk::Property::atoms.net_desktop_viewport,
otk::Property::net_active_window, otk::Property::atoms.net_active_window,
otk::Property::net_workarea, otk::Property::atoms.net_workarea,
otk::Property::net_client_list, otk::Property::atoms.net_client_list,
otk::Property::net_client_list_stacking, otk::Property::atoms.net_client_list_stacking,
otk::Property::net_desktop_names, otk::Property::atoms.net_desktop_names,
otk::Property::net_close_window, otk::Property::atoms.net_close_window,
otk::Property::net_wm_name, otk::Property::atoms.net_wm_name,
otk::Property::net_wm_visible_name, otk::Property::atoms.net_wm_visible_name,
otk::Property::net_wm_icon_name, otk::Property::atoms.net_wm_icon_name,
otk::Property::net_wm_visible_icon_name, otk::Property::atoms.net_wm_visible_icon_name,
/* /*
otk::Property::net_wm_desktop, otk::Property::atoms.net_wm_desktop,
*/ */
otk::Property::net_wm_strut, otk::Property::atoms.net_wm_strut,
otk::Property::net_wm_window_type, otk::Property::atoms.net_wm_window_type,
otk::Property::net_wm_window_type_desktop, otk::Property::atoms.net_wm_window_type_desktop,
otk::Property::net_wm_window_type_dock, otk::Property::atoms.net_wm_window_type_dock,
otk::Property::net_wm_window_type_toolbar, otk::Property::atoms.net_wm_window_type_toolbar,
otk::Property::net_wm_window_type_menu, otk::Property::atoms.net_wm_window_type_menu,
otk::Property::net_wm_window_type_utility, otk::Property::atoms.net_wm_window_type_utility,
otk::Property::net_wm_window_type_splash, otk::Property::atoms.net_wm_window_type_splash,
otk::Property::net_wm_window_type_dialog, otk::Property::atoms.net_wm_window_type_dialog,
otk::Property::net_wm_window_type_normal, otk::Property::atoms.net_wm_window_type_normal,
/* /*
otk::Property::net_wm_moveresize, otk::Property::atoms.net_wm_moveresize,
otk::Property::net_wm_moveresize_size_topleft, otk::Property::atoms.net_wm_moveresize_size_topleft,
otk::Property::net_wm_moveresize_size_topright, otk::Property::atoms.net_wm_moveresize_size_topright,
otk::Property::net_wm_moveresize_size_bottomleft, otk::Property::atoms.net_wm_moveresize_size_bottomleft,
otk::Property::net_wm_moveresize_size_bottomright, otk::Property::atoms.net_wm_moveresize_size_bottomright,
otk::Property::net_wm_moveresize_move, otk::Property::atoms.net_wm_moveresize_move,
*/ */
/* /*
otk::Property::net_wm_allowed_actions, otk::Property::atoms.net_wm_allowed_actions,
otk::Property::net_wm_action_move, otk::Property::atoms.net_wm_action_move,
otk::Property::net_wm_action_resize, otk::Property::atoms.net_wm_action_resize,
otk::Property::net_wm_action_shade, otk::Property::atoms.net_wm_action_shade,
otk::Property::net_wm_action_maximize_horz, otk::Property::atoms.net_wm_action_maximize_horz,
otk::Property::net_wm_action_maximize_vert, otk::Property::atoms.net_wm_action_maximize_vert,
otk::Property::net_wm_action_change_desktop, otk::Property::atoms.net_wm_action_change_desktop,
otk::Property::net_wm_action_close, otk::Property::atoms.net_wm_action_close,
*/ */
otk::Property::net_wm_state, otk::Property::atoms.net_wm_state,
otk::Property::net_wm_state_modal, otk::Property::atoms.net_wm_state_modal,
otk::Property::net_wm_state_maximized_vert, otk::Property::atoms.net_wm_state_maximized_vert,
otk::Property::net_wm_state_maximized_horz, otk::Property::atoms.net_wm_state_maximized_horz,
otk::Property::net_wm_state_shaded, otk::Property::atoms.net_wm_state_shaded,
otk::Property::net_wm_state_skip_taskbar, otk::Property::atoms.net_wm_state_skip_taskbar,
otk::Property::net_wm_state_skip_pager, otk::Property::atoms.net_wm_state_skip_pager,
otk::Property::net_wm_state_hidden, otk::Property::atoms.net_wm_state_hidden,
otk::Property::net_wm_state_fullscreen, otk::Property::atoms.net_wm_state_fullscreen,
otk::Property::net_wm_state_above, otk::Property::atoms.net_wm_state_above,
otk::Property::net_wm_state_below, otk::Property::atoms.net_wm_state_below,
}; };
const int num_supported = sizeof(supported)/sizeof(Atom); const int num_supported = sizeof(supported)/sizeof(Atom);
// convert to the atom values otk::Property::set(_info->rootWindow(), otk::Property::atoms.net_supported,
for (int i = 0; i < num_supported; ++i) otk::Property::atoms.atom, supported, num_supported);
supported[i] =
openbox->property()->atom((otk::Property::Atoms)supported[i]);
openbox->property()->set(_info->rootWindow(),
otk::Property::net_supported,
otk::Property::Atom_Atom,
supported, num_supported);
} }
@ -389,10 +375,8 @@ void Screen::changeClientList()
} else } else
windows = (Window*) 0; windows = (Window*) 0;
openbox->property()->set(_info->rootWindow(), otk::Property::set(_info->rootWindow(), otk::Property::atoms.net_client_list,
otk::Property::net_client_list, otk::Property::atoms.window, windows, size);
otk::Property::Atom_Window,
windows, size);
if (size) if (size)
delete [] windows; delete [] windows;
@ -422,10 +406,9 @@ void Screen::changeStackingList()
} else } else
windows = (Window*) 0; windows = (Window*) 0;
openbox->property()->set(_info->rootWindow(), otk::Property::set(_info->rootWindow(),
otk::Property::net_client_list_stacking, otk::Property::atoms.net_client_list_stacking,
otk::Property::Atom_Window, otk::Property::atoms.window, windows, size);
windows, size);
if (size) if (size)
delete [] windows; delete [] windows;
@ -441,10 +424,8 @@ void Screen::changeWorkArea() {
dims[(i * 4) + 2] = _area.width(); dims[(i * 4) + 2] = _area.width();
dims[(i * 4) + 3] = _area.height(); dims[(i * 4) + 3] = _area.height();
} }
openbox->property()->set(_info->rootWindow(), otk::Property::set(_info->rootWindow(), otk::Property::atoms.net_workarea,
otk::Property::net_workarea, otk::Property::atoms.cardinal, dims, 4 * _num_desktops);
otk::Property::Atom_Cardinal,
dims, 4 * _num_desktops);
delete [] dims; delete [] dims;
} }
@ -645,10 +626,9 @@ void Screen::changeDesktop(long desktop)
long old = _desktop; long old = _desktop;
_desktop = desktop; _desktop = desktop;
openbox->property()->set(_info->rootWindow(), otk::Property::set(_info->rootWindow(),
otk::Property::net_current_desktop, otk::Property::atoms.net_current_desktop,
otk::Property::Atom_Cardinal, otk::Property::atoms.cardinal, _desktop);
_desktop);
if (old == _desktop) return; if (old == _desktop) return;
@ -675,18 +655,17 @@ void Screen::changeNumDesktops(long num)
// XXX: move windows on desktops that will no longer exist! // XXX: move windows on desktops that will no longer exist!
_num_desktops = num; _num_desktops = num;
openbox->property()->set(_info->rootWindow(), otk::Property::set(_info->rootWindow(),
otk::Property::net_number_of_desktops, otk::Property::atoms.net_number_of_desktops,
otk::Property::Atom_Cardinal, otk::Property::atoms.cardinal, _num_desktops);
_num_desktops);
// set the viewport hint // set the viewport hint
unsigned long *viewport = new unsigned long[_num_desktops * 2]; unsigned long *viewport = new unsigned long[_num_desktops * 2];
memset(viewport, 0, sizeof(unsigned long) * _num_desktops * 2); memset(viewport, 0, sizeof(unsigned long) * _num_desktops * 2);
openbox->property()->set(_info->rootWindow(), otk::Property::set(_info->rootWindow(),
otk::Property::net_desktop_viewport, otk::Property::atoms.net_desktop_viewport,
otk::Property::Atom_Cardinal, otk::Property::atoms.cardinal,
viewport, _num_desktops * 2); viewport, _num_desktops * 2);
delete [] viewport; delete [] viewport;
// update the work area hint // update the work area hint
@ -696,13 +675,11 @@ void Screen::changeNumDesktops(long num)
void Screen::updateDesktopNames() void Screen::updateDesktopNames()
{ {
const otk::Property *property = openbox->property();
unsigned long num = (unsigned) -1; unsigned long num = (unsigned) -1;
if (!property->get(_info->rootWindow(), if (!otk::Property::get(_info->rootWindow(),
otk::Property::net_desktop_names, otk::Property::atoms.net_desktop_names,
otk::Property::utf8, &num, &_desktop_names)) otk::Property::utf8, &num, &_desktop_names))
_desktop_names.clear(); _desktop_names.clear();
while ((long)_desktop_names.size() < _num_desktops) while ((long)_desktop_names.size() < _num_desktops)
_desktop_names.push_back("Unnamed"); _desktop_names.push_back("Unnamed");
@ -715,12 +692,11 @@ void Screen::setDesktopName(long i, const otk::ustring &name)
if (i >= _num_desktops) return; if (i >= _num_desktops) return;
const otk::Property *property = openbox->property();
otk::Property::StringVect newnames = _desktop_names; otk::Property::StringVect newnames = _desktop_names;
newnames[i] = name; newnames[i] = name;
property->set(_info->rootWindow(), otk::Property::net_desktop_names, otk::Property::set(_info->rootWindow(),
otk::Property::utf8, newnames); otk::Property::atoms.net_desktop_names,
otk::Property::utf8, newnames);
} }
@ -728,8 +704,6 @@ void Screen::propertyHandler(const XPropertyEvent &e)
{ {
otk::EventHandler::propertyHandler(e); otk::EventHandler::propertyHandler(e);
const otk::Property *property = openbox->property();
// compress changes to a single property into a single change // compress changes to a single property into a single change
XEvent ce; XEvent ce;
while (XCheckTypedEvent(**otk::display, e.type, &ce)) { while (XCheckTypedEvent(**otk::display, e.type, &ce)) {
@ -741,7 +715,7 @@ void Screen::propertyHandler(const XPropertyEvent &e)
} }
} }
if (e.atom == property->atom(otk::Property::net_desktop_names)) if (e.atom == otk::Property::atoms.net_desktop_names)
updateDesktopNames(); updateDesktopNames();
} }
@ -752,12 +726,9 @@ void Screen::clientMessageHandler(const XClientMessageEvent &e)
if (e.format != 32) return; if (e.format != 32) return;
const otk::Property *property = openbox->property(); if (e.message_type == otk::Property::atoms.net_current_desktop) {
if (e.message_type == property->atom(otk::Property::net_current_desktop)) {
changeDesktop(e.data.l[0]); changeDesktop(e.data.l[0]);
} else if (e.message_type == } else if (e.message_type == otk::Property::atoms.net_number_of_desktops) {
property->atom(otk::Property::net_number_of_desktops)) {
changeNumDesktops(e.data.l[0]); changeNumDesktops(e.data.l[0]);
} }
// XXX: so many client messages to handle here! ..or not.. they go to clients // XXX: so many client messages to handle here! ..or not.. they go to clients
@ -783,8 +754,7 @@ void Screen::mapRequestHandler(const XMapRequestEvent &e)
// send a net_active_window message // send a net_active_window message
XEvent ce; XEvent ce;
ce.xclient.type = ClientMessage; ce.xclient.type = ClientMessage;
ce.xclient.message_type = ce.xclient.message_type = otk::Property::atoms.net_active_window;
openbox->property()->atom(otk::Property::net_active_window);
ce.xclient.display = **otk::display; ce.xclient.display = **otk::display;
ce.xclient.window = c->window(); ce.xclient.window = c->window();
ce.xclient.format = 32; ce.xclient.format = 32;