_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");
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[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");
}
switch (type) {
case ansi: t = _atoms[string]; break;
case utf8: t = _atoms[utf8_string]; break;
- default: assert(False); // unhandled StringType
+ default: assert(False); return; // unhandled StringType
}
setValue(win, _atoms[atom], t,
reinterpret_cast<unsigned char *>(const_cast<char *>(value.c_str())),
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 with c malloc
+ 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;
- const unsigned long maxread = nelements;
+ 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);
- if (result != Success || ret_type != type || ret_size != size ||
- nelements < 1) {
- // an error occured, the property does not exist on the window, or is empty,
- // or the wrong data is in property for the request
- if (c_val) XFree(c_val);
- return False;
- }
- // the data is correct, now, is there more elements left?
- 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);
- XFree(c_val);
- return True;
+ 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);
+ }
}
- // 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);
- assert(result == Success);
- 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;
+ if (c_val) XFree(c_val);
+ return ret;
}
switch (type) {
case ansi: t = _atoms[string]; break;
case utf8: t = _atoms[utf8_string]; break;
- default: assert(False); return // unhandled StringType
+ default: assert(False); return False; // unhandled StringType
}
unsigned char *value;
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;
- ++num;
}
nelements = num;
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);
+}