X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=otk%2Fproperty.cc;h=3b0750111ad0dc1c23a55a7c5a75776dcfa7e5c0;hb=3147507622de5ab771c99a4bb636f55344f6cbd7;hp=a51a2353318f994731d99f443d8f21a854fed1ff;hpb=d8aff44a6a639de83ba8f0957f9f9f17f2a05532;p=chaz%2Fopenbox diff --git a/otk/property.cc b/otk/property.cc index a51a2353..3b075011 100644 --- a/otk/property.cc +++ b/otk/property.cc @@ -1,19 +1,16 @@ // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*- -#ifdef HAVE_CONFIG_H -# include "../config.h" -#endif // HAVE_CONFIG_H +#include "config.h" #include "property.hh" #include "display.hh" extern "C" { #include - -#include } #include +#include namespace otk { @@ -64,6 +61,8 @@ void Property::initialize() 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_desktop_layout = create("_NET_DESKTOP_LAYOUT"); + atoms.net_showing_desktop = create("_NET_SHOWING_DESKTOP"); atoms.net_close_window = create("_NET_CLOSE_WINDOW"); atoms.net_wm_moveresize = create("_NET_WM_MOVERESIZE"); @@ -78,7 +77,7 @@ void Property::initialize() 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_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"); @@ -107,9 +106,12 @@ void Property::initialize() atoms.net_wm_action_move = create("_NET_WM_ACTION_MOVE"); atoms.net_wm_action_resize = create("_NET_WM_ACTION_RESIZE"); + atoms.net_wm_action_minimize = create("_NET_WM_ACTION_MINIMIZE"); atoms.net_wm_action_shade = create("_NET_WM_ACTION_SHADE"); + atoms.net_wm_action_stick = create("_NET_WM_ACTION_STICK"); 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_fullscreen = create("_NET_WM_ACTION_FULLSCREEN"); atoms.net_wm_action_change_desktop = create("_NET_WM_ACTION_CHANGE_DESKTOP"); atoms.net_wm_action_close = create("_NET_WM_ACTION_CLOSE"); @@ -126,11 +128,24 @@ void Property::initialize() atoms.net_wm_state_above = create("_NET_WM_STATE_ABOVE"); atoms.net_wm_state_below = create("_NET_WM_STATE_BELOW"); + atoms.net_wm_state_add = 1; + atoms.net_wm_state_remove = 0; + atoms.net_wm_state_toggle = 2; + 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"); + + atoms.kwm_win_icon = create("KWM_WIN_ICON"); + + atoms.rootpmapid = create("_XROOTPMAP_ID"); + atoms.esetrootid = create("ESETROOT_PMAP_ID"); + + atoms.openbox_premax = create("_OPENBOX_PREMAX"); + atoms.openbox_active_window = create("_OPENBOX_ACTIVE_WINDOW"); + atoms.openbox_restack_window = create("_OPENBOX_RESTACK_WINDOW"); } void Property::set(Window win, Atom atom, Atom type, unsigned char* data, @@ -201,13 +216,11 @@ bool Property::get(Window win, Atom atom, Atom type, unsigned long *nelements, { 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 @@ -217,7 +230,7 @@ bool Property::get(Window win, Atom atom, Atom type, unsigned long *nelements, ret = (result == Success && ret_type == type && ret_size == size && *nelements > 0); if (ret) { - if (ret_bytes == 0 || maxread <= *nelements) { + 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); @@ -226,21 +239,19 @@ bool Property::get(Window win, Atom atom, Atom type, unsigned long *nelements, 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; + long remain = (ret_bytes - 1)/sizeof(long) + 1 + 1; 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); + ret = (result == Success && ret_type == type && ret_size == size); /* 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 get(win, atom, type, &maxread, value, size); + if (! ret) { + return get(win, atom, type, nelements, value, size); + } *value = new unsigned char[*nelements * size/8 + 1]; memcpy(*value, c_val, *nelements * size/8 + 1); @@ -259,20 +270,23 @@ bool Property::get(Window win, Atom atom, Atom type, unsigned long *nelements, bool Property::get(Window win, Atom atom, Atom type, unsigned long *value) { unsigned long *temp; - unsigned long num = 1; + unsigned long num; if (! get(win, atom, type, &num, (unsigned char **) &temp, 32)) return false; - *value = temp[0]; - delete [] temp; - return true; + if (num >= 1) { + *value = temp[0]; + delete [] temp; + return true; + } + return false; } bool Property::get(Window win, Atom atom, StringType type, ustring *value) { - unsigned long n = 1; + unsigned long n; StringVect s; - if (get(win, atom, type, &n, &s)) { + if (get(win, atom, type, &n, &s) && n > 0) { *value = s[0]; return true; } @@ -282,8 +296,6 @@ bool Property::get(Window win, Atom atom, StringType type, ustring *value) bool Property::get(Window win, Atom atom, StringType type, unsigned long *nelements, StringVect *strings) { - assert(*nelements > 0); - Atom t; bool u; // utf8 encoded? switch (type) { @@ -293,7 +305,7 @@ bool Property::get(Window win, Atom atom, StringType type, } unsigned char *value; - unsigned long elements = (unsigned) -1; + unsigned long elements;; if (!get(win, atom, t, &elements, &value, 8) || elements < 1) return false; @@ -302,7 +314,7 @@ bool Property::get(Window win, Atom atom, StringType type, std::string::const_iterator it = s.begin(), end = s.end(); unsigned long num = 0; - while(num < *nelements) { + while(true) { 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)