all repos — openbox @ b8ee3dbc4565efb19338c5cf1948f0f4e2f24fd6

openbox fork - make it a bit more like ryudo

merging in netwm changes at merge point "netwm-merge1". This add the XAtom class, and sets the net_supported_wm_check related atoms.
Dana Jansens danakj@orodu.net
commit

b8ee3dbc4565efb19338c5cf1948f0f4e2f24fd6

parent

5ae928ffc67d0a341ac48c1c07de503e30f3a02b

M src/Configuration.ccsrc/Configuration.cc

@@ -25,6 +25,8 @@

#include "Configuration.hh" #include "Util.hh" +#include <algorithm> + #ifdef HAVE_STDLIB_H # include <stdlib.h> #endif // HAVE_STDLIB_H
M src/Makefile.amsrc/Makefile.am

@@ -29,7 +29,7 @@ -DDEFAULTSTYLE=\"$(DEFAULT_STYLE)\"

bin_PROGRAMS= openbox -openbox_SOURCES= BaseDisplay.cc Basemenu.cc Clientmenu.cc Color.cc Configmenu.cc Configuration.cc GCCache.cc Iconmenu.cc Image.cc ImageControl.cc Netizen.cc Rootmenu.cc Screen.cc Slit.cc Texture.cc Timer.cc Toolbar.cc Util.cc Window.cc Windowmenu.cc Workspace.cc Workspacemenu.cc blackbox.cc i18n.cc main.cc +openbox_SOURCES= BaseDisplay.cc Basemenu.cc Clientmenu.cc Color.cc Configmenu.cc Configuration.cc GCCache.cc Iconmenu.cc Image.cc ImageControl.cc Netizen.cc Rootmenu.cc Screen.cc Slit.cc Texture.cc Timer.cc Toolbar.cc Util.cc Window.cc Windowmenu.cc Workspace.cc Workspacemenu.cc XAtom.cc blackbox.cc i18n.cc main.cc MAINTAINERCLEANFILES= Makefile.in
M src/Screen.ccsrc/Screen.cc

@@ -21,9 +21,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -#ifdef HAVE_CONFIG_H -# include "../config.h" -#endif // HAVE_CONFIG_H +#include "../config.h" extern "C" { #include <X11/Xatom.h>

@@ -86,6 +84,7 @@ #include "Util.hh"

#include "Window.hh" #include "Workspace.hh" #include "Workspacemenu.hh" +#include "XAtom.hh" #ifndef FONT_ELEMENT_SIZE #define FONT_ELEMENT_SIZE 50

@@ -110,6 +109,7 @@ BScreen::BScreen(Blackbox *bb, unsigned int scrn) : ScreenInfo(bb, scrn) {

blackbox = bb; screenstr = (string)"session.screen" + itostring(scrn) + '.'; config = blackbox->getConfig(); + xatom = blackbox->getXAtom(); event_mask = ColormapChangeMask | EnterWindowMask | PropertyChangeMask | SubstructureRedirectMask | ButtonPressMask | ButtonReleaseMask;

@@ -135,13 +135,10 @@ resource.tstyle.fontset = resource.wstyle.fontset = (XFontSet) 0;

resource.mstyle.t_font = resource.mstyle.f_font = resource.tstyle.font = resource.wstyle.font = (XFontStruct *) 0; + xatom->setSupported(this); // set-up netwm support #ifdef HAVE_GETPID - pid_t bpid = getpid(); - - XChangeProperty(blackbox->getXDisplay(), getRootWindow(), - blackbox->getBlackboxPidAtom(), XA_CARDINAL, - sizeof(pid_t) * 8, PropModeReplace, - (unsigned char *) &bpid, 1); + xatom->setValue(getRootWindow(), XAtom::blackbox_pid, XAtom::Type_Cardinal, + (unsigned long) getpid()); #endif // HAVE_GETPID XDefineCursor(blackbox->getXDisplay(), getRootWindow(),
M src/Screen.hhsrc/Screen.hh

@@ -55,6 +55,7 @@ #include "Workspace.hh"

#include "Workspacemenu.hh" #include "blackbox.hh" class Slit; // forward reference +class XAtom; enum TextJustify { LeftJustify = 1, RightJustify, CenterJustify };

@@ -119,6 +120,7 @@ Configmenu *configmenu;

Iconmenu *iconmenu; Rootmenu *rootmenu; Configuration *config; + XAtom *xatom; typedef std::list<Rootmenu*> RootmenuList; RootmenuList rootmenuList;
A src/XAtom.cc

@@ -0,0 +1,341 @@

+// XAtom.cc for Openbox +// Copyright (c) 2002 - 2002 Ben Jansens (xor at orodu.net) +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +#include "../config.h" + +#include "XAtom.hh" +#include "blackbox.hh" +#include "Screen.hh" +#include "Util.hh" + +XAtom::XAtom(Blackbox *bb) { + _display = bb->getXDisplay(); + + // make sure asserts fire if there is a problem + memset(_atoms, sizeof(_atoms), 0); + + _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[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[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_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_ping] = create("_NET_WM_PING"); +} + + +/* + * 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 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, Type_Window, w); + + //set properties on the supporting window + setValue(w, net_wm_name, Type_Utf8, "Openbox"); + setValue(w, net_supporting_wm_check, Type_Window, w); + + + // we don't support any yet.. + // yes we do! + + Atom supported[] = { + _atoms[net_supported] // remove me later, cuz i dont think i belong + }; + + eraseValue(root, net_supported); + for (unsigned int i = 0, num = sizeof(supported)/sizeof(Atom); i < num; ++i) + addValue(root, net_supported, Type_Atom, supported[i]); +} + + +/* + * Internal setValue used by all typed setValue functions. + * Sets a window property on a window, optionally appending to the existing + * value. + */ +void XAtom::setValue(Window win, AvailableAtoms atom, Atom type, + unsigned char* data, int size, int nelements, + bool append) const { + assert(atom >= 0 && atom < NUM_ATOMS); + assert(win != None); assert(type != None); + assert(data != (unsigned char *) 0); + assert(size == 8 || size == 16 || size == 32); + assert(nelements > 0); + XChangeProperty(_display, win, _atoms[atom], type, size, + (append ? PropModeAppend : PropModeReplace), + data, nelements); +} + + +/* + * Set a 32-bit property value on a window. + */ +void XAtom::setValue(Window win, AvailableAtoms atom, AtomType type, + unsigned long value) const { + Atom t; + switch (type) { + case Type_Cardinal: t = XA_CARDINAL; break; + case Type_Atom: t = XA_ATOM; break; + case Type_Window: t = XA_WINDOW; break; + case Type_Pixmap: t = XA_PIXMAP; break; + default: assert(false); // unhandled AtomType + } + setValue(win, atom, t, reinterpret_cast<unsigned char*>(&value), + 32, 1, false); +} + + +/* + * Set a string property value on a window. + */ +void XAtom::setValue(Window win, AvailableAtoms atom, StringType type, + const std::string &value) const { + Atom t; + switch (type) { + case Type_String: t = XA_STRING; break; + case Type_Utf8: t = _atoms[utf8_string]; break; + default: assert(false); // unhandled StringType + } + setValue(win, atom, t, + const_cast<unsigned char*> + (reinterpret_cast<const unsigned char*>(value.c_str())), + 8, value.size(), false); +} + + +/* + * Add elements to a 32-bit property value on a window. + */ +void XAtom::addValue(Window win, AvailableAtoms atom, AtomType type, + unsigned long value) const { + Atom t; + switch (type) { + case Type_Cardinal: t = XA_CARDINAL; break; + case Type_Atom: t = XA_ATOM; break; + case Type_Window: t = XA_WINDOW; break; + case Type_Pixmap: t = XA_PIXMAP; break; + default: assert(false); // unhandled Atom_Type + } + setValue(win, atom, t, reinterpret_cast<unsigned char*>(&value), 32, 1, true); +} + + +/* + * Add characters to a string property value on a window. + */ +void XAtom::addValue(Window win, AvailableAtoms atom, StringType type, + const std::string &value) const { + Atom t; + switch (type) { + case Type_String: t = XA_STRING; break; + case Type_Utf8: t = _atoms[utf8_string]; break; + default: assert(false); // unhandled StringType + } + setValue(win, atom, t, + const_cast<unsigned char*> + (reinterpret_cast<const unsigned char *> + (value.c_str())), + 8, value.size(), true); +} + + +/* + * 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, AvailableAtoms atom, Atom type, + unsigned long *nelements, unsigned char **value, + int size) const { + assert(atom >= 0 && atom < NUM_ATOMS); + assert(win != None); assert(type != None); + assert(size == 8 || size == 16 || size == 32); + unsigned char *c_val; // value alloc'd with c malloc + Atom ret_type; + int ret_size; + unsigned long ret_bytes; + XGetWindowProperty(_display, win, _atoms[atom], 0l, 1l, False, + AnyPropertyType, &ret_type, &ret_size, nelements, + &ret_bytes, &c_val); // try get the first element + if (ret_type == None) + // the property does not exist on the window + return false; + if (ret_type != type || ret_size != size) { + // wrong data in property + XFree(c_val); + return false; + } + // the data is correct, now, is there more than 1 element? + if (ret_bytes == 0) { + // we got the whole property's value + *value = new unsigned char[*nelements * size/8 + 1]; + memcpy(*value, c_val, *nelements * size/8 + 1); + XFree(c_val); + return true; + } + // get the entire property since it is larger than one long + free(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. + const int remain = (ret_bytes - 1)/sizeof(long) + 1 + 1; + XGetWindowProperty(_display, win, _atoms[atom], 0l, remain, False, type, + &ret_type, &ret_size, nelements, &ret_bytes, &c_val); + assert(ret_bytes == 0); + *value = new unsigned char[*nelements * size/8 + 1]; + memcpy(*value, c_val, *nelements * size/8 + 1); + XFree(c_val); + return true; +} + + +/* + * Gets a 32-bit property's value from a window. + */ +bool XAtom::getValue(Window win, AvailableAtoms atom, AtomType type, + unsigned long *nelements, + unsigned long **value) const { + Atom t; + switch (type) { + case Type_Cardinal: t = XA_CARDINAL; break; + case Type_Atom: t = XA_ATOM; break; + case Type_Window: t = XA_WINDOW; break; + case Type_Pixmap: t = XA_PIXMAP; break; + default: assert(false); // unhandled Atom_Type + } + return getValue(win, atom, XA_CARDINAL, nelements, + reinterpret_cast<unsigned char **>(value), 32); +} + + +/* + * Gets an string property's value from a window. + */ +bool XAtom::getValue(Window win, AvailableAtoms atom, StringType type, + std::string &value) const { + Atom t; + switch (type) { + case Type_String: t = XA_STRING; break; + case Type_Utf8: t = _atoms[utf8_string]; break; + default: assert(false); // unhandled StringType + } + unsigned char *data; + unsigned long nelements; + bool ret = getValue(win, atom, t, &nelements, &data, 8); + if (ret) + value = reinterpret_cast<char*>(data); + return ret; +} + + +/* + * Removes a property entirely from a window. + */ +void XAtom::eraseValue(Window win, AvailableAtoms atom) const { + XDeleteProperty(_display, win, _atoms[atom]); +}
A src/XAtom.hh

@@ -0,0 +1,171 @@

+// XAtom.h for Openbox +// Copyright (c) 2002 - 2002 Ben Janens (ben at orodu.net) +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +#ifndef __XAtom_h +#define __XAtom_h + +#include <X11/Xlib.h> +#include <X11/Xatom.h> +#include <vector> +#include <string> + +class Blackbox; +class ScreenInfo; + +class XAtom { +public: + enum AvailableAtoms { + // string type + 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, + 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, + + // 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_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, + // application protocols + net_wm_ping, + + // constant for how many atoms exist in the enumerator + NUM_ATOMS + }; + + enum AtomType { + Type_Cardinal, + Type_Atom, + Type_Window, + Type_Pixmap + }; + + enum StringType { + Type_String, + Type_Utf8, + }; + +private: + typedef std::vector<Window> 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, AvailableAtoms atom, Atom type, unsigned char *data, + int size, int nelements, bool append) const; + bool getValue(Window win, AvailableAtoms atom, Atom type, + unsigned long *nelements, unsigned char **value, + int size) const; + + // no copying!! + XAtom(const XAtom &); + XAtom& operator=(const XAtom&); + +public: + XAtom(Blackbox *bb); + virtual ~XAtom(); + + // setup support on a screen, each screen should call this once in its + // constructor. + void setSupported(const ScreenInfo *screen); + + void setValue(Window win, AvailableAtoms atom, AtomType type, + unsigned long value) const; + void setValue(Window win, AvailableAtoms atom, StringType type, + const std::string &value) const; + + void addValue(Window win, AvailableAtoms atom, AtomType type, + unsigned long value) const; + void addValue(Window win, AvailableAtoms atom, StringType type, + const std::string &value) 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. + bool getValue(Window win, AvailableAtoms atom, AtomType type, + unsigned long *nelements, unsigned long **value) const; + bool getValue(Window win, AvailableAtoms atom, StringType type, + std::string &value) const; + + void eraseValue(Window win, AvailableAtoms atom) const; + + // temporary function!! remove when not used in blackbox.hh anymore!! + inline Atom getAtom(AvailableAtoms a) + { Atom ret = _atoms[a]; assert(ret != 0); return ret; } +}; + +#endif // __XAtom_h
M src/blackbox.ccsrc/blackbox.cc

@@ -108,7 +108,7 @@ #include "Util.hh"

#include "Window.hh" #include "Workspace.hh" #include "Workspacemenu.hh" - +#include "XAtom.hh" // X event scanner for enter/leave notifies - adapted from twm struct scanargs {

@@ -159,7 +159,7 @@

XrmInitialize(); load_rc(); - init_icccm(); + xatom = new XAtom(this); cursor.session = XCreateFontCursor(getXDisplay(), XC_left_ptr); cursor.move = XCreateFontCursor(getXDisplay(), XC_fleur);

@@ -206,6 +206,8 @@ std::for_each(screenList.begin(), screenList.end(), PointerAssassin());

std::for_each(menuTimestamps.begin(), menuTimestamps.end(), PointerAssassin()); + + delete xatom; delete timer; }

@@ -739,89 +741,6 @@ return False;

} return True; -} - - -void Blackbox::init_icccm(void) { - xa_wm_colormap_windows = - XInternAtom(getXDisplay(), "WM_COLORMAP_WINDOWS", False); - xa_wm_protocols = XInternAtom(getXDisplay(), "WM_PROTOCOLS", False); - xa_wm_state = XInternAtom(getXDisplay(), "WM_STATE", False); - xa_wm_change_state = XInternAtom(getXDisplay(), "WM_CHANGE_STATE", False); - xa_wm_delete_window = XInternAtom(getXDisplay(), "WM_DELETE_WINDOW", False); - xa_wm_take_focus = XInternAtom(getXDisplay(), "WM_TAKE_FOCUS", False); - motif_wm_hints = XInternAtom(getXDisplay(), "_MOTIF_WM_HINTS", False); - - blackbox_hints = XInternAtom(getXDisplay(), "_BLACKBOX_HINTS", False); - blackbox_attributes = - XInternAtom(getXDisplay(), "_BLACKBOX_ATTRIBUTES", False); - blackbox_change_attributes = - XInternAtom(getXDisplay(), "_BLACKBOX_CHANGE_ATTRIBUTES", False); - blackbox_structure_messages = - XInternAtom(getXDisplay(), "_BLACKBOX_STRUCTURE_MESSAGES", False); - blackbox_notify_startup = - XInternAtom(getXDisplay(), "_BLACKBOX_NOTIFY_STARTUP", False); - blackbox_notify_window_add = - XInternAtom(getXDisplay(), "_BLACKBOX_NOTIFY_WINDOW_ADD", False); - blackbox_notify_window_del = - XInternAtom(getXDisplay(), "_BLACKBOX_NOTIFY_WINDOW_DEL", False); - blackbox_notify_current_workspace = - XInternAtom(getXDisplay(), "_BLACKBOX_NOTIFY_CURRENT_WORKSPACE", False); - blackbox_notify_workspace_count = - XInternAtom(getXDisplay(), "_BLACKBOX_NOTIFY_WORKSPACE_COUNT", False); - blackbox_notify_window_focus = - XInternAtom(getXDisplay(), "_BLACKBOX_NOTIFY_WINDOW_FOCUS", False); - blackbox_notify_window_raise = - XInternAtom(getXDisplay(), "_BLACKBOX_NOTIFY_WINDOW_RAISE", False); - blackbox_notify_window_lower = - XInternAtom(getXDisplay(), "_BLACKBOX_NOTIFY_WINDOW_LOWER", False); - blackbox_change_workspace = - XInternAtom(getXDisplay(), "_BLACKBOX_CHANGE_WORKSPACE", False); - blackbox_change_window_focus = - XInternAtom(getXDisplay(), "_BLACKBOX_CHANGE_WINDOW_FOCUS", False); - blackbox_cycle_window_focus = - XInternAtom(getXDisplay(), "_BLACKBOX_CYCLE_WINDOW_FOCUS", False); - -#ifdef NEWWMSPEC - net_supported = XInternAtom(getXDisplay(), "_NET_SUPPORTED", False); - net_client_list = XInternAtom(getXDisplay(), "_NET_CLIENT_LIST", False); - net_client_list_stacking = - XInternAtom(getXDisplay(), "_NET_CLIENT_LIST_STACKING", False); - net_number_of_desktops = - XInternAtom(getXDisplay(), "_NET_NUMBER_OF_DESKTOPS", False); - net_desktop_geometry = - XInternAtom(getXDisplay(), "_NET_DESKTOP_GEOMETRY", False); - net_desktop_viewport = - XInternAtom(getXDisplay(), "_NET_DESKTOP_VIEWPORT", False); - net_current_desktop = - XInternAtom(getXDisplay(), "_NET_CURRENT_DESKTOP", False); - net_desktop_names = XInternAtom(getXDisplay(), "_NET_DESKTOP_NAMES", False); - net_active_window = XInternAtom(getXDisplay(), "_NET_ACTIVE_WINDOW", False); - net_workarea = XInternAtom(getXDisplay(), "_NET_WORKAREA", False); - net_supporting_wm_check = - XInternAtom(getXDisplay(), "_NET_SUPPORTING_WM_CHECK", False); - net_virtual_roots = XInternAtom(getXDisplay(), "_NET_VIRTUAL_ROOTS", False); - net_close_window = XInternAtom(getXDisplay(), "_NET_CLOSE_WINDOW", False); - net_wm_moveresize = XInternAtom(getXDisplay(), "_NET_WM_MOVERESIZE", False); - net_properties = XInternAtom(getXDisplay(), "_NET_PROPERTIES", False); - net_wm_name = XInternAtom(getXDisplay(), "_NET_WM_NAME", False); - net_wm_desktop = XInternAtom(getXDisplay(), "_NET_WM_DESKTOP", False); - net_wm_window_type = - XInternAtom(getXDisplay(), "_NET_WM_WINDOW_TYPE", False); - net_wm_state = XInternAtom(getXDisplay(), "_NET_WM_STATE", False); - net_wm_strut = XInternAtom(getXDisplay(), "_NET_WM_STRUT", False); - net_wm_icon_geometry = - XInternAtom(getXDisplay(), "_NET_WM_ICON_GEOMETRY", False); - net_wm_icon = XInternAtom(getXDisplay(), "_NET_WM_ICON", False); - net_wm_pid = XInternAtom(getXDisplay(), "_NET_WM_PID", False); - net_wm_handled_icons = - XInternAtom(getXDisplay(), "_NET_WM_HANDLED_ICONS", False); - net_wm_ping = XInternAtom(getXDisplay(), "_NET_WM_PING", False); -#endif // NEWWMSPEC - -#ifdef HAVE_GETPID - blackbox_pid = XInternAtom(getXDisplay(), "_BLACKBOX_PID", False); -#endif // HAVE_GETPID }
M src/blackbox.hhsrc/blackbox.hh

@@ -51,6 +51,7 @@ #include "i18n.hh"

#include "BaseDisplay.hh" #include "Configuration.hh" #include "Timer.hh" +#include "XAtom.hh" #define AttribShaded (1l << 0) #define AttribMaxHoriz (1l << 1)

@@ -146,52 +147,13 @@ BScreen *active_screen;

BlackboxWindow *focused_window; BTimer *timer; Configuration config; + XAtom *xatom; bool no_focus, reconfigure_wait, reread_menu_wait; Time last_time; char **argv; std::string menu_file, rc_file; - Atom xa_wm_colormap_windows, xa_wm_protocols, xa_wm_state, - xa_wm_delete_window, xa_wm_take_focus, xa_wm_change_state, - motif_wm_hints; - - // NETAttributes - Atom blackbox_attributes, blackbox_change_attributes, blackbox_hints; -#ifdef HAVE_GETPID - Atom blackbox_pid; -#endif // HAVE_GETPID - - // NETStructureMessages - Atom 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; - - // message_types for client -> wm messages - Atom blackbox_change_workspace, blackbox_change_window_focus, - blackbox_cycle_window_focus; - -#ifdef NEWWMSPEC - // root window properties - Atom 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 - Atom net_close_window, net_wm_moveresize; - - // application window properties - Atom net_properties, net_wm_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; - - // application protocols - Atom net_wm_ping; -#endif // NEWWMSPEC - Blackbox(const Blackbox&); Blackbox& operator=(const Blackbox&);

@@ -199,8 +161,6 @@ void load_rc(void);

void save_rc(void); void real_rereadMenu(void); void real_reconfigure(void); - - void init_icccm(void); virtual void process_event(XEvent *);

@@ -227,6 +187,8 @@ void removeGroupSearch(Window window);

void removeToolbarSearch(Window window); void removeSlitSearch(Window window); + inline XAtom *getXAtom(void) { return xatom; } + inline BlackboxWindow *getFocusedWindow(void) { return focused_window; } inline Configuration *getConfig() { return &config; }

@@ -283,131 +245,67 @@ #ifndef HAVE_STRFTIME

enum { B_AmericanDate = 1, B_EuropeanDate }; #endif // HAVE_STRFTIME -#ifdef HAVE_GETPID - inline Atom getBlackboxPidAtom(void) const { return blackbox_pid; } -#endif // HAVE_GETPID - inline Atom getWMChangeStateAtom(void) const - { return xa_wm_change_state; } + { return xatom->getAtom(XAtom::wm_change_state); } inline Atom getWMStateAtom(void) const - { return xa_wm_state; } + { return xatom->getAtom(XAtom::wm_state); } inline Atom getWMDeleteAtom(void) const - { return xa_wm_delete_window; } + { return xatom->getAtom(XAtom::wm_delete_window); } inline Atom getWMProtocolsAtom(void) const - { return xa_wm_protocols; } + { return xatom->getAtom(XAtom::wm_protocols); } inline Atom getWMTakeFocusAtom(void) const - { return xa_wm_take_focus; } + { return xatom->getAtom(XAtom::wm_take_focus); } inline Atom getWMColormapAtom(void) const - { return xa_wm_colormap_windows; } + { return xatom->getAtom(XAtom::wm_colormap_windows); } inline Atom getMotifWMHintsAtom(void) const - { return motif_wm_hints; } + { return xatom->getAtom(XAtom::motif_wm_hints); } // this atom is for normal app->WM hints about decorations, stacking, // starting workspace etc... inline Atom getBlackboxHintsAtom(void) const - { return blackbox_hints;} + { return xatom->getAtom(XAtom::blackbox_hints); } // these atoms are for normal app->WM interaction beyond the scope of the // ICCCM... inline Atom getBlackboxAttributesAtom(void) const - { return blackbox_attributes; } + { return xatom->getAtom(XAtom::blackbox_attributes); } inline Atom getBlackboxChangeAttributesAtom(void) const - { return blackbox_change_attributes; } + { return xatom->getAtom(XAtom::blackbox_change_attributes); } // these atoms are for window->WM interaction, with more control and // information on window "structure"... common examples are // notifying apps when windows are raised/lowered... when the user changes // workspaces... i.e. "pager talk" inline Atom getBlackboxStructureMessagesAtom(void) const - { return blackbox_structure_messages; } + { return xatom->getAtom(XAtom::blackbox_structure_messages); } // *Notify* portions of the NETStructureMessages protocol inline Atom getBlackboxNotifyStartupAtom(void) const - { return blackbox_notify_startup; } + { return xatom->getAtom(XAtom::blackbox_notify_startup); } inline Atom getBlackboxNotifyWindowAddAtom(void) const - { return blackbox_notify_window_add; } + { return xatom->getAtom(XAtom::blackbox_notify_window_add); } inline Atom getBlackboxNotifyWindowDelAtom(void) const - { return blackbox_notify_window_del; } + { return xatom->getAtom(XAtom::blackbox_notify_window_del); } inline Atom getBlackboxNotifyWindowFocusAtom(void) const - { return blackbox_notify_window_focus; } + { return xatom->getAtom(XAtom::blackbox_notify_window_focus); } inline Atom getBlackboxNotifyCurrentWorkspaceAtom(void) const - { return blackbox_notify_current_workspace; } + { return xatom->getAtom(XAtom::blackbox_notify_current_workspace); } inline Atom getBlackboxNotifyWorkspaceCountAtom(void) const - { return blackbox_notify_workspace_count; } + { return xatom->getAtom(XAtom::blackbox_notify_workspace_count); } inline Atom getBlackboxNotifyWindowRaiseAtom(void) const - { return blackbox_notify_window_raise; } + { return xatom->getAtom(XAtom::blackbox_notify_window_raise); } inline Atom getBlackboxNotifyWindowLowerAtom(void) const - { return blackbox_notify_window_lower; } + { return xatom->getAtom(XAtom::blackbox_notify_window_lower); } // atoms to change that request changes to the desktop environment during // runtime... these messages can be sent by any client... as the sending // client window id is not included in the ClientMessage event... inline Atom getBlackboxChangeWorkspaceAtom(void) const - { return blackbox_change_workspace; } + { return xatom->getAtom(XAtom::blackbox_change_workspace); } inline Atom getBlackboxChangeWindowFocusAtom(void) const - { return blackbox_change_window_focus; } + { return xatom->getAtom(XAtom::blackbox_change_window_focus); } inline Atom getBlackboxCycleWindowFocusAtom(void) const - { return blackbox_cycle_window_focus; } - -#ifdef NEWWMSPEC - // root window properties - inline Atom getNETSupportedAtom(void) const - { return net_supported; } - inline Atom getNETClientListAtom(void) const - { return net_client_list; } - inline Atom getNETClientListStackingAtom(void) const - { return net_client_list_stacking; } - inline Atom getNETNumberOfDesktopsAtom(void) const - { return net_number_of_desktops; } - inline Atom getNETDesktopGeometryAtom(void) const - { return net_desktop_geometry; } - inline Atom getNETDesktopViewportAtom(void) const - { return net_desktop_viewport; } - inline Atom getNETCurrentDesktopAtom(void) const - { return net_current_desktop; } - inline Atom getNETDesktopNamesAtom(void) const - { return net_desktop_names; } - inline Atom getNETActiveWindowAtom(void) const - { return net_active_window; } - inline Atom getNETWorkareaAtom(void) const - { return net_workarea; } - inline Atom getNETSupportingWMCheckAtom(void) const - { return net_supporting_wm_check; } - inline Atom getNETVirtualRootsAtom(void) const - { return net_virtual_roots; } - - // root window messages - inline Atom getNETCloseWindowAtom(void) const - { return net_close_window; } - inline Atom getNETWMMoveResizeAtom(void) const - { return net_wm_moveresize; } - - // application window properties - inline Atom getNETPropertiesAtom(void) const - { return net_properties; } - inline Atom getNETWMNameAtom(void) const - { return net_wm_name; } - inline Atom getNETWMDesktopAtom(void) const - { return net_wm_desktop; } - inline Atom getNETWMWindowTypeAtom(void) const - { return net_wm_window_type; } - inline Atom getNETWMStateAtom(void) const - { return net_wm_state; } - inline Atom getNETWMStrutAtom(void) const - { return net_wm_strut; } - inline Atom getNETWMIconGeometryAtom(void) const - { return net_wm_icon_geometry; } - inline Atom getNETWMIconAtom(void) const - { return net_wm_icon; } - inline Atom getNETWMPidAtom(void) const - { return net_wm_pid; } - inline Atom getNETWMHandledIconsAtom(void) const - { return net_wm_handled_icons; } - - // application protocols - inline Atom getNETWMPingAtom(void) const - { return net_wm_ping; } -#endif // NEWWMSPEC + { return xatom->getAtom(XAtom::blackbox_cycle_window_focus); } };