From 641bc819d1b399d2313e3328d111dd70777ecfea Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Tue, 5 Nov 2002 07:48:26 +0000 Subject: convert XAtom to OBAtom --- src/Makefile.am | 2 +- src/atom.cc | 514 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/atom.hh | 218 +++++++++++++++++++++++ src/bbwindow.cc | 148 ++++++++-------- src/bbwindow.hh | 2 +- src/blackbox.cc | 80 ++++----- src/blackbox.hh | 6 +- src/openbox.hh | 3 +- src/screen.cc | 64 +++---- src/screen.hh | 4 +- src/workspace.cc | 18 +- src/workspace.hh | 4 +- src/xatom.cc | 515 ------------------------------------------------------- src/xatom.hh | 219 ----------------------- 14 files changed, 898 insertions(+), 899 deletions(-) create mode 100644 src/atom.cc create mode 100644 src/atom.hh delete mode 100644 src/xatom.cc delete mode 100644 src/xatom.hh (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 19306b3f..e20fd953 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -16,7 +16,7 @@ bin_PROGRAMS= openbox openbox_LDADD=../otk/libotk.a @LIBINTL@ openbox_SOURCES= configuration.cc screen.cc openbox.cc \ - util.cc bbwindow.cc workspace.cc xatom.cc blackbox.cc \ + util.cc bbwindow.cc workspace.cc atom.cc blackbox.cc \ main.cc xeventhandler.cc MAINTAINERCLEANFILES= Makefile.in diff --git a/src/atom.cc b/src/atom.cc new file mode 100644 index 00000000..17278840 --- /dev/null +++ b/src/atom.cc @@ -0,0 +1,514 @@ +// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*- + +#ifdef HAVE_CONFIG_H +# include "../config.h" +#endif // HAVE_CONFIG_H + +extern "C" { +#include +} + +#include "atom.hh" +#include "screen.hh" +#include "util.hh" +#include "otk/display.hh" + +namespace ob { + +OBAtom::OBAtom() { + // make sure asserts fire if there is a problem + memset(_atoms, 0, sizeof(_atoms)); + + _atoms[cardinal] = XA_CARDINAL; + _atoms[window] = XA_WINDOW; + _atoms[pixmap] = XA_PIXMAP; + _atoms[atom] = XA_ATOM; + _atoms[string] = XA_STRING; + _atoms[utf8_string] = create("UTF8_STRING"); + +#ifdef HAVE_GETPID + _atoms[blackbox_pid] = create("_BLACKBOX_PID"); +#endif // HAVE_GETPID + + _atoms[wm_colormap_windows] = create("WM_COLORMAP_WINDOWS"); + _atoms[wm_protocols] = create("WM_PROTOCOLS"); + _atoms[wm_state] = create("WM_STATE"); + _atoms[wm_change_state] = create("WM_CHANGE_STATE"); + _atoms[wm_delete_window] = create("WM_DELETE_WINDOW"); + _atoms[wm_take_focus] = create("WM_TAKE_FOCUS"); + _atoms[wm_name] = create("WM_NAME"); + _atoms[wm_icon_name] = create("WM_ICON_NAME"); + _atoms[wm_class] = create("WM_CLASS"); + _atoms[motif_wm_hints] = create("_MOTIF_WM_HINTS"); + _atoms[blackbox_hints] = create("_BLACKBOX_HINTS"); + _atoms[blackbox_attributes] = create("_BLACKBOX_ATTRIBUTES"); + _atoms[blackbox_change_attributes] = create("_BLACKBOX_CHANGE_ATTRIBUTES"); + _atoms[blackbox_structure_messages] = create("_BLACKBOX_STRUCTURE_MESSAGES"); + _atoms[blackbox_notify_startup] = create("_BLACKBOX_NOTIFY_STARTUP"); + _atoms[blackbox_notify_window_add] = create("_BLACKBOX_NOTIFY_WINDOW_ADD"); + _atoms[blackbox_notify_window_del] = create("_BLACKBOX_NOTIFY_WINDOW_DEL"); + _atoms[blackbox_notify_current_workspace] = + create("_BLACKBOX_NOTIFY_CURRENT_WORKSPACE"); + _atoms[blackbox_notify_workspace_count] = + create("_BLACKBOX_NOTIFY_WORKSPACE_COUNT"); + _atoms[blackbox_notify_window_focus] = + create("_BLACKBOX_NOTIFY_WINDOW_FOCUS"); + _atoms[blackbox_notify_window_raise] = + create("_BLACKBOX_NOTIFY_WINDOW_RAISE"); + _atoms[blackbox_notify_window_lower] = + create("_BLACKBOX_NOTIFY_WINDOW_LOWER"); + + _atoms[blackbox_change_workspace] = create("_BLACKBOX_CHANGE_WORKSPACE"); + _atoms[blackbox_change_window_focus] = + create("_BLACKBOX_CHANGE_WINDOW_FOCUS"); + _atoms[blackbox_cycle_window_focus] = create("_BLACKBOX_CYCLE_WINDOW_FOCUS"); + + _atoms[openbox_show_root_menu] = create("_OPENBOX_SHOW_ROOT_MENU"); + _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"); + _atoms[net_wm_moveresize_size_topright] = + create("_NET_WM_MOVERESIZE_SIZE_TOPRIGHT"); + _atoms[net_wm_moveresize_size_bottomleft] = + create("_NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT"); + _atoms[net_wm_moveresize_size_bottomright] = + create("_NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT"); + _atoms[net_wm_moveresize_move] = + create("_NET_WM_MOVERESIZE_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_shade] = create("_NET_WM_ACTION_SHADE"); + _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_change_desktop] = + create("_NET_WM_ACTION_CHANGE_DESKTOP"); + _atoms[net_wm_action_close] = create("_NET_WM_ACTION_CLOSE"); + + _atoms[net_wm_state_modal] = create("_NET_WM_STATE_MODAL"); + _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_shaded] = create("_NET_WM_STATE_SHADED"); + _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_hidden] = create("_NET_WM_STATE_HIDDEN"); + _atoms[net_wm_state_fullscreen] = create("_NET_WM_STATE_FULLSCREEN"); + + _atoms[kde_net_system_tray_windows] = create("_KDE_NET_SYSTEM_TRAY_WINDOWS"); + _atoms[kde_net_wm_system_tray_window_for] = + create("_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR"); + _atoms[kde_net_wm_window_type_override] = + create("_KDE_NET_WM_WINDOW_TYPE_OVERRIDE"); +} + + +/* + * clean up the class' members + */ +OBAtom::~OBAtom() { + while (!_support_windows.empty()) { + // make sure we aren't fucking with this somewhere + assert(_support_windows.back() != None); + XDestroyWindow(otk::OBDisplay::display, _support_windows.back()); + _support_windows.pop_back(); + } +} + + +/* + * Returns an atom from the Xserver, creating it if necessary. + */ +Atom OBAtom::create(const char *name) const { + return XInternAtom(otk::OBDisplay::display, name, False); +} + + +/* + * Sets which atoms are supported for NETWM, by Openbox, on the root window. + */ +void OBAtom::setSupported(const otk::ScreenInfo *screen) { + Window root = screen->getRootWindow(); + + // create the netwm support window + Window w = XCreateSimpleWindow(otk::OBDisplay::display, root, 0, 0, 1, 1, 0, 0, 0); + assert(w != None); + _support_windows.push_back(w); + + // set supporting window + setValue(root, net_supporting_wm_check, window, w); + + //set properties on the supporting window + setValue(w, net_wm_name, utf8, "Openbox"); + setValue(w, net_supporting_wm_check, window, w); + + // we don't support any yet.. + // yes we do! + + Atom supported[] = { + _atoms[net_current_desktop], + _atoms[net_number_of_desktops], + _atoms[net_desktop_geometry], + _atoms[net_desktop_viewport], + _atoms[net_active_window], + _atoms[net_workarea], + _atoms[net_client_list], + _atoms[net_client_list_stacking], + _atoms[net_desktop_names], + _atoms[net_close_window], + _atoms[net_wm_name], + _atoms[net_wm_visible_name], + _atoms[net_wm_icon_name], + _atoms[net_wm_visible_icon_name], + _atoms[net_wm_desktop], + _atoms[net_wm_strut], + _atoms[net_wm_window_type], + _atoms[net_wm_window_type_desktop], + _atoms[net_wm_window_type_dock], + _atoms[net_wm_window_type_toolbar], + _atoms[net_wm_window_type_menu], + _atoms[net_wm_window_type_utility], + _atoms[net_wm_window_type_splash], + _atoms[net_wm_window_type_dialog], + _atoms[net_wm_window_type_normal], + _atoms[net_wm_moveresize], + _atoms[net_wm_moveresize_size_topleft], + _atoms[net_wm_moveresize_size_topright], + _atoms[net_wm_moveresize_size_bottomleft], + _atoms[net_wm_moveresize_size_bottomright], + _atoms[net_wm_moveresize_move], + _atoms[net_wm_allowed_actions], + _atoms[net_wm_action_move], + _atoms[net_wm_action_resize], + _atoms[net_wm_action_shade], + _atoms[net_wm_action_maximize_horz], + _atoms[net_wm_action_maximize_vert], + _atoms[net_wm_action_change_desktop], + _atoms[net_wm_action_close], + _atoms[net_wm_state], + _atoms[net_wm_state_modal], + _atoms[net_wm_state_maximized_vert], + _atoms[net_wm_state_maximized_horz], + _atoms[net_wm_state_shaded], + _atoms[net_wm_state_skip_taskbar], + _atoms[net_wm_state_skip_pager], + _atoms[net_wm_state_hidden], + _atoms[net_wm_state_fullscreen], + }; + const int num_supported = sizeof(supported)/sizeof(Atom); + + setValue(root, net_supported, atom, supported, num_supported); +} + + +/* + * Internal setValue. + * Sets a window property on a window, optionally appending to the existing + * value. + */ +void OBAtom::setValue(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(nelements == 0 || (nelements > 0 && data != (unsigned char *) 0)); + assert(size == 8 || size == 16 || size == 32); + XChangeProperty(otk::OBDisplay::display, win, atom, type, size, + (append ? PropModeAppend : PropModeReplace), + data, nelements); +} + + +/* + * Set a 32-bit property value on a window. + */ +void OBAtom::setValue(Window win, Atoms atom, Atoms type, + unsigned long value) const { + assert(atom >= 0 && atom < NUM_ATOMS); + assert(type >= 0 && type < NUM_ATOMS); + setValue(win, _atoms[atom], _atoms[type], + reinterpret_cast(&value), 32, 1, False); +} + + +/* + * Set an array of 32-bit properties value on a window. + */ +void OBAtom::setValue(Window win, Atoms atom, Atoms type, + unsigned long value[], int elements) const { + assert(atom >= 0 && atom < NUM_ATOMS); + assert(type >= 0 && type < NUM_ATOMS); + setValue(win, _atoms[atom], _atoms[type], + reinterpret_cast(value), 32, elements, False); +} + + +/* + * Set an string property value on a window. + */ +void OBAtom::setValue(Window win, Atoms atom, StringType type, + const std::string &value) const { + assert(atom >= 0 && atom < NUM_ATOMS); + assert(type >= 0 && type < NUM_STRING_TYPE); + + Atom t; + switch (type) { + case ansi: t = _atoms[string]; break; + case utf8: t = _atoms[utf8_string]; break; + default: assert(False); return; // unhandled StringType + } + setValue(win, _atoms[atom], t, + reinterpret_cast(const_cast(value.c_str())), + 8, value.size() + 1, False); // add 1 to the size to include the null +} + + +/* + * Set an array of string property values on a window. + */ +void OBAtom::setValue(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; + switch (type) { + case ansi: t = _atoms[string]; break; + case utf8: t = _atoms[utf8_string]; break; + default: assert(False); return; // unhandled StringType + } + + std::string value; + + StringVect::const_iterator it = strings.begin(); + const StringVect::const_iterator end = strings.end(); + for (; it != end; ++it) + value += *it + '\0'; + + setValue(win, _atoms[atom], t, + reinterpret_cast(const_cast(value.c_str())), + 8, value.size(), False); +} + + +/* + * Internal getValue function used by all of the typed getValue 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 OBAtom::getValue(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(size == 8 || size == 16 || size == 32); + assert(nelements > 0); + unsigned char *c_val = 0; // value alloc'd in Xlib, must be XFree()d + Atom ret_type; + int ret_size; + unsigned long ret_bytes; + int result; + unsigned long maxread = nelements; + bool ret = False; + + // try get the first element + result = XGetWindowProperty(otk::OBDisplay::display, win, atom, 0l, 1l, False, + AnyPropertyType, &ret_type, &ret_size, + &nelements, &ret_bytes, &c_val); + ret = (result == Success && ret_type == type && ret_size == size && + nelements > 0); + if (ret) { + if (ret_bytes == 0 || maxread <= nelements) { + // we got the whole property's value + *value = new unsigned char[nelements * size/8 + 1]; + memcpy(*value, c_val, nelements * size/8 + 1); + } else { + // get the entire property since it is larger than one long + XFree(c_val); + // the number of longs that need to be retreived to get the property's + // entire value. The last + 1 is the first long that we retrieved above. + int remain = (ret_bytes - 1)/sizeof(long) + 1 + 1; + if (remain > size/8 * (signed)maxread) // dont get more than the max + remain = size/8 * (signed)maxread; + result = XGetWindowProperty(otk::OBDisplay::display, win, atom, 0l, remain, False, type, + &ret_type, &ret_size, &nelements, &ret_bytes, + &c_val); + ret = (result == Success && ret_type == type && ret_size == size && + ret_bytes == 0); + /* + If the property has changed type/size, or has grown since our first + read of it, then stop here and try again. If it shrank, then this will + still work. + */ + if (! ret) + return getValue(win, atom, type, maxread, value, size); + + *value = new unsigned char[nelements * size/8 + 1]; + memcpy(*value, c_val, nelements * size/8 + 1); + } + } + if (c_val) XFree(c_val); + return ret; +} + + +/* + * Gets a 32-bit property's value from a window. + */ +bool OBAtom::getValue(Window win, Atoms atom, Atoms type, + unsigned long &nelements, + unsigned long **value) const { + assert(atom >= 0 && atom < NUM_ATOMS); + assert(type >= 0 && type < NUM_ATOMS); + return getValue(win, _atoms[atom], _atoms[type], nelements, + reinterpret_cast(value), 32); +} + + +/* + * Gets a single 32-bit property's value from a window. + */ +bool OBAtom::getValue(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 num = 1; + if (! getValue(win, _atoms[atom], _atoms[type], num, + reinterpret_cast(&temp), 32)) + return False; + value = temp[0]; + delete [] temp; + return True; +} + + +/* + * Gets an string property's value from a window. + */ +bool OBAtom::getValue(Window win, Atoms atom, StringType type, + std::string &value) const { + unsigned long n = 1; + StringVect s; + if (getValue(win, atom, type, n, s)) { + value = s[0]; + return True; + } + return False; +} + + +bool OBAtom::getValue(Window win, Atoms atom, StringType type, + 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); + + Atom t; + switch (type) { + case ansi: t = _atoms[string]; break; + case utf8: t = _atoms[utf8_string]; break; + default: assert(False); return False; // unhandled StringType + } + + unsigned char *value; + unsigned long elements = (unsigned) -1; + if (!getValue(win, _atoms[atom], t, elements, &value, 8) || elements < 1) + return False; + + std::string s(reinterpret_cast(value), elements); + delete [] value; + + std::string::const_iterator it = s.begin(), end = s.end(); + unsigned long num = 0; + while(num < nelements) { + std::string::const_iterator tmp = it; // current string.begin() + it = std::find(tmp, end, '\0'); // look for null between tmp and end + strings.push_back(std::string(tmp, it)); // s[tmp:it) + ++num; + if (it == end) break; + ++it; + if (it == end) break; + } + + nelements = num; + + return True; +} + + +/* + * Removes a property entirely from a window. + */ +void OBAtom::eraseValue(Window win, Atoms atom) const { + assert(atom >= 0 && atom < NUM_ATOMS); + XDeleteProperty(otk::OBDisplay::display, win, _atoms[atom]); +} + + +void OBAtom::sendClientMessage(Window target, Atoms type, Window about, + long data, long data1, long data2, + long data3, long data4) const { + assert(atom >= 0 && atom < NUM_ATOMS); + assert(target != None); + + XEvent e; + e.xclient.type = ClientMessage; + e.xclient.format = 32; + e.xclient.message_type = _atoms[type]; + e.xclient.window = about; + e.xclient.data.l[0] = data; + e.xclient.data.l[1] = data1; + e.xclient.data.l[2] = data2; + e.xclient.data.l[3] = data3; + e.xclient.data.l[4] = data4; + + XSendEvent(otk::OBDisplay::display, target, False, + SubstructureRedirectMask | SubstructureNotifyMask, + &e); +} + +} diff --git a/src/atom.hh b/src/atom.hh new file mode 100644 index 00000000..fabe2b23 --- /dev/null +++ b/src/atom.hh @@ -0,0 +1,218 @@ +// OBAtom.h for Openbox +#ifndef __atom_hh +#define __atom_hh + +/*! @file xatom.hh + @brief Provides access to atoms on the display +*/ + +extern "C" { +#include +#include + +#include +} + +#include +#include + +#include "otk/screeninfo.hh" + +namespace ob { + +class OBAtom { +public: + enum Atoms { + // types + cardinal, + window, + pixmap, + atom, + string, + utf8_string, + +#ifdef HAVE_GETPID + blackbox_pid, +#endif // HAVE_GETPID + + // 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, + 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_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, + + kde_net_system_tray_windows, + kde_net_wm_system_tray_window_for, + kde_net_wm_window_type_override, + + // constant for how many atoms exist in the enumerator + NUM_ATOMS + }; + + enum StringType { + ansi, + utf8, + NUM_STRING_TYPE + }; + +private: + typedef std::vector SupportWindows; + + // windows used to specify support for NETWM + SupportWindows _support_windows; + Atom _atoms[NUM_ATOMS]; + + Atom create(const char *name) const; + + void setValue(Window win, Atom atom, Atom type, unsigned char *data, + int size, int nelements, bool append) const; + bool getValue(Window win, Atom atom, Atom type, + unsigned long &nelements, unsigned char **value, + int size) const; + + // no copying!! + OBAtom(const OBAtom &); + OBAtom& operator=(const OBAtom&); + +public: + typedef std::vector StringVect; + + OBAtom(); + virtual ~OBAtom(); + + // setup support on a screen, each screen should call this once in its + // constructor. + void setSupported(const otk::ScreenInfo *screen); + + void setValue(Window win, Atoms atom, Atoms type, unsigned long value) const; + void setValue(Window win, Atoms atom, Atoms type, + unsigned long value[], int elements) const; + void setValue(Window win, Atoms atom, StringType type, + const std::string &value) const; + void setValue(Window win, Atoms atom, StringType type, + const StringVect &strings) const; + + // the 'value' is allocated inside the function and + // delete [] value needs to be called when you are done with it. + // the 'value' array returned is null terminated, and has 'nelements' + // elements in it plus the null. + // nelements must be set to the maximum number of elements to read from + // the property. + bool getValue(Window win, Atoms atom, Atoms type, + unsigned long &nelements, unsigned long **value) const; + bool getValue(Window win, Atoms atom, Atoms type, unsigned long &value) const; + bool getValue(Window win, Atoms atom, StringType type, + std::string &value) const; + bool getValue(Window win, Atoms atom, StringType type, + unsigned long &nelements, StringVect &strings) const; + + void eraseValue(Window win, Atoms atom) const; + + // sends a client message a window + void sendClientMessage(Window target, Atoms type, Window about, + long data = 0, long data1 = 0, long data2 = 0, + long data3 = 0, long data4 = 0) const; + + // temporary function!! remove when not used in blackbox.hh anymore!! + inline Atom getAtom(Atoms a) + { assert(a >= 0 && a < NUM_ATOMS); Atom ret = _atoms[a]; + assert(ret != 0); return ret; } +}; + +} + +#endif // __atom_hh diff --git a/src/bbwindow.cc b/src/bbwindow.cc index 64a6b25a..45a4bd4d 100644 --- a/src/bbwindow.cc +++ b/src/bbwindow.cc @@ -1049,7 +1049,7 @@ void BlackboxWindow::positionWindows(void) { void BlackboxWindow::updateStrut(void) { unsigned long num = 4; unsigned long *data; - if (! xatom->getValue(client.window, XAtom::net_wm_strut, XAtom::cardinal, + if (! xatom->getValue(client.window, OBAtom::net_wm_strut, OBAtom::cardinal, num, &data)) return; @@ -1071,27 +1071,27 @@ bool BlackboxWindow::getWindowType(void) { unsigned long *val; unsigned long num = (unsigned) -1; - if (xatom->getValue(client.window, XAtom::net_wm_window_type, XAtom::atom, + if (xatom->getValue(client.window, OBAtom::net_wm_window_type, OBAtom::atom, num, &val)) { for (unsigned long i = 0; i < num; ++i) { - if (val[i] == xatom->getAtom(XAtom::net_wm_window_type_desktop)) + if (val[i] == xatom->getAtom(OBAtom::net_wm_window_type_desktop)) window_type = Type_Desktop; - else if (val[i] == xatom->getAtom(XAtom::net_wm_window_type_dock)) + else if (val[i] == xatom->getAtom(OBAtom::net_wm_window_type_dock)) window_type = Type_Dock; - else if (val[i] == xatom->getAtom(XAtom::net_wm_window_type_toolbar)) + else if (val[i] == xatom->getAtom(OBAtom::net_wm_window_type_toolbar)) window_type = Type_Toolbar; - else if (val[i] == xatom->getAtom(XAtom::net_wm_window_type_menu)) + else if (val[i] == xatom->getAtom(OBAtom::net_wm_window_type_menu)) window_type = Type_Menu; - else if (val[i] == xatom->getAtom(XAtom::net_wm_window_type_utility)) + else if (val[i] == xatom->getAtom(OBAtom::net_wm_window_type_utility)) window_type = Type_Utility; - else if (val[i] == xatom->getAtom(XAtom::net_wm_window_type_splash)) + else if (val[i] == xatom->getAtom(OBAtom::net_wm_window_type_splash)) window_type = Type_Splash; - else if (val[i] == xatom->getAtom(XAtom::net_wm_window_type_dialog)) + else if (val[i] == xatom->getAtom(OBAtom::net_wm_window_type_dialog)) window_type = Type_Dialog; - else if (val[i] == xatom->getAtom(XAtom::net_wm_window_type_normal)) + else if (val[i] == xatom->getAtom(OBAtom::net_wm_window_type_normal)) window_type = Type_Normal; else if (val[i] == - xatom->getAtom(XAtom::kde_net_wm_window_type_override)) + xatom->getAtom(OBAtom::kde_net_wm_window_type_override)) mwm_decorations = 0; // prevent this window from getting any decor } delete val; @@ -1115,21 +1115,21 @@ bool BlackboxWindow::getWindowType(void) { void BlackboxWindow::getWMName(void) { - if (xatom->getValue(client.window, XAtom::net_wm_name, - XAtom::utf8, client.title) && + if (xatom->getValue(client.window, OBAtom::net_wm_name, + OBAtom::utf8, client.title) && !client.title.empty()) { - xatom->eraseValue(client.window, XAtom::net_wm_visible_name); + xatom->eraseValue(client.window, OBAtom::net_wm_visible_name); return; } //fall through to using WM_NAME - if (xatom->getValue(client.window, XAtom::wm_name, XAtom::ansi, client.title) + if (xatom->getValue(client.window, OBAtom::wm_name, OBAtom::ansi, client.title) && !client.title.empty()) { - xatom->eraseValue(client.window, XAtom::net_wm_visible_name); + xatom->eraseValue(client.window, OBAtom::net_wm_visible_name); return; } // fall back to an internal default client.title = "Unnamed"; - xatom->setValue(client.window, XAtom::net_wm_visible_name, XAtom::utf8, + xatom->setValue(client.window, OBAtom::net_wm_visible_name, OBAtom::utf8, client.title); #ifdef DEBUG_WITH_ID @@ -1143,22 +1143,22 @@ void BlackboxWindow::getWMName(void) { void BlackboxWindow::getWMIconName(void) { - if (xatom->getValue(client.window, XAtom::net_wm_icon_name, - XAtom::utf8, client.icon_title) && + if (xatom->getValue(client.window, OBAtom::net_wm_icon_name, + OBAtom::utf8, client.icon_title) && !client.icon_title.empty()) { - xatom->eraseValue(client.window, XAtom::net_wm_visible_icon_name); + xatom->eraseValue(client.window, OBAtom::net_wm_visible_icon_name); return; } //fall through to using WM_ICON_NAME - if (xatom->getValue(client.window, XAtom::wm_icon_name, XAtom::ansi, + if (xatom->getValue(client.window, OBAtom::wm_icon_name, OBAtom::ansi, client.icon_title) && !client.icon_title.empty()) { - xatom->eraseValue(client.window, XAtom::net_wm_visible_icon_name); + xatom->eraseValue(client.window, OBAtom::net_wm_visible_icon_name); return; } // fall back to using the main name client.icon_title = client.title; - xatom->setValue(client.window, XAtom::net_wm_visible_icon_name, XAtom::utf8, + xatom->setValue(client.window, OBAtom::net_wm_visible_icon_name, OBAtom::utf8, client.icon_title); } @@ -1177,10 +1177,10 @@ void BlackboxWindow::getWMProtocols(void) { if (XGetWMProtocols(otk::OBDisplay::display, client.window, &proto, &num_return)) { for (int i = 0; i < num_return; ++i) { - if (proto[i] == xatom->getAtom(XAtom::wm_delete_window)) { + if (proto[i] == xatom->getAtom(OBAtom::wm_delete_window)) { decorations |= Decor_Close; functions |= Func_Close; - } else if (proto[i] == xatom->getAtom(XAtom::wm_take_focus)) + } else if (proto[i] == xatom->getAtom(OBAtom::wm_take_focus)) flags.send_focus_message = True; } @@ -1318,7 +1318,7 @@ void BlackboxWindow::getWMNormalHints(void) { void BlackboxWindow::getNetWMHints(void) { unsigned long workspace; - if (xatom->getValue(client.window, XAtom::net_wm_desktop, XAtom::cardinal, + if (xatom->getValue(client.window, OBAtom::net_wm_desktop, OBAtom::cardinal, workspace)) { if (workspace == 0xffffffff) flags.stuck = True; @@ -1328,26 +1328,26 @@ void BlackboxWindow::getNetWMHints(void) { unsigned long *state; unsigned long num = (unsigned) -1; - if (xatom->getValue(client.window, XAtom::net_wm_state, XAtom::atom, + if (xatom->getValue(client.window, OBAtom::net_wm_state, OBAtom::atom, num, &state)) { bool vert = False, horz = False; for (unsigned long i = 0; i < num; ++i) { - if (state[i] == xatom->getAtom(XAtom::net_wm_state_modal)) + if (state[i] == xatom->getAtom(OBAtom::net_wm_state_modal)) flags.modal = True; - else if (state[i] == xatom->getAtom(XAtom::net_wm_state_shaded)) + else if (state[i] == xatom->getAtom(OBAtom::net_wm_state_shaded)) flags.shaded = True; - else if (state[i] == xatom->getAtom(XAtom::net_wm_state_skip_taskbar)) + else if (state[i] == xatom->getAtom(OBAtom::net_wm_state_skip_taskbar)) flags.skip_taskbar = True; - else if (state[i] == xatom->getAtom(XAtom::net_wm_state_skip_pager)) + else if (state[i] == xatom->getAtom(OBAtom::net_wm_state_skip_pager)) flags.skip_pager = True; - else if (state[i] == xatom->getAtom(XAtom::net_wm_state_fullscreen)) + else if (state[i] == xatom->getAtom(OBAtom::net_wm_state_fullscreen)) flags.fullscreen = True; - else if (state[i] == xatom->getAtom(XAtom::net_wm_state_hidden)) + else if (state[i] == xatom->getAtom(OBAtom::net_wm_state_hidden)) setState(IconicState); - else if (state[i] == xatom->getAtom(XAtom::net_wm_state_maximized_vert)) + else if (state[i] == xatom->getAtom(OBAtom::net_wm_state_maximized_vert)) vert = True; - else if (state[i] == xatom->getAtom(XAtom::net_wm_state_maximized_horz)) + else if (state[i] == xatom->getAtom(OBAtom::net_wm_state_maximized_horz)) horz = True; } if (vert && horz) @@ -1374,8 +1374,8 @@ void BlackboxWindow::getMWMHints(void) { MwmHints *mwm_hint; num = PropMwmHintsElements; - if (! xatom->getValue(client.window, XAtom::motif_wm_hints, - XAtom::motif_wm_hints, num, + if (! xatom->getValue(client.window, OBAtom::motif_wm_hints, + OBAtom::motif_wm_hints, num, (unsigned long **)&mwm_hint)) return; if (num < PropMwmHintsElements) { @@ -1438,8 +1438,8 @@ bool BlackboxWindow::getBlackboxHints(void) { BlackboxHints *blackbox_hint; num = PropBlackboxHintsElements; - if (! xatom->getValue(client.window, XAtom::blackbox_hints, - XAtom::blackbox_hints, num, + if (! xatom->getValue(client.window, OBAtom::blackbox_hints, + OBAtom::blackbox_hints, num, (unsigned long **)&blackbox_hint)) return False; if (num < PropBlackboxHintsElements) { @@ -1721,11 +1721,11 @@ bool BlackboxWindow::setInputFocus(void) { if (flags.send_focus_message) { XEvent ce; ce.xclient.type = ClientMessage; - ce.xclient.message_type = xatom->getAtom(XAtom::wm_protocols); + ce.xclient.message_type = xatom->getAtom(OBAtom::wm_protocols); ce.xclient.display = otk::OBDisplay::display; ce.xclient.window = client.window; ce.xclient.format = 32; - ce.xclient.data.l[0] = xatom->getAtom(XAtom::wm_take_focus); + ce.xclient.data.l[0] = xatom->getAtom(OBAtom::wm_take_focus); ce.xclient.data.l[1] = blackbox->getLastTime(); ce.xclient.data.l[2] = 0l; ce.xclient.data.l[3] = 0l; @@ -1846,11 +1846,11 @@ void BlackboxWindow::close(void) { XEvent ce; ce.xclient.type = ClientMessage; - ce.xclient.message_type = xatom->getAtom(XAtom::wm_protocols); + ce.xclient.message_type = xatom->getAtom(OBAtom::wm_protocols); ce.xclient.display = otk::OBDisplay::display; ce.xclient.window = client.window; ce.xclient.format = 32; - ce.xclient.data.l[0] = xatom->getAtom(XAtom::wm_delete_window); + ce.xclient.data.l[0] = xatom->getAtom(OBAtom::wm_delete_window); ce.xclient.data.l[1] = CurrentTime; ce.xclient.data.l[2] = 0l; ce.xclient.data.l[3] = 0l; @@ -2034,7 +2034,7 @@ void BlackboxWindow::setWorkspace(unsigned int n) { */ n = 0xffffffff; } - xatom->setValue(client.window, XAtom::net_wm_desktop, XAtom::cardinal, n); + xatom->setValue(client.window, OBAtom::net_wm_desktop, OBAtom::cardinal, n); } @@ -2087,7 +2087,7 @@ void BlackboxWindow::stick(void) { screen->reassociateWindow(this, BSENTINEL, True); // temporary fix since sticky windows suck. set the hint to what we // actually hold in our data. - xatom->setValue(client.window, XAtom::net_wm_desktop, XAtom::cardinal, + xatom->setValue(client.window, OBAtom::net_wm_desktop, OBAtom::cardinal, blackbox_attrib.workspace); setState(current_state); @@ -2099,7 +2099,7 @@ void BlackboxWindow::stick(void) { // temporary fix since sticky windows suck. set the hint to a different // value than that contained in the class' data. - xatom->setValue(client.window, XAtom::net_wm_desktop, XAtom::cardinal, + xatom->setValue(client.window, OBAtom::net_wm_desktop, OBAtom::cardinal, 0xffffffff); for (unsigned int i = 0; i < screen->getNumberOfWorkspaces(); ++i) @@ -2254,20 +2254,20 @@ void BlackboxWindow::setAllowedActions(void) { Atom actions[7]; int num = 0; - actions[num++] = xatom->getAtom(XAtom::net_wm_action_shade); - actions[num++] = xatom->getAtom(XAtom::net_wm_action_change_desktop); - actions[num++] = xatom->getAtom(XAtom::net_wm_action_close); + actions[num++] = xatom->getAtom(OBAtom::net_wm_action_shade); + actions[num++] = xatom->getAtom(OBAtom::net_wm_action_change_desktop); + actions[num++] = xatom->getAtom(OBAtom::net_wm_action_close); if (functions & Func_Move) - actions[num++] = xatom->getAtom(XAtom::net_wm_action_move); + actions[num++] = xatom->getAtom(OBAtom::net_wm_action_move); if (functions & Func_Resize) - actions[num++] = xatom->getAtom(XAtom::net_wm_action_resize); + actions[num++] = xatom->getAtom(OBAtom::net_wm_action_resize); if (functions & Func_Maximize) { - actions[num++] = xatom->getAtom(XAtom::net_wm_action_maximize_horz); - actions[num++] = xatom->getAtom(XAtom::net_wm_action_maximize_vert); + actions[num++] = xatom->getAtom(OBAtom::net_wm_action_maximize_horz); + actions[num++] = xatom->getAtom(OBAtom::net_wm_action_maximize_vert); } - xatom->setValue(client.window, XAtom::net_wm_allowed_actions, XAtom::atom, + xatom->setValue(client.window, OBAtom::net_wm_allowed_actions, OBAtom::atom, actions, num); } @@ -2278,37 +2278,37 @@ void BlackboxWindow::setState(unsigned long new_state) { unsigned long state[2]; state[0] = current_state; state[1] = None; - xatom->setValue(client.window, XAtom::wm_state, XAtom::wm_state, state, 2); + xatom->setValue(client.window, OBAtom::wm_state, OBAtom::wm_state, state, 2); - xatom->setValue(client.window, XAtom::blackbox_attributes, - XAtom::blackbox_attributes, (unsigned long *)&blackbox_attrib, + xatom->setValue(client.window, OBAtom::blackbox_attributes, + OBAtom::blackbox_attributes, (unsigned long *)&blackbox_attrib, PropBlackboxAttributesElements); Atom netstate[8]; int num = 0; if (flags.modal) - netstate[num++] = xatom->getAtom(XAtom::net_wm_state_modal); + netstate[num++] = xatom->getAtom(OBAtom::net_wm_state_modal); if (flags.shaded) - netstate[num++] = xatom->getAtom(XAtom::net_wm_state_shaded); + netstate[num++] = xatom->getAtom(OBAtom::net_wm_state_shaded); if (flags.iconic) - netstate[num++] = xatom->getAtom(XAtom::net_wm_state_hidden); + netstate[num++] = xatom->getAtom(OBAtom::net_wm_state_hidden); if (flags.skip_taskbar) - netstate[num++] = xatom->getAtom(XAtom::net_wm_state_skip_taskbar); + netstate[num++] = xatom->getAtom(OBAtom::net_wm_state_skip_taskbar); if (flags.skip_pager) - netstate[num++] = xatom->getAtom(XAtom::net_wm_state_skip_pager); + netstate[num++] = xatom->getAtom(OBAtom::net_wm_state_skip_pager); if (flags.fullscreen) - netstate[num++] = xatom->getAtom(XAtom::net_wm_state_fullscreen); + netstate[num++] = xatom->getAtom(OBAtom::net_wm_state_fullscreen); if (flags.maximized == 1 || flags.maximized == 2) - netstate[num++] = xatom->getAtom(XAtom::net_wm_state_maximized_vert); + netstate[num++] = xatom->getAtom(OBAtom::net_wm_state_maximized_vert); if (flags.maximized == 1 || flags.maximized == 3) - netstate[num++] = xatom->getAtom(XAtom::net_wm_state_maximized_horz); - xatom->setValue(client.window, XAtom::net_wm_state, XAtom::atom, + netstate[num++] = xatom->getAtom(OBAtom::net_wm_state_maximized_horz); + xatom->setValue(client.window, OBAtom::net_wm_state, OBAtom::atom, netstate, num); } bool BlackboxWindow::getState(void) { - bool ret = xatom->getValue(client.window, XAtom::wm_state, XAtom::wm_state, + bool ret = xatom->getValue(client.window, OBAtom::wm_state, OBAtom::wm_state, current_state); if (! ret) current_state = 0; return ret; @@ -2318,8 +2318,8 @@ bool BlackboxWindow::getState(void) { void BlackboxWindow::restoreAttributes(void) { unsigned long num = PropBlackboxAttributesElements; BlackboxAttributes *net; - if (! xatom->getValue(client.window, XAtom::blackbox_attributes, - XAtom::blackbox_attributes, num, + if (! xatom->getValue(client.window, OBAtom::blackbox_attributes, + OBAtom::blackbox_attributes, num, (unsigned long **)&net)) return; if (num < PropBlackboxAttributesElements) { @@ -2875,7 +2875,7 @@ void BlackboxWindow::propertyNotifyEvent(const XPropertyEvent *pe) { if (flags.iconic) screen->propagateWindowName(this); break; - case XAtom::net_wm_name: + case OBAtom::net_wm_name: case XA_WM_NAME: getWMName(); @@ -2917,7 +2917,7 @@ void BlackboxWindow::propertyNotifyEvent(const XPropertyEvent *pe) { } default: - if (pe->atom == xatom->getAtom(XAtom::wm_protocols)) { + if (pe->atom == xatom->getAtom(OBAtom::wm_protocols)) { getWMProtocols(); if ((decorations & Decor_Close) && (! frame.close_button)) { @@ -2927,7 +2927,7 @@ void BlackboxWindow::propertyNotifyEvent(const XPropertyEvent *pe) { XMapSubwindows(otk::OBDisplay::display, frame.title); } } - } else if (pe->atom == xatom->getAtom(XAtom::net_wm_strut)) { + } else if (pe->atom == xatom->getAtom(OBAtom::net_wm_strut)) { updateStrut(); } @@ -3876,8 +3876,8 @@ void BlackboxWindow::restore(bool remap) { // erase the netwm stuff that we read when a window maps, so that it // doesn't persist between mappings. // (these are the ones read in getNetWMFlags().) - xatom->eraseValue(client.window, XAtom::net_wm_desktop); - xatom->eraseValue(client.window, XAtom::net_wm_state); + xatom->eraseValue(client.window, OBAtom::net_wm_desktop); + xatom->eraseValue(client.window, OBAtom::net_wm_state); restoreGravity(client.rect); diff --git a/src/bbwindow.hh b/src/bbwindow.hh index 29818b43..628728e1 100644 --- a/src/bbwindow.hh +++ b/src/bbwindow.hh @@ -104,7 +104,7 @@ public: private: Blackbox *blackbox; BScreen *screen; - XAtom *xatom; + OBAtom *xatom; otk::OBTimer *timer; BlackboxAttributes blackbox_attrib; diff --git a/src/blackbox.cc b/src/blackbox.cc index ca6ac814..4a5ef099 100644 --- a/src/blackbox.cc +++ b/src/blackbox.cc @@ -83,7 +83,7 @@ using std::string; #include "util.hh" #include "bbwindow.hh" #include "workspace.hh" -#include "xatom.hh" +#include "atom.hh" namespace ob { @@ -120,7 +120,7 @@ Blackbox::Blackbox(int argc, char **m_argv, char *rc) load_rc(); - xatom = new XAtom(otk::OBDisplay::display); + xatom = new OBAtom(); cursor.session = XCreateFontCursor(otk::OBDisplay::display, XC_left_ptr); cursor.move = XCreateFontCursor(otk::OBDisplay::display, XC_fleur); @@ -558,7 +558,7 @@ void Blackbox::process_event(XEvent *e) { case ClientMessage: { if (e->xclient.format == 32) { - if (e->xclient.message_type == xatom->getAtom(XAtom::wm_change_state)) { + if (e->xclient.message_type == xatom->getAtom(OBAtom::wm_change_state)) { // WM_CHANGE_STATE message BlackboxWindow *win = searchWindow(e->xclient.window); if (! win || ! win->validateClient()) return; @@ -568,9 +568,9 @@ void Blackbox::process_event(XEvent *e) { if (e->xclient.data.l[0] == NormalState) win->deiconify(); } else if (e->xclient.message_type == - xatom->getAtom(XAtom::blackbox_change_workspace) || + xatom->getAtom(OBAtom::blackbox_change_workspace) || e->xclient.message_type == - xatom->getAtom(XAtom::net_current_desktop)) { + xatom->getAtom(OBAtom::net_current_desktop)) { // NET_CURRENT_DESKTOP message BScreen *screen = searchScreen(e->xclient.window); @@ -578,14 +578,14 @@ void Blackbox::process_event(XEvent *e) { if (screen && workspace < screen->getWorkspaceCount()) screen->changeWorkspaceID(workspace); } else if (e->xclient.message_type == - xatom->getAtom(XAtom::blackbox_change_window_focus)) { + xatom->getAtom(OBAtom::blackbox_change_window_focus)) { // TEMP HACK TO KEEP BBKEYS WORKING BlackboxWindow *win = searchWindow(e->xclient.window); if (win && win->isVisible() && win->setInputFocus()) win->installColormap(True); } else if (e->xclient.message_type == - xatom->getAtom(XAtom::net_active_window)) { + xatom->getAtom(OBAtom::net_active_window)) { // NET_ACTIVE_WINDOW BlackboxWindow *win = searchWindow(e->xclient.window); @@ -606,7 +606,7 @@ void Blackbox::process_event(XEvent *e) { } } } else if (e->xclient.message_type == - xatom->getAtom(XAtom::blackbox_cycle_window_focus)) { + xatom->getAtom(OBAtom::blackbox_cycle_window_focus)) { // BLACKBOX_CYCLE_WINDOW_FOCUS BScreen *screen = searchScreen(e->xclient.window); @@ -617,7 +617,7 @@ void Blackbox::process_event(XEvent *e) { screen->nextFocus(); } } else if (e->xclient.message_type == - xatom->getAtom(XAtom::net_wm_desktop)) { + xatom->getAtom(OBAtom::net_wm_desktop)) { // NET_WM_DESKTOP BlackboxWindow *win = searchWindow(e->xclient.window); @@ -640,7 +640,7 @@ void Blackbox::process_event(XEvent *e) { } } } else if (e->xclient.message_type == - xatom->getAtom(XAtom::blackbox_change_attributes)) { + xatom->getAtom(OBAtom::blackbox_change_attributes)) { // BLACKBOX_CHANGE_ATTRIBUTES BlackboxWindow *win = searchWindow(e->xclient.window); @@ -655,45 +655,45 @@ void Blackbox::process_event(XEvent *e) { win->changeBlackboxHints(&net); } } else if (e->xclient.message_type == - xatom->getAtom(XAtom::net_number_of_desktops)) { + xatom->getAtom(OBAtom::net_number_of_desktops)) { // NET_NUMBER_OF_DESKTOPS BScreen *screen = searchScreen(e->xclient.window); if (e->xclient.data.l[0] > 0) screen->changeWorkspaceCount((unsigned) e->xclient.data.l[0]); } else if (e->xclient.message_type == - xatom->getAtom(XAtom::net_close_window)) { + xatom->getAtom(OBAtom::net_close_window)) { // NET_CLOSE_WINDOW BlackboxWindow *win = searchWindow(e->xclient.window); if (win && win->validateClient()) win->close(); // could this be smarter? } else if (e->xclient.message_type == - xatom->getAtom(XAtom::net_wm_moveresize)) { + xatom->getAtom(OBAtom::net_wm_moveresize)) { // NET_WM_MOVERESIZE BlackboxWindow *win = searchWindow(e->xclient.window); if (win && win->validateClient()) { int x_root = e->xclient.data.l[0], y_root = e->xclient.data.l[1]; if ((Atom) e->xclient.data.l[2] == - xatom->getAtom(XAtom::net_wm_moveresize_move)) { + xatom->getAtom(OBAtom::net_wm_moveresize_move)) { win->beginMove(x_root, y_root); } else { if ((Atom) e->xclient.data.l[2] == - xatom->getAtom(XAtom::net_wm_moveresize_size_topleft)) + xatom->getAtom(OBAtom::net_wm_moveresize_size_topleft)) win->beginResize(x_root, y_root, BlackboxWindow::TopLeft); else if ((Atom) e->xclient.data.l[2] == - xatom->getAtom(XAtom::net_wm_moveresize_size_topright)) + xatom->getAtom(OBAtom::net_wm_moveresize_size_topright)) win->beginResize(x_root, y_root, BlackboxWindow::TopRight); else if ((Atom) e->xclient.data.l[2] == - xatom->getAtom(XAtom::net_wm_moveresize_size_bottomleft)) + xatom->getAtom(OBAtom::net_wm_moveresize_size_bottomleft)) win->beginResize(x_root, y_root, BlackboxWindow::BottomLeft); else if ((Atom) e->xclient.data.l[2] == - xatom->getAtom(XAtom::net_wm_moveresize_size_bottomright)) + xatom->getAtom(OBAtom::net_wm_moveresize_size_bottomright)) win->beginResize(x_root, y_root, BlackboxWindow::BottomRight); } } } else if (e->xclient.message_type == - xatom->getAtom(XAtom::net_wm_state)) { + xatom->getAtom(OBAtom::net_wm_state)) { // NET_WM_STATE BlackboxWindow *win = searchWindow(e->xclient.window); if (win && win->validateClient()) { @@ -707,10 +707,10 @@ void Blackbox::process_event(XEvent *e) { if ((Atom) e->xclient.data.l[0] == 1) { // ADD - if (state[i] == xatom->getAtom(XAtom::net_wm_state_modal)) { + if (state[i] == xatom->getAtom(OBAtom::net_wm_state_modal)) { win->setModal(True); } else if (state[i] == - xatom->getAtom(XAtom::net_wm_state_maximized_vert)) { + xatom->getAtom(OBAtom::net_wm_state_maximized_vert)) { if (win->isMaximizedHoriz()) { win->maximize(0); // unmaximize win->maximize(1); // full @@ -718,7 +718,7 @@ void Blackbox::process_event(XEvent *e) { win->maximize(2); // vert } } else if (state[i] == - xatom->getAtom(XAtom::net_wm_state_maximized_horz)) { + xatom->getAtom(OBAtom::net_wm_state_maximized_horz)) { if (win->isMaximizedVert()) { win->maximize(0); // unmaximize win->maximize(1); // full @@ -726,25 +726,25 @@ void Blackbox::process_event(XEvent *e) { win->maximize(3); // horiz } } else if (state[i] == - xatom->getAtom(XAtom::net_wm_state_shaded)) { + xatom->getAtom(OBAtom::net_wm_state_shaded)) { if (! win->isShaded()) win->shade(); } else if (state[i] == - xatom->getAtom(XAtom::net_wm_state_skip_taskbar)) { + xatom->getAtom(OBAtom::net_wm_state_skip_taskbar)) { win->setSkipTaskbar(True); } else if (state[i] == - xatom->getAtom(XAtom::net_wm_state_skip_pager)) { + xatom->getAtom(OBAtom::net_wm_state_skip_pager)) { win->setSkipPager(True); } else if (state[i] == - xatom->getAtom(XAtom::net_wm_state_fullscreen)) { + xatom->getAtom(OBAtom::net_wm_state_fullscreen)) { win->setFullscreen(True); } } else if (action == 0) { // REMOVE - if (state[i] == xatom->getAtom(XAtom::net_wm_state_modal)) { + if (state[i] == xatom->getAtom(OBAtom::net_wm_state_modal)) { win->setModal(False); } else if (state[i] == - xatom->getAtom(XAtom::net_wm_state_maximized_vert)) { + xatom->getAtom(OBAtom::net_wm_state_maximized_vert)) { if (win->isMaximizedFull()) { win->maximize(0); // unmaximize win->maximize(3); // horiz @@ -752,7 +752,7 @@ void Blackbox::process_event(XEvent *e) { win->maximize(0); // unmaximize } } else if (state[i] == - xatom->getAtom(XAtom::net_wm_state_maximized_horz)) { + xatom->getAtom(OBAtom::net_wm_state_maximized_horz)) { if (win->isMaximizedFull()) { win->maximize(0); // unmaximize win->maximize(2); // vert @@ -760,25 +760,25 @@ void Blackbox::process_event(XEvent *e) { win->maximize(0); // unmaximize } } else if (state[i] == - xatom->getAtom(XAtom::net_wm_state_shaded)) { + xatom->getAtom(OBAtom::net_wm_state_shaded)) { if (win->isShaded()) win->shade(); } else if (state[i] == - xatom->getAtom(XAtom::net_wm_state_skip_taskbar)) { + xatom->getAtom(OBAtom::net_wm_state_skip_taskbar)) { win->setSkipTaskbar(False); } else if (state[i] == - xatom->getAtom(XAtom::net_wm_state_skip_pager)) { + xatom->getAtom(OBAtom::net_wm_state_skip_pager)) { win->setSkipPager(False); } else if (state[i] == - xatom->getAtom(XAtom::net_wm_state_fullscreen)) { + xatom->getAtom(OBAtom::net_wm_state_fullscreen)) { win->setFullscreen(False); } } else if (action == 2) { // TOGGLE - if (state[i] == xatom->getAtom(XAtom::net_wm_state_modal)) { + if (state[i] == xatom->getAtom(OBAtom::net_wm_state_modal)) { win->setModal(! win->isModal()); } else if (state[i] == - xatom->getAtom(XAtom::net_wm_state_maximized_vert)) { + xatom->getAtom(OBAtom::net_wm_state_maximized_vert)) { if (win->isMaximizedFull()) { win->maximize(0); // unmaximize win->maximize(3); // horiz @@ -791,7 +791,7 @@ void Blackbox::process_event(XEvent *e) { win->maximize(2); // vert } } else if (state[i] == - xatom->getAtom(XAtom::net_wm_state_maximized_horz)) { + xatom->getAtom(OBAtom::net_wm_state_maximized_horz)) { if (win->isMaximizedFull()) { win->maximize(0); // unmaximize win->maximize(2); // vert @@ -804,16 +804,16 @@ void Blackbox::process_event(XEvent *e) { win->maximize(3); // horiz } } else if (state[i] == - xatom->getAtom(XAtom::net_wm_state_shaded)) { + xatom->getAtom(OBAtom::net_wm_state_shaded)) { win->shade(); } else if (state[i] == - xatom->getAtom(XAtom::net_wm_state_skip_taskbar)) { + xatom->getAtom(OBAtom::net_wm_state_skip_taskbar)) { win->setSkipTaskbar(! win->skipTaskbar()); } else if (state[i] == - xatom->getAtom(XAtom::net_wm_state_skip_pager)) { + xatom->getAtom(OBAtom::net_wm_state_skip_pager)) { win->setSkipPager(! win->skipPager()); } else if (state[i] == - xatom->getAtom(XAtom::net_wm_state_fullscreen)) { + xatom->getAtom(OBAtom::net_wm_state_fullscreen)) { win->setFullscreen(! win->isFullscreen()); } } diff --git a/src/blackbox.hh b/src/blackbox.hh index 00f70cb9..7f07e946 100644 --- a/src/blackbox.hh +++ b/src/blackbox.hh @@ -29,7 +29,7 @@ extern "C" { #include "openbox.hh" #include "configuration.hh" #include "timer.hh" -#include "xatom.hh" +#include "atom.hh" #define AttribShaded (1l << 0) #define AttribMaxHoriz (1l << 1) @@ -112,7 +112,7 @@ private: BlackboxWindow *focused_window, *changing_window; otk::OBTimer *timer; Configuration config; - XAtom *xatom; + OBAtom *xatom; bool no_focus, reconfigure_wait; Time last_time; @@ -158,7 +158,7 @@ public: void removeWindowSearch(Window window); void removeGroupSearch(Window window); - inline XAtom *getXAtom(void) { return xatom; } + inline OBAtom *getXAtom(void) { return xatom; } inline BlackboxWindow *getFocusedWindow(void) { return focused_window; } inline BlackboxWindow *getChangingWindow(void) { return changing_window; } diff --git a/src/openbox.hh b/src/openbox.hh index 2feb8f0f..5e9edd17 100644 --- a/src/openbox.hh +++ b/src/openbox.hh @@ -16,6 +16,7 @@ extern "C" { #include "otk/screeninfo.hh" #include "otk/timerqueuemanager.hh" #include "xeventhandler.hh" +#include "atom.hh" namespace ob { @@ -112,7 +113,7 @@ public: //! The main function of the Openbox class /*! This function should be called after instantiating the Openbox class. - Loops indefinately while handling all events in the application. + It loops indefinately while handling all events for the application. The Openbox::shutdown method will cause this function to exit. */ void eventLoop(); diff --git a/src/screen.cc b/src/screen.cc index 4afe22a5..24520cea 100644 --- a/src/screen.cc +++ b/src/screen.cc @@ -64,7 +64,7 @@ using std::string; #include "bbwindow.hh" #include "workspace.hh" #include "util.hh" -#include "xatom.hh" +#include "atom.hh" #ifndef FONT_ELEMENT_SIZE #define FONT_ELEMENT_SIZE 50 @@ -119,11 +119,11 @@ BScreen::BScreen(Blackbox *bb, unsigned int scrn) : ScreenInfo(scrn) { #endif // HAVE_GETPID unsigned long geometry[] = { getWidth(), getHeight()}; - xatom->setValue(getRootWindow(), XAtom::net_desktop_geometry, - XAtom::cardinal, geometry, 2); + xatom->setValue(getRootWindow(), OBAtom::net_desktop_geometry, + OBAtom::cardinal, geometry, 2); unsigned long viewport[] = {0,0}; - xatom->setValue(getRootWindow(), XAtom::net_desktop_viewport, - XAtom::cardinal, viewport, 2); + xatom->setValue(getRootWindow(), OBAtom::net_desktop_viewport, + OBAtom::cardinal, viewport, 2); XDefineCursor(otk::OBDisplay::display, getRootWindow(), @@ -194,8 +194,8 @@ BScreen::BScreen(Blackbox *bb, unsigned int scrn) : ScreenInfo(scrn) { current_workspace = workspacesList.front(); - xatom->setValue(getRootWindow(), XAtom::net_current_desktop, - XAtom::cardinal, 0); //first workspace + xatom->setValue(getRootWindow(), OBAtom::net_current_desktop, + OBAtom::cardinal, 0); //first workspace raiseWindows(0, 0); // this also initializes the empty stacking list @@ -630,7 +630,7 @@ void BScreen::load_rc(void) { resource.col_direction = TopBottom; if (config->getValue(screenstr + "workspaceNames", s)) { - XAtom::StringVect workspaceNames; + OBAtom::StringVect workspaceNames; string::const_iterator it = s.begin(), end = s.end(); while(1) { @@ -642,7 +642,7 @@ void BScreen::load_rc(void) { ++it; } - xatom->setValue(getRootWindow(), XAtom::net_desktop_names, XAtom::utf8, + xatom->setValue(getRootWindow(), OBAtom::net_desktop_names, OBAtom::utf8, workspaceNames); } @@ -1014,8 +1014,8 @@ void BScreen::changeWorkspaceID(unsigned int id) { current_workspace = getWorkspace(id); - xatom->setValue(getRootWindow(), XAtom::net_current_desktop, - XAtom::cardinal, id); + xatom->setValue(getRootWindow(), OBAtom::net_current_desktop, + OBAtom::cardinal, id); current_workspace->showAll(); @@ -1069,11 +1069,11 @@ void BScreen::updateClientList(void) { const BlackboxWindowList::iterator end = windowList.end(); for (; it != end; ++it, ++win_it) *win_it = (*it)->getClientWindow(); - xatom->setValue(getRootWindow(), XAtom::net_client_list, XAtom::window, + xatom->setValue(getRootWindow(), OBAtom::net_client_list, OBAtom::window, windows, windowList.size()); delete [] windows; } else - xatom->setValue(getRootWindow(), XAtom::net_client_list, XAtom::window, + xatom->setValue(getRootWindow(), OBAtom::net_client_list, OBAtom::window, 0, 0); updateStackingList(); @@ -1106,12 +1106,12 @@ void BScreen::updateStackingList(void) { end = stack_order.end(); for (; it != end; ++it, ++win_it) *win_it = (*it)->getClientWindow(); - xatom->setValue(getRootWindow(), XAtom::net_client_list_stacking, - XAtom::window, windows, stack_order.size()); + xatom->setValue(getRootWindow(), OBAtom::net_client_list_stacking, + OBAtom::window, windows, stack_order.size()); delete [] windows; } else - xatom->setValue(getRootWindow(), XAtom::net_client_list_stacking, - XAtom::window, 0, 0); + xatom->setValue(getRootWindow(), OBAtom::net_client_list_stacking, + OBAtom::window, 0, 0); } @@ -1120,8 +1120,8 @@ void BScreen::addSystrayWindow(Window window) { XSelectInput(otk::OBDisplay::display, window, StructureNotifyMask); systrayWindowList.push_back(window); - xatom->setValue(getRootWindow(), XAtom::kde_net_system_tray_windows, - XAtom::window, + xatom->setValue(getRootWindow(), OBAtom::kde_net_system_tray_windows, + OBAtom::window, &systrayWindowList[0], systrayWindowList.size()); blackbox->saveSystrayWindowSearch(window, this); @@ -1137,8 +1137,8 @@ void BScreen::removeSystrayWindow(Window window) { for (; it != end; ++it) if (*it == window) { systrayWindowList.erase(it); - xatom->setValue(getRootWindow(), XAtom::kde_net_system_tray_windows, - XAtom::window, + xatom->setValue(getRootWindow(), OBAtom::kde_net_system_tray_windows, + OBAtom::window, &systrayWindowList[0], systrayWindowList.size()); blackbox->removeSystrayWindowSearch(window); XSelectInput(otk::OBDisplay::display, window, NoEventMask); @@ -1154,8 +1154,8 @@ void BScreen::removeSystrayWindow(Window window) { void BScreen::manageWindow(Window w) { // is the window a KDE systray window? Window systray; - if (xatom->getValue(w, XAtom::kde_net_wm_system_tray_window_for, - XAtom::window, systray) && systray != None) { + if (xatom->getValue(w, OBAtom::kde_net_wm_system_tray_window_for, + OBAtom::window, systray) && systray != None) { addSystrayWindow(w); return; } @@ -1198,8 +1198,8 @@ void BScreen::unmanageWindow(BlackboxWindow *w, bool remap) { // is the window a KDE systray window? Window systray; if (xatom->getValue(w->getClientWindow(), - XAtom::kde_net_wm_system_tray_window_for, - XAtom::window, systray) && systray != None) { + OBAtom::kde_net_wm_system_tray_window_for, + OBAtom::window, systray) && systray != None) { removeSystrayWindow(w->getClientWindow()); return; } @@ -1271,18 +1271,18 @@ void BScreen::updateWorkArea(void) { dims[(i * 4) + 2] = area.width(); dims[(i * 4) + 3] = area.height(); } - xatom->setValue(getRootWindow(), XAtom::net_workarea, XAtom::cardinal, + xatom->setValue(getRootWindow(), OBAtom::net_workarea, OBAtom::cardinal, dims, 4 * workspacesList.size()); delete [] dims; } else - xatom->setValue(getRootWindow(), XAtom::net_workarea, XAtom::cardinal, + xatom->setValue(getRootWindow(), OBAtom::net_workarea, OBAtom::cardinal, 0, 0); } void BScreen::updateNetizenWorkspaceCount(void) { - xatom->setValue(getRootWindow(), XAtom::net_number_of_desktops, - XAtom::cardinal, workspacesList.size()); + xatom->setValue(getRootWindow(), OBAtom::net_number_of_desktops, + OBAtom::cardinal, workspacesList.size()); updateWorkArea(); } @@ -1292,8 +1292,8 @@ void BScreen::updateNetizenWindowFocus(void) { Window f = ((blackbox->getFocusedWindow()) ? blackbox->getFocusedWindow()->getClientWindow() : None); - xatom->setValue(getRootWindow(), XAtom::net_active_window, - XAtom::window, f); + xatom->setValue(getRootWindow(), OBAtom::net_active_window, + OBAtom::window, f); } @@ -1641,7 +1641,7 @@ void BScreen::buttonPressEvent(const XButtonEvent *xbutton) { void BScreen::propertyNotifyEvent(const XPropertyEvent *pe) { - if (pe->atom == xatom->getAtom(XAtom::net_desktop_names)) { + if (pe->atom == xatom->getAtom(OBAtom::net_desktop_names)) { // _NET_WM_DESKTOP_NAMES WorkspaceList::iterator it = workspacesList.begin(); const WorkspaceList::iterator end = workspacesList.end(); diff --git a/src/screen.hh b/src/screen.hh index a1f36956..b00e5fc7 100644 --- a/src/screen.hh +++ b/src/screen.hh @@ -30,7 +30,7 @@ extern "C" { namespace ob { -class XAtom; +class OBAtom; struct Strut; enum TextJustify { LeftJustify = 1, RightJustify, CenterJustify }; @@ -66,7 +66,7 @@ private: Blackbox *blackbox; otk::BImageControl *image_control; Configuration *config; - XAtom *xatom; + OBAtom *xatom; BlackboxWindowList iconList, windowList; diff --git a/src/workspace.cc b/src/workspace.cc index ab209b0e..ec220a6a 100644 --- a/src/workspace.cc +++ b/src/workspace.cc @@ -31,7 +31,7 @@ using std::string; #include "util.hh" #include "bbwindow.hh" #include "workspace.hh" -#include "xatom.hh" +#include "atom.hh" namespace ob { @@ -424,12 +424,12 @@ void Workspace::setCurrent(void) { void Workspace::readName(void) { - XAtom::StringVect namesList; + OBAtom::StringVect namesList; unsigned long numnames = id + 1; // attempt to get from the _NET_WM_DESKTOP_NAMES property - if (xatom->getValue(screen->getRootWindow(), XAtom::net_desktop_names, - XAtom::utf8, numnames, namesList) && + if (xatom->getValue(screen->getRootWindow(), OBAtom::net_desktop_names, + OBAtom::utf8, numnames, namesList) && namesList.size() > id) { name = namesList[id]; @@ -451,17 +451,17 @@ void Workspace::readName(void) { void Workspace::setName(const string& new_name) { // set the _NET_WM_DESKTOP_NAMES property with the new name - XAtom::StringVect namesList; + OBAtom::StringVect namesList; unsigned long numnames = (unsigned) -1; - if (xatom->getValue(screen->getRootWindow(), XAtom::net_desktop_names, - XAtom::utf8, numnames, namesList) && + if (xatom->getValue(screen->getRootWindow(), OBAtom::net_desktop_names, + OBAtom::utf8, numnames, namesList) && namesList.size() > id) namesList[id] = new_name; else namesList.push_back(new_name); - xatom->setValue(screen->getRootWindow(), XAtom::net_desktop_names, - XAtom::utf8, namesList); + xatom->setValue(screen->getRootWindow(), OBAtom::net_desktop_names, + OBAtom::utf8, namesList); } diff --git a/src/workspace.hh b/src/workspace.hh index b40de267..a51b42a2 100644 --- a/src/workspace.hh +++ b/src/workspace.hh @@ -10,7 +10,7 @@ extern "C" { #include #include -#include "xatom.hh" +#include "atom.hh" namespace ob { @@ -25,7 +25,7 @@ class Workspace { private: BScreen *screen; BlackboxWindow *lastfocus; - XAtom *xatom; + OBAtom *xatom; BlackboxWindowList stackingList, windowList; diff --git a/src/xatom.cc b/src/xatom.cc deleted file mode 100644 index 3ed6cdf4..00000000 --- a/src/xatom.cc +++ /dev/null @@ -1,515 +0,0 @@ -// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*- - -#ifdef HAVE_CONFIG_H -# include "../config.h" -#endif // HAVE_CONFIG_H - -extern "C" { -#include -} - -#include "xatom.hh" -#include "screen.hh" -#include "util.hh" - -namespace ob { - -XAtom::XAtom(Display *d) { - _display = d; - - // make sure asserts fire if there is a problem - memset(_atoms, 0, sizeof(_atoms)); - - _atoms[cardinal] = XA_CARDINAL; - _atoms[window] = XA_WINDOW; - _atoms[pixmap] = XA_PIXMAP; - _atoms[atom] = XA_ATOM; - _atoms[string] = XA_STRING; - _atoms[utf8_string] = create("UTF8_STRING"); - -#ifdef HAVE_GETPID - _atoms[blackbox_pid] = create("_BLACKBOX_PID"); -#endif // HAVE_GETPID - - _atoms[wm_colormap_windows] = create("WM_COLORMAP_WINDOWS"); - _atoms[wm_protocols] = create("WM_PROTOCOLS"); - _atoms[wm_state] = create("WM_STATE"); - _atoms[wm_change_state] = create("WM_CHANGE_STATE"); - _atoms[wm_delete_window] = create("WM_DELETE_WINDOW"); - _atoms[wm_take_focus] = create("WM_TAKE_FOCUS"); - _atoms[wm_name] = create("WM_NAME"); - _atoms[wm_icon_name] = create("WM_ICON_NAME"); - _atoms[wm_class] = create("WM_CLASS"); - _atoms[motif_wm_hints] = create("_MOTIF_WM_HINTS"); - _atoms[blackbox_hints] = create("_BLACKBOX_HINTS"); - _atoms[blackbox_attributes] = create("_BLACKBOX_ATTRIBUTES"); - _atoms[blackbox_change_attributes] = create("_BLACKBOX_CHANGE_ATTRIBUTES"); - _atoms[blackbox_structure_messages] = create("_BLACKBOX_STRUCTURE_MESSAGES"); - _atoms[blackbox_notify_startup] = create("_BLACKBOX_NOTIFY_STARTUP"); - _atoms[blackbox_notify_window_add] = create("_BLACKBOX_NOTIFY_WINDOW_ADD"); - _atoms[blackbox_notify_window_del] = create("_BLACKBOX_NOTIFY_WINDOW_DEL"); - _atoms[blackbox_notify_current_workspace] = - create("_BLACKBOX_NOTIFY_CURRENT_WORKSPACE"); - _atoms[blackbox_notify_workspace_count] = - create("_BLACKBOX_NOTIFY_WORKSPACE_COUNT"); - _atoms[blackbox_notify_window_focus] = - create("_BLACKBOX_NOTIFY_WINDOW_FOCUS"); - _atoms[blackbox_notify_window_raise] = - create("_BLACKBOX_NOTIFY_WINDOW_RAISE"); - _atoms[blackbox_notify_window_lower] = - create("_BLACKBOX_NOTIFY_WINDOW_LOWER"); - - _atoms[blackbox_change_workspace] = create("_BLACKBOX_CHANGE_WORKSPACE"); - _atoms[blackbox_change_window_focus] = - create("_BLACKBOX_CHANGE_WINDOW_FOCUS"); - _atoms[blackbox_cycle_window_focus] = create("_BLACKBOX_CYCLE_WINDOW_FOCUS"); - - _atoms[openbox_show_root_menu] = create("_OPENBOX_SHOW_ROOT_MENU"); - _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"); - _atoms[net_wm_moveresize_size_topright] = - create("_NET_WM_MOVERESIZE_SIZE_TOPRIGHT"); - _atoms[net_wm_moveresize_size_bottomleft] = - create("_NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT"); - _atoms[net_wm_moveresize_size_bottomright] = - create("_NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT"); - _atoms[net_wm_moveresize_move] = - create("_NET_WM_MOVERESIZE_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_shade] = create("_NET_WM_ACTION_SHADE"); - _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_change_desktop] = - create("_NET_WM_ACTION_CHANGE_DESKTOP"); - _atoms[net_wm_action_close] = create("_NET_WM_ACTION_CLOSE"); - - _atoms[net_wm_state_modal] = create("_NET_WM_STATE_MODAL"); - _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_shaded] = create("_NET_WM_STATE_SHADED"); - _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_hidden] = create("_NET_WM_STATE_HIDDEN"); - _atoms[net_wm_state_fullscreen] = create("_NET_WM_STATE_FULLSCREEN"); - - _atoms[kde_net_system_tray_windows] = create("_KDE_NET_SYSTEM_TRAY_WINDOWS"); - _atoms[kde_net_wm_system_tray_window_for] = - create("_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR"); - _atoms[kde_net_wm_window_type_override] = - create("_KDE_NET_WM_WINDOW_TYPE_OVERRIDE"); -} - - -/* - * clean up the class' members - */ -XAtom::~XAtom() { - while (!_support_windows.empty()) { - // make sure we aren't fucking with this somewhere - assert(_support_windows.back() != None); - XDestroyWindow(_display, _support_windows.back()); - _support_windows.pop_back(); - } -} - - -/* - * Returns an atom from the Xserver, creating it if necessary. - */ -Atom XAtom::create(const char *name) const { - return XInternAtom(_display, name, False); -} - - -/* - * Sets which atoms are supported for NETWM, by Openbox, on the root window. - */ -void XAtom::setSupported(const otk::ScreenInfo *screen) { - Window root = screen->getRootWindow(); - - // create the netwm support window - Window w = XCreateSimpleWindow(_display, root, 0, 0, 1, 1, 0, 0, 0); - assert(w != None); - _support_windows.push_back(w); - - // set supporting window - setValue(root, net_supporting_wm_check, window, w); - - //set properties on the supporting window - setValue(w, net_wm_name, utf8, "Openbox"); - setValue(w, net_supporting_wm_check, window, w); - - // we don't support any yet.. - // yes we do! - - Atom supported[] = { - _atoms[net_current_desktop], - _atoms[net_number_of_desktops], - _atoms[net_desktop_geometry], - _atoms[net_desktop_viewport], - _atoms[net_active_window], - _atoms[net_workarea], - _atoms[net_client_list], - _atoms[net_client_list_stacking], - _atoms[net_desktop_names], - _atoms[net_close_window], - _atoms[net_wm_name], - _atoms[net_wm_visible_name], - _atoms[net_wm_icon_name], - _atoms[net_wm_visible_icon_name], - _atoms[net_wm_desktop], - _atoms[net_wm_strut], - _atoms[net_wm_window_type], - _atoms[net_wm_window_type_desktop], - _atoms[net_wm_window_type_dock], - _atoms[net_wm_window_type_toolbar], - _atoms[net_wm_window_type_menu], - _atoms[net_wm_window_type_utility], - _atoms[net_wm_window_type_splash], - _atoms[net_wm_window_type_dialog], - _atoms[net_wm_window_type_normal], - _atoms[net_wm_moveresize], - _atoms[net_wm_moveresize_size_topleft], - _atoms[net_wm_moveresize_size_topright], - _atoms[net_wm_moveresize_size_bottomleft], - _atoms[net_wm_moveresize_size_bottomright], - _atoms[net_wm_moveresize_move], - _atoms[net_wm_allowed_actions], - _atoms[net_wm_action_move], - _atoms[net_wm_action_resize], - _atoms[net_wm_action_shade], - _atoms[net_wm_action_maximize_horz], - _atoms[net_wm_action_maximize_vert], - _atoms[net_wm_action_change_desktop], - _atoms[net_wm_action_close], - _atoms[net_wm_state], - _atoms[net_wm_state_modal], - _atoms[net_wm_state_maximized_vert], - _atoms[net_wm_state_maximized_horz], - _atoms[net_wm_state_shaded], - _atoms[net_wm_state_skip_taskbar], - _atoms[net_wm_state_skip_pager], - _atoms[net_wm_state_hidden], - _atoms[net_wm_state_fullscreen], - }; - const int num_supported = sizeof(supported)/sizeof(Atom); - - setValue(root, net_supported, atom, supported, num_supported); -} - - -/* - * Internal setValue. - * Sets a window property on a window, optionally appending to the existing - * value. - */ -void XAtom::setValue(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(nelements == 0 || (nelements > 0 && data != (unsigned char *) 0)); - assert(size == 8 || size == 16 || size == 32); - XChangeProperty(_display, win, atom, type, size, - (append ? PropModeAppend : PropModeReplace), - data, nelements); -} - - -/* - * Set a 32-bit property value on a window. - */ -void XAtom::setValue(Window win, Atoms atom, Atoms type, - unsigned long value) const { - assert(atom >= 0 && atom < NUM_ATOMS); - assert(type >= 0 && type < NUM_ATOMS); - setValue(win, _atoms[atom], _atoms[type], - reinterpret_cast(&value), 32, 1, False); -} - - -/* - * Set an array of 32-bit properties value on a window. - */ -void XAtom::setValue(Window win, Atoms atom, Atoms type, - unsigned long value[], int elements) const { - assert(atom >= 0 && atom < NUM_ATOMS); - assert(type >= 0 && type < NUM_ATOMS); - setValue(win, _atoms[atom], _atoms[type], - reinterpret_cast(value), 32, elements, False); -} - - -/* - * Set an string property value on a window. - */ -void XAtom::setValue(Window win, Atoms atom, StringType type, - const std::string &value) const { - assert(atom >= 0 && atom < NUM_ATOMS); - assert(type >= 0 && type < NUM_STRING_TYPE); - - Atom t; - switch (type) { - case ansi: t = _atoms[string]; break; - case utf8: t = _atoms[utf8_string]; break; - default: assert(False); return; // unhandled StringType - } - setValue(win, _atoms[atom], t, - reinterpret_cast(const_cast(value.c_str())), - 8, value.size() + 1, False); // add 1 to the size to include the null -} - - -/* - * Set an array of string property values on a window. - */ -void XAtom::setValue(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; - switch (type) { - case ansi: t = _atoms[string]; break; - case utf8: t = _atoms[utf8_string]; break; - default: assert(False); return; // unhandled StringType - } - - std::string value; - - StringVect::const_iterator it = strings.begin(); - const StringVect::const_iterator end = strings.end(); - for (; it != end; ++it) - value += *it + '\0'; - - setValue(win, _atoms[atom], t, - reinterpret_cast(const_cast(value.c_str())), - 8, value.size(), False); -} - - -/* - * Internal getValue function used by all of the typed getValue 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 XAtom::getValue(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(size == 8 || size == 16 || size == 32); - assert(nelements > 0); - unsigned char *c_val = 0; // value alloc'd in Xlib, must be XFree()d - Atom ret_type; - int ret_size; - unsigned long ret_bytes; - int result; - unsigned long maxread = nelements; - bool ret = False; - - // try get the first element - result = XGetWindowProperty(_display, win, atom, 0l, 1l, False, - AnyPropertyType, &ret_type, &ret_size, - &nelements, &ret_bytes, &c_val); - ret = (result == Success && ret_type == type && ret_size == size && - nelements > 0); - if (ret) { - if (ret_bytes == 0 || maxread <= nelements) { - // we got the whole property's value - *value = new unsigned char[nelements * size/8 + 1]; - memcpy(*value, c_val, nelements * size/8 + 1); - } else { - // get the entire property since it is larger than one long - XFree(c_val); - // the number of longs that need to be retreived to get the property's - // entire value. The last + 1 is the first long that we retrieved above. - int remain = (ret_bytes - 1)/sizeof(long) + 1 + 1; - if (remain > size/8 * (signed)maxread) // dont get more than the max - remain = size/8 * (signed)maxread; - result = XGetWindowProperty(_display, win, atom, 0l, remain, False, type, - &ret_type, &ret_size, &nelements, &ret_bytes, - &c_val); - ret = (result == Success && ret_type == type && ret_size == size && - ret_bytes == 0); - /* - If the property has changed type/size, or has grown since our first - read of it, then stop here and try again. If it shrank, then this will - still work. - */ - if (! ret) - return getValue(win, atom, type, maxread, value, size); - - *value = new unsigned char[nelements * size/8 + 1]; - memcpy(*value, c_val, nelements * size/8 + 1); - } - } - if (c_val) XFree(c_val); - return ret; -} - - -/* - * Gets a 32-bit property's value from a window. - */ -bool XAtom::getValue(Window win, Atoms atom, Atoms type, - unsigned long &nelements, - unsigned long **value) const { - assert(atom >= 0 && atom < NUM_ATOMS); - assert(type >= 0 && type < NUM_ATOMS); - return getValue(win, _atoms[atom], _atoms[type], nelements, - reinterpret_cast(value), 32); -} - - -/* - * Gets a single 32-bit property's value from a window. - */ -bool XAtom::getValue(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 num = 1; - if (! getValue(win, _atoms[atom], _atoms[type], num, - reinterpret_cast(&temp), 32)) - return False; - value = temp[0]; - delete [] temp; - return True; -} - - -/* - * Gets an string property's value from a window. - */ -bool XAtom::getValue(Window win, Atoms atom, StringType type, - std::string &value) const { - unsigned long n = 1; - StringVect s; - if (getValue(win, atom, type, n, s)) { - value = s[0]; - return True; - } - return False; -} - - -bool XAtom::getValue(Window win, Atoms atom, StringType type, - 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); - - Atom t; - switch (type) { - case ansi: t = _atoms[string]; break; - case utf8: t = _atoms[utf8_string]; break; - default: assert(False); return False; // unhandled StringType - } - - unsigned char *value; - unsigned long elements = (unsigned) -1; - if (!getValue(win, _atoms[atom], t, elements, &value, 8) || elements < 1) - return False; - - std::string s(reinterpret_cast(value), elements); - delete [] value; - - std::string::const_iterator it = s.begin(), end = s.end(); - unsigned long num = 0; - while(num < nelements) { - std::string::const_iterator tmp = it; // current string.begin() - it = std::find(tmp, end, '\0'); // look for null between tmp and end - strings.push_back(std::string(tmp, it)); // s[tmp:it) - ++num; - if (it == end) break; - ++it; - if (it == end) break; - } - - nelements = num; - - return True; -} - - -/* - * Removes a property entirely from a window. - */ -void XAtom::eraseValue(Window win, Atoms atom) const { - assert(atom >= 0 && atom < NUM_ATOMS); - XDeleteProperty(_display, win, _atoms[atom]); -} - - -void XAtom::sendClientMessage(Window target, Atoms type, Window about, - long data, long data1, long data2, - long data3, long data4) const { - assert(atom >= 0 && atom < NUM_ATOMS); - assert(target != None); - - XEvent e; - e.xclient.type = ClientMessage; - e.xclient.format = 32; - e.xclient.message_type = _atoms[type]; - e.xclient.window = about; - e.xclient.data.l[0] = data; - e.xclient.data.l[1] = data1; - e.xclient.data.l[2] = data2; - e.xclient.data.l[3] = data3; - e.xclient.data.l[4] = data4; - - XSendEvent(_display, target, False, - SubstructureRedirectMask | SubstructureNotifyMask, - &e); -} - -} diff --git a/src/xatom.hh b/src/xatom.hh deleted file mode 100644 index 0b5ec435..00000000 --- a/src/xatom.hh +++ /dev/null @@ -1,219 +0,0 @@ -// XAtom.h for Openbox -#ifndef __XAtom_h -#define __XAtom_h - -/*! @file xatom.hh - @brief Provides access to atoms on the display -*/ - -extern "C" { -#include -#include - -#include -} - -#include -#include - -#include "otk/screeninfo.hh" - -namespace ob { - -class XAtom { -public: - enum Atoms { - // types - cardinal, - window, - pixmap, - atom, - string, - utf8_string, - -#ifdef HAVE_GETPID - blackbox_pid, -#endif // HAVE_GETPID - - // 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, - 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_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, - - kde_net_system_tray_windows, - kde_net_wm_system_tray_window_for, - kde_net_wm_window_type_override, - - // constant for how many atoms exist in the enumerator - NUM_ATOMS - }; - - enum StringType { - ansi, - utf8, - NUM_STRING_TYPE - }; - -private: - typedef std::vector SupportWindows; - - Display *_display; - // windows used to specify support for NETWM - SupportWindows _support_windows; - Atom _atoms[NUM_ATOMS]; - - Atom create(const char *name) const; - - void setValue(Window win, Atom atom, Atom type, unsigned char *data, - int size, int nelements, bool append) const; - bool getValue(Window win, Atom atom, Atom type, - unsigned long &nelements, unsigned char **value, - int size) const; - - // no copying!! - XAtom(const XAtom &); - XAtom& operator=(const XAtom&); - -public: - typedef std::vector StringVect; - - XAtom(Display *d); - virtual ~XAtom(); - - // setup support on a screen, each screen should call this once in its - // constructor. - void setSupported(const otk::ScreenInfo *screen); - - void setValue(Window win, Atoms atom, Atoms type, unsigned long value) const; - void setValue(Window win, Atoms atom, Atoms type, - unsigned long value[], int elements) const; - void setValue(Window win, Atoms atom, StringType type, - const std::string &value) const; - void setValue(Window win, Atoms atom, StringType type, - const StringVect &strings) const; - - // the 'value' is allocated inside the function and - // delete [] value needs to be called when you are done with it. - // the 'value' array returned is null terminated, and has 'nelements' - // elements in it plus the null. - // nelements must be set to the maximum number of elements to read from - // the property. - bool getValue(Window win, Atoms atom, Atoms type, - unsigned long &nelements, unsigned long **value) const; - bool getValue(Window win, Atoms atom, Atoms type, unsigned long &value) const; - bool getValue(Window win, Atoms atom, StringType type, - std::string &value) const; - bool getValue(Window win, Atoms atom, StringType type, - unsigned long &nelements, StringVect &strings) const; - - void eraseValue(Window win, Atoms atom) const; - - // sends a client message a window - void sendClientMessage(Window target, Atoms type, Window about, - long data = 0, long data1 = 0, long data2 = 0, - long data3 = 0, long data4 = 0) const; - - // temporary function!! remove when not used in blackbox.hh anymore!! - inline Atom getAtom(Atoms a) - { assert(a >= 0 && a < NUM_ATOMS); Atom ret = _atoms[a]; - assert(ret != 0); return ret; } -}; - -} - -#endif // __XAtom_h -- cgit v1.2.3