2002-10-02 16:26:05 +00:00
|
|
|
// Ewmh.cc for fluxbox
|
2006-02-16 06:53:05 +00:00
|
|
|
// Copyright (c) 2002 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org)
|
2002-10-02 16:26:05 +00:00
|
|
|
//
|
|
|
|
// 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,
|
2003-03-04 11:06:03 +00:00
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
2002-10-02 16:26:05 +00:00
|
|
|
// 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.
|
|
|
|
|
2004-09-10 15:36:04 +00:00
|
|
|
#include "Ewmh.hh"
|
2002-10-02 16:26:05 +00:00
|
|
|
|
|
|
|
#include "Screen.hh"
|
|
|
|
#include "Window.hh"
|
2003-04-14 12:13:36 +00:00
|
|
|
#include "WinClient.hh"
|
2003-04-25 11:15:01 +00:00
|
|
|
#include "Workspace.hh"
|
2006-02-20 21:04:35 +00:00
|
|
|
#include "Layer.hh"
|
2006-04-23 21:42:11 +00:00
|
|
|
#include "fluxbox.hh"
|
2006-07-22 07:15:24 +00:00
|
|
|
#include "FbWinFrameTheme.hh"
|
2006-07-29 06:28:58 +00:00
|
|
|
#include "FocusControl.hh"
|
2010-03-17 15:35:07 +00:00
|
|
|
#include "Debug.hh"
|
2006-04-23 17:00:33 +00:00
|
|
|
|
2006-02-20 21:04:35 +00:00
|
|
|
#include "FbTk/App.hh"
|
2004-01-19 18:21:51 +00:00
|
|
|
#include "FbTk/FbWindow.hh"
|
2004-06-07 11:46:05 +00:00
|
|
|
#include "FbTk/I18n.hh"
|
2011-02-23 21:49:27 +00:00
|
|
|
#include "FbTk/LayerItem.hh"
|
|
|
|
#include "FbTk/Layer.hh"
|
2008-02-24 20:58:24 +00:00
|
|
|
#include "FbTk/FbPixmap.hh"
|
2004-01-19 18:21:51 +00:00
|
|
|
|
2008-02-24 20:58:24 +00:00
|
|
|
#include <X11/Xproto.h>
|
2007-12-30 06:44:11 +00:00
|
|
|
#include <X11/Xatom.h>
|
2009-10-01 06:41:04 +00:00
|
|
|
|
2002-10-02 16:26:05 +00:00
|
|
|
#include <iostream>
|
2003-04-14 12:13:36 +00:00
|
|
|
#include <algorithm>
|
2002-11-26 19:49:40 +00:00
|
|
|
#include <new>
|
2009-10-01 06:41:04 +00:00
|
|
|
|
2007-06-29 17:25:24 +00:00
|
|
|
#ifdef HAVE_CSTRING
|
|
|
|
#include <cstring>
|
|
|
|
#else
|
|
|
|
#include <string.h>
|
|
|
|
#endif
|
2004-10-21 10:57:38 +00:00
|
|
|
|
2009-10-01 06:41:04 +00:00
|
|
|
#ifdef HAVE_CSTDLIB
|
|
|
|
#include <cstdlib>
|
|
|
|
#else
|
|
|
|
#include <stdlib.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2006-10-30 19:31:15 +00:00
|
|
|
using std::cerr;
|
|
|
|
using std::endl;
|
|
|
|
using std::vector;
|
|
|
|
using std::list;
|
2002-10-02 16:26:05 +00:00
|
|
|
|
2004-10-21 10:57:38 +00:00
|
|
|
// mipspro has no new(nothrow)
|
|
|
|
#if defined sgi && ! defined GCC
|
|
|
|
#define FB_new_nothrow new
|
|
|
|
#else
|
|
|
|
#define FB_new_nothrow new(std::nothrow)
|
|
|
|
#endif
|
|
|
|
|
2008-01-02 21:41:50 +00:00
|
|
|
|
2008-02-24 20:58:24 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
/* From Extended Window Manager Hints, draft 1.3:
|
|
|
|
*
|
|
|
|
* _NET_WM_ICON CARDINAL[][2+n]/32
|
|
|
|
*
|
|
|
|
* This is an array of possible icons for the client. This specification does
|
|
|
|
* not stipulate what size these icons should be, but individual desktop
|
|
|
|
* environments or toolkits may do so. The Window Manager MAY scale any of
|
|
|
|
* these icons to an appropriate size.
|
|
|
|
*
|
|
|
|
* This is an array of 32bit packed CARDINAL ARGB with high byte being A, low
|
|
|
|
* byte being B. The first two cardinals are width, height. Data is in rows,
|
|
|
|
* left to right and top to bottom.
|
2008-03-05 08:24:40 +00:00
|
|
|
*
|
2008-09-23 07:13:53 +00:00
|
|
|
***
|
|
|
|
*
|
|
|
|
* NOTE: the returned data for XA_CARDINAL is long if the rfmt equals
|
|
|
|
* 32. sizeof(long) on 64bit machines is 8. to quote from
|
|
|
|
* "man XGetWindowProperty":
|
|
|
|
*
|
|
|
|
* If the returned format is 32, the property data will be stored as
|
|
|
|
* an array of longs (which in a 64-bit application will be 64-bit
|
|
|
|
* values that are padded in the upper 4 bytes).
|
|
|
|
*
|
|
|
|
* this is especially true on 64bit machines when some of the clients
|
|
|
|
* (eg: tvtime, konqueror3) have problems to feed in the right data
|
|
|
|
* into the _NET_WM_ICON property. we faced some segfaults because
|
|
|
|
* width and height were not quite right because of ignoring 64bit
|
|
|
|
* behaviour on client side.
|
|
|
|
*
|
2008-03-05 08:24:40 +00:00
|
|
|
* TODO: maybe move the pixmap-creation code to FbTk? */
|
2008-02-24 20:58:24 +00:00
|
|
|
void extractNetWmIcon(Atom net_wm_icon, WinClient& winclient) {
|
|
|
|
|
|
|
|
typedef std::pair<int, int> Size;
|
|
|
|
typedef std::map<Size, const unsigned long*> IconContainer;
|
|
|
|
|
|
|
|
unsigned long* raw_data = 0;
|
2008-09-23 07:13:53 +00:00
|
|
|
unsigned long nr_icon_data = 0;
|
2008-02-24 20:58:24 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
Atom rtype;
|
|
|
|
int rfmt;
|
|
|
|
unsigned long nr_read;
|
|
|
|
unsigned long nr_bytes_left;
|
|
|
|
|
|
|
|
// no data or no _NET_WM_ICON
|
|
|
|
if (! winclient.property(net_wm_icon, 0L, 0L, False, XA_CARDINAL,
|
|
|
|
&rtype, &rfmt, &nr_read, &nr_bytes_left,
|
|
|
|
reinterpret_cast<unsigned char**>(&raw_data)) || nr_bytes_left == 0) {
|
|
|
|
|
|
|
|
if (raw_data)
|
|
|
|
XFree(raw_data);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// actually there is some data in _NET_WM_ICON
|
|
|
|
nr_icon_data = nr_bytes_left / sizeof(CARD32);
|
2010-03-17 15:35:07 +00:00
|
|
|
|
2010-09-08 18:17:21 +00:00
|
|
|
fbdbg << "extractNetWmIcon: " << winclient.title().logical() << "\n";
|
2010-03-17 15:35:07 +00:00
|
|
|
fbdbg << "nr_icon_data: " << nr_icon_data << "\n";
|
|
|
|
|
2008-02-24 20:58:24 +00:00
|
|
|
// read all the icons stored in _NET_WM_ICON
|
2008-08-22 09:23:29 +00:00
|
|
|
if (raw_data)
|
2008-09-11 14:21:51 +00:00
|
|
|
XFree(raw_data);
|
|
|
|
|
|
|
|
// something went wrong
|
|
|
|
if (!winclient.property(net_wm_icon, 0L, nr_icon_data, False, XA_CARDINAL,
|
2008-02-24 20:58:24 +00:00
|
|
|
&rtype, &rfmt, &nr_read, &nr_bytes_left,
|
2008-09-11 14:21:51 +00:00
|
|
|
reinterpret_cast<unsigned char**>(&raw_data))) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2010-03-17 15:35:07 +00:00
|
|
|
|
|
|
|
fbdbg << "nr_read: " << nr_read << "|" << nr_bytes_left << "\n";
|
|
|
|
|
2008-02-24 20:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
IconContainer icon_data; // stores all available data, sorted by size (width x height)
|
2008-09-23 07:13:53 +00:00
|
|
|
unsigned long width;
|
|
|
|
unsigned long height;
|
2008-02-24 20:58:24 +00:00
|
|
|
|
|
|
|
// analyze the available icons
|
2008-09-23 07:13:53 +00:00
|
|
|
//
|
|
|
|
// check also for invalid values coming in from "bad" applications
|
|
|
|
unsigned long i;
|
2008-09-11 14:21:51 +00:00
|
|
|
for (i = 0; i + 2 < nr_icon_data; i += width * height ) {
|
2008-02-24 20:58:24 +00:00
|
|
|
|
|
|
|
width = raw_data[i++];
|
2008-09-23 07:13:53 +00:00
|
|
|
if (width >= nr_icon_data) {
|
2010-03-17 15:35:07 +00:00
|
|
|
|
|
|
|
fbdbg << "Ewmh.cc extractNetWmIcon found strange _NET_WM_ICON width ("
|
2010-09-08 18:17:21 +00:00
|
|
|
<< width << ") for " << winclient.title().logical() << "\n";
|
2008-09-23 07:13:53 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-02-24 20:58:24 +00:00
|
|
|
height = raw_data[i++];
|
2008-09-23 07:13:53 +00:00
|
|
|
if (height >= nr_icon_data) {
|
2010-03-17 15:35:07 +00:00
|
|
|
|
|
|
|
fbdbg << "Ewmh.cc extractNetWmIcon found strange _NET_WM_ICON height ("
|
2010-09-08 18:17:21 +00:00
|
|
|
<< height << ") for " << winclient.title().logical() << "\n";
|
2010-03-17 15:35:07 +00:00
|
|
|
|
2008-09-23 07:13:53 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-02-24 20:58:24 +00:00
|
|
|
|
2008-09-11 14:21:51 +00:00
|
|
|
// strange values stored in the NETWM_ICON
|
2008-09-23 07:13:53 +00:00
|
|
|
if (i + width * height > nr_icon_data) {
|
2010-03-17 15:35:07 +00:00
|
|
|
fbdbg << "Ewmh.cc extractNetWmIcon found strange _NET_WM_ICON dimensions ("
|
2010-09-08 18:17:21 +00:00
|
|
|
|
|
|
|
<< width << "x" << height << ")for " << winclient.title().logical() << "\n";
|
2010-03-17 15:35:07 +00:00
|
|
|
|
2008-09-23 07:13:53 +00:00
|
|
|
break;
|
2008-09-11 14:21:51 +00:00
|
|
|
}
|
|
|
|
|
2008-02-24 20:58:24 +00:00
|
|
|
icon_data[Size(width, height)] = &raw_data[i];
|
|
|
|
}
|
|
|
|
|
2008-09-23 07:13:53 +00:00
|
|
|
// no valid icons found at all
|
|
|
|
if (icon_data.empty()) {
|
|
|
|
XFree(raw_data);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-02-24 20:58:24 +00:00
|
|
|
Display* dpy = FbTk::App::instance()->display();
|
|
|
|
int scrn = winclient.screen().screenNumber();
|
|
|
|
|
|
|
|
// pick the smallest icon size atm
|
|
|
|
// TODO: find a better criteria
|
|
|
|
width = icon_data.begin()->first.first;
|
|
|
|
height = icon_data.begin()->first.second;
|
|
|
|
|
|
|
|
// tmp image for the pixmap
|
|
|
|
XImage* img_pm = XCreateImage(dpy, DefaultVisual(dpy, scrn), winclient.depth(),
|
|
|
|
ZPixmap,
|
|
|
|
0, NULL, width, height, 32, 0);
|
|
|
|
if (!img_pm) {
|
|
|
|
XFree(raw_data);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// tmp image for the mask
|
|
|
|
XImage* img_mask = XCreateImage(dpy, DefaultVisual(dpy, scrn), 1,
|
|
|
|
XYBitmap,
|
|
|
|
0, NULL, width, height, 32, 0);
|
|
|
|
|
|
|
|
if (!img_mask) {
|
|
|
|
XFree(raw_data);
|
|
|
|
XDestroyImage(img_pm);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// allocate some memory for the icons at client side
|
2008-06-07 13:14:23 +00:00
|
|
|
img_pm->data = static_cast<char*>(malloc(img_pm->bytes_per_line * height));
|
|
|
|
img_mask->data = static_cast<char*>(malloc(img_mask->bytes_per_line * height));
|
2008-02-24 20:58:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
const unsigned long* src = icon_data.begin()->second;
|
2008-03-05 08:24:40 +00:00
|
|
|
unsigned int rgba;
|
|
|
|
unsigned long pixel;
|
2008-09-23 07:13:53 +00:00
|
|
|
unsigned long x;
|
|
|
|
unsigned long y;
|
2008-02-24 20:58:24 +00:00
|
|
|
unsigned char r, g, b, a;
|
|
|
|
|
|
|
|
for (y = 0; y < height; y++) {
|
|
|
|
for (x = 0; x < width; x++, src++) {
|
|
|
|
|
2008-03-05 08:24:40 +00:00
|
|
|
rgba = *src; // use only 32bit
|
|
|
|
|
|
|
|
a = ( rgba & 0xff000000 ) >> 24;
|
|
|
|
r = ( rgba & 0x00ff0000 ) >> 16;
|
|
|
|
g = ( rgba & 0x0000ff00 ) >> 8;
|
|
|
|
b = ( rgba & 0x000000ff );
|
|
|
|
|
|
|
|
// 15 bit display, 5R 5G 5B
|
|
|
|
if (img_pm->red_mask == 0x7c00
|
|
|
|
&& img_pm->green_mask == 0x03e0
|
|
|
|
&& img_pm->blue_mask == 0x1f) {
|
|
|
|
|
|
|
|
pixel = ((r << 7) & 0x7c00) | ((g << 2) & 0x03e0) | ((b >> 3) & 0x001f);
|
|
|
|
|
|
|
|
// 16 bit display, 5R 6G 5B
|
|
|
|
} else if (img_pm->red_mask == 0xf800
|
|
|
|
&& img_pm->green_mask == 0x07e0
|
|
|
|
&& img_pm->blue_mask == 0x1f) {
|
|
|
|
|
|
|
|
pixel = ((r << 8) & 0xf800) | ((g << 3) & 0x07e0) | ((b >> 3) & 0x001f);
|
|
|
|
|
|
|
|
// 24/32 bit display, 8R 8G 8B
|
|
|
|
} else if (img_pm->red_mask == 0xff0000
|
|
|
|
&& img_pm->green_mask == 0xff00
|
|
|
|
&& img_pm->blue_mask == 0xff) {
|
|
|
|
|
|
|
|
pixel = rgba & 0x00ffffff;
|
2008-02-24 20:58:24 +00:00
|
|
|
|
2008-03-05 08:24:40 +00:00
|
|
|
} else {
|
|
|
|
pixel = 0;
|
|
|
|
}
|
2008-02-24 20:58:24 +00:00
|
|
|
|
2008-03-05 08:24:40 +00:00
|
|
|
// transfer rgb data
|
|
|
|
XPutPixel(img_pm, x, y, pixel);
|
2008-02-24 20:58:24 +00:00
|
|
|
|
|
|
|
// transfer mask data
|
|
|
|
XPutPixel(img_mask, x, y, a > 127 ? 0 : 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// the final icon
|
|
|
|
FbTk::PixmapWithMask icon;
|
|
|
|
icon.pixmap() = FbTk::FbPixmap(winclient.drawable(), width, height, winclient.depth());
|
|
|
|
icon.mask() = FbTk::FbPixmap(winclient.drawable(), width, height, 1);
|
|
|
|
|
|
|
|
FbTk::GContext gc_pm(icon.pixmap());
|
|
|
|
FbTk::GContext gc_mask(icon.mask());
|
|
|
|
|
|
|
|
XPutImage(dpy, icon.pixmap().drawable(), gc_pm.gc(), img_pm, 0, 0, 0, 0, width, height);
|
|
|
|
XPutImage(dpy, icon.mask().drawable(), gc_mask.gc(), img_mask, 0, 0, 0, 0, width, height);
|
|
|
|
|
2008-03-05 08:24:40 +00:00
|
|
|
XDestroyImage(img_pm); // frees img_pm->data as well
|
|
|
|
XDestroyImage(img_mask); // frees img_mask->data as well
|
2008-02-24 20:58:24 +00:00
|
|
|
|
|
|
|
XFree(raw_data);
|
|
|
|
|
|
|
|
winclient.setIcon(icon);
|
|
|
|
}
|
|
|
|
|
2009-09-30 19:02:24 +00:00
|
|
|
} // end anonymous namespace
|
2008-02-24 20:58:24 +00:00
|
|
|
|
2008-01-02 21:41:50 +00:00
|
|
|
class Ewmh::EwmhAtoms {
|
|
|
|
public:
|
|
|
|
|
|
|
|
EwmhAtoms() {
|
|
|
|
Display *disp = FbTk::App::instance()->display();
|
|
|
|
|
|
|
|
supported = XInternAtom(disp, "_NET_SUPPORTED", False);
|
|
|
|
client_list = XInternAtom(disp, "_NET_CLIENT_LIST", False);
|
|
|
|
client_list_stacking = XInternAtom(disp, "_NET_CLIENT_LIST_STACKING", False);
|
|
|
|
number_of_desktops = XInternAtom(disp, "_NET_NUMBER_OF_DESKTOPS", False);
|
|
|
|
desktop_geometry = XInternAtom(disp, "_NET_DESKTOP_GEOMETRY", False);
|
|
|
|
desktop_viewport = XInternAtom(disp, "_NET_DESKTOP_VIEWPORT", False);
|
|
|
|
current_desktop = XInternAtom(disp, "_NET_CURRENT_DESKTOP", False);
|
|
|
|
desktop_names = XInternAtom(disp, "_NET_DESKTOP_NAMES", False);
|
|
|
|
active_window = XInternAtom(disp, "_NET_ACTIVE_WINDOW", False);
|
|
|
|
workarea = XInternAtom(disp, "_NET_WORKAREA", False);
|
|
|
|
supporting_wm_check = XInternAtom(disp, "_NET_SUPPORTING_WM_CHECK", False);
|
|
|
|
virtual_roots = XInternAtom(disp, "_NET_VIRTUAL_ROOTS", False);
|
|
|
|
|
|
|
|
close_window = XInternAtom(disp, "_NET_CLOSE_WINDOW", False);
|
|
|
|
moveresize_window = XInternAtom(disp, "_NET_MOVERESIZE_WINDOW", False);
|
|
|
|
restack_window = XInternAtom(disp, "_NET_RESTACK_WINDOW", False);
|
|
|
|
request_frame_extents = XInternAtom(disp,
|
|
|
|
"_NET_REQUEST_FRAME_EXTENTS", False);
|
|
|
|
|
|
|
|
|
|
|
|
wm_moveresize = XInternAtom(disp, "_NET_WM_MOVERESIZE", False);
|
|
|
|
|
|
|
|
properties = XInternAtom(disp, "_NET_PROPERTIES", False);
|
|
|
|
wm_name = XInternAtom(disp, "_NET_WM_NAME", False);
|
|
|
|
wm_icon_name = XInternAtom(disp, "_NET_WM_ICON_NAME", False);
|
|
|
|
wm_desktop = XInternAtom(disp, "_NET_WM_DESKTOP", False);
|
|
|
|
|
|
|
|
// type atoms
|
|
|
|
wm_window_type = XInternAtom(disp, "_NET_WM_WINDOW_TYPE", False);
|
|
|
|
wm_window_type_dock = XInternAtom(disp, "_NET_WM_WINDOW_TYPE_DOCK", False);
|
|
|
|
wm_window_type_desktop = XInternAtom(disp, "_NET_WM_WINDOW_TYPE_DESKTOP", False);
|
|
|
|
wm_window_type_splash = XInternAtom(disp, "_NET_WM_WINDOW_TYPE_SPLASH", False);
|
|
|
|
wm_window_type_dialog = XInternAtom(disp, "_NET_WM_WINDOW_TYPE_DIALOG", False);
|
|
|
|
wm_window_type_menu = XInternAtom(disp, "_NET_WM_WINDOW_TYPE_MENU", False);
|
|
|
|
wm_window_type_toolbar = XInternAtom(disp, "_NET_WM_WINDOW_TYPE_TOOLBAR", False);
|
|
|
|
wm_window_type_normal = XInternAtom(disp, "_NET_WM_WINDOW_TYPE_NORMAL", False);
|
|
|
|
|
|
|
|
// state atom and the supported state atoms
|
|
|
|
wm_state = XInternAtom(disp, "_NET_WM_STATE", False);
|
|
|
|
wm_state_sticky = XInternAtom(disp, "_NET_WM_STATE_STICKY", False);
|
|
|
|
wm_state_shaded = XInternAtom(disp, "_NET_WM_STATE_SHADED", False);
|
|
|
|
wm_state_maximized_horz = XInternAtom(disp, "_NET_WM_STATE_MAXIMIZED_HORZ", False);
|
|
|
|
wm_state_maximized_vert = XInternAtom(disp, "_NET_WM_STATE_MAXIMIZED_VERT", False);
|
|
|
|
wm_state_fullscreen = XInternAtom(disp, "_NET_WM_STATE_FULLSCREEN", False);
|
|
|
|
wm_state_hidden = XInternAtom(disp, "_NET_WM_STATE_HIDDEN", False);
|
|
|
|
wm_state_skip_taskbar = XInternAtom(disp, "_NET_WM_STATE_SKIP_TASKBAR", False);
|
|
|
|
wm_state_skip_pager = XInternAtom(disp, "_NET_WM_STATE_SKIP_PAGER", False);
|
|
|
|
wm_state_above = XInternAtom(disp, "_NET_WM_STATE_ABOVE", False);
|
|
|
|
wm_state_below = XInternAtom(disp, "_NET_WM_STATE_BELOW", False);
|
|
|
|
wm_state_modal = XInternAtom(disp, "_NET_WM_STATE_MODAL", False);
|
|
|
|
wm_state_demands_attention = XInternAtom(disp, "_NET_WM_STATE_DEMANDS_ATTENTION", False);
|
|
|
|
|
|
|
|
// allowed actions
|
|
|
|
wm_allowed_actions = XInternAtom(disp, "_NET_WM_ALLOWED_ACTIONS", False);
|
|
|
|
wm_action_move = XInternAtom(disp, "_NET_WM_ACTION_MOVE", False);
|
|
|
|
wm_action_resize = XInternAtom(disp, "_NET_WM_ACTION_RESIZE", False);
|
|
|
|
wm_action_minimize = XInternAtom(disp, "_NET_WM_ACTION_MINIMIZE", False);
|
|
|
|
wm_action_shade = XInternAtom(disp, "_NET_WM_ACTION_SHADE", False);
|
|
|
|
wm_action_stick = XInternAtom(disp, "_NET_WM_ACTION_STICK", False);
|
|
|
|
wm_action_maximize_horz = XInternAtom(disp, "_NET_WM_ACTION_MAXIMIZE_HORZ", False);
|
|
|
|
wm_action_maximize_vert = XInternAtom(disp, "_NET_WM_ACTION_MAXIMIZE_VERT", False);
|
|
|
|
wm_action_fullscreen = XInternAtom(disp, "_NET_WM_ACTION_FULLSCREEN", False);
|
|
|
|
wm_action_change_desktop = XInternAtom(disp, "_NET_WM_ACTION_CHANGE_DESKTOP", False);
|
|
|
|
wm_action_close = XInternAtom(disp, "_NET_WM_ACTION_CLOSE", False);
|
|
|
|
|
|
|
|
wm_strut = XInternAtom(disp, "_NET_WM_STRUT", False);
|
|
|
|
wm_icon_geometry = XInternAtom(disp, "_NET_WM_ICON_GEOMETRY", False);
|
|
|
|
wm_icon = XInternAtom(disp, "_NET_WM_ICON", False);
|
|
|
|
wm_pid = XInternAtom(disp, "_NET_WM_PID", False);
|
|
|
|
wm_handled_icons = XInternAtom(disp, "_NET_WM_HANDLED_ICONS", False);
|
|
|
|
|
|
|
|
frame_extents = XInternAtom(disp, "_NET_FRAME_EXTENTS", False);
|
|
|
|
|
|
|
|
wm_ping = XInternAtom(disp, "_NET_WM_PING", False);
|
|
|
|
utf8_string = XInternAtom(disp, "UTF8_STRING", False);
|
|
|
|
};
|
|
|
|
|
|
|
|
// root window properties
|
|
|
|
Atom supported,
|
|
|
|
client_list,
|
|
|
|
client_list_stacking,
|
|
|
|
number_of_desktops,
|
|
|
|
desktop_geometry,
|
|
|
|
desktop_viewport,
|
|
|
|
current_desktop,
|
|
|
|
desktop_names,
|
|
|
|
active_window,
|
|
|
|
workarea,
|
|
|
|
supporting_wm_check,
|
|
|
|
virtual_roots,
|
|
|
|
moveresize_window,
|
|
|
|
restack_window,
|
|
|
|
request_frame_extents;
|
|
|
|
|
|
|
|
// root window messages
|
|
|
|
Atom close_window,
|
|
|
|
wm_moveresize;
|
|
|
|
|
|
|
|
// application window properties
|
|
|
|
Atom properties,
|
|
|
|
wm_name,
|
|
|
|
wm_icon_name,
|
|
|
|
wm_desktop,
|
|
|
|
// types
|
|
|
|
wm_window_type,
|
|
|
|
wm_window_type_dock,
|
|
|
|
wm_window_type_desktop,
|
|
|
|
wm_window_type_splash,
|
|
|
|
wm_window_type_dialog,
|
|
|
|
wm_window_type_menu,
|
|
|
|
wm_window_type_toolbar,
|
|
|
|
wm_window_type_normal,
|
|
|
|
|
|
|
|
// states
|
|
|
|
wm_state,
|
|
|
|
wm_state_sticky,
|
|
|
|
wm_state_shaded,
|
|
|
|
wm_state_maximized_horz,
|
|
|
|
wm_state_maximized_vert,
|
|
|
|
wm_state_fullscreen,
|
|
|
|
wm_state_hidden,
|
|
|
|
wm_state_skip_taskbar,
|
|
|
|
wm_state_skip_pager,
|
|
|
|
wm_state_below,
|
|
|
|
wm_state_above,
|
|
|
|
wm_state_modal,
|
|
|
|
wm_state_demands_attention,
|
|
|
|
|
|
|
|
// allowed actions
|
|
|
|
wm_allowed_actions,
|
|
|
|
wm_action_move,
|
|
|
|
wm_action_resize,
|
|
|
|
wm_action_minimize,
|
|
|
|
wm_action_shade,
|
|
|
|
wm_action_stick,
|
|
|
|
wm_action_maximize_horz,
|
|
|
|
wm_action_maximize_vert,
|
|
|
|
wm_action_fullscreen,
|
|
|
|
wm_action_change_desktop,
|
|
|
|
wm_action_close,
|
|
|
|
|
|
|
|
wm_strut,
|
|
|
|
wm_icon_geometry,
|
|
|
|
wm_icon,
|
|
|
|
wm_pid,
|
|
|
|
wm_handled_icons,
|
|
|
|
|
|
|
|
frame_extents;
|
|
|
|
|
|
|
|
// application protocols
|
|
|
|
Atom wm_ping;
|
|
|
|
|
|
|
|
Atom utf8_string;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-05-13 11:07:50 +00:00
|
|
|
enum EwmhMoveResizeDirection {
|
|
|
|
_NET_WM_MOVERESIZE_SIZE_TOPLEFT = 0,
|
|
|
|
_NET_WM_MOVERESIZE_SIZE_TOP = 1,
|
|
|
|
_NET_WM_MOVERESIZE_SIZE_TOPRIGHT = 2,
|
|
|
|
_NET_WM_MOVERESIZE_SIZE_RIGHT = 3,
|
|
|
|
_NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT = 4,
|
|
|
|
_NET_WM_MOVERESIZE_SIZE_BOTTOM = 5,
|
|
|
|
_NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT = 6,
|
|
|
|
_NET_WM_MOVERESIZE_SIZE_LEFT = 7,
|
2006-10-30 19:31:15 +00:00
|
|
|
_NET_WM_MOVERESIZE_MOVE = 8, // movement only
|
2006-05-13 11:07:50 +00:00
|
|
|
_NET_WM_MOVERESIZE_SIZE_KEYBOARD = 9, // size via keyboard
|
2006-07-22 07:15:24 +00:00
|
|
|
_NET_WM_MOVERESIZE_MOVE_KEYBOARD = 10, // move via keyboard
|
|
|
|
_NET_WM_MOVERESIZE_CANCEL = 11 // cancel operation
|
2006-05-13 11:07:50 +00:00
|
|
|
};
|
2004-10-21 10:57:38 +00:00
|
|
|
|
2002-10-02 16:26:05 +00:00
|
|
|
Ewmh::Ewmh() {
|
2010-09-13 20:04:24 +00:00
|
|
|
setName("ewmh");
|
2008-01-02 21:41:50 +00:00
|
|
|
m_net = new EwmhAtoms;
|
|
|
|
}
|
|
|
|
|
|
|
|
Ewmh::~Ewmh() {
|
|
|
|
delete m_net;
|
2002-10-02 16:26:05 +00:00
|
|
|
}
|
|
|
|
|
2003-03-03 21:51:13 +00:00
|
|
|
void Ewmh::initForScreen(BScreen &screen) {
|
2003-03-04 21:41:05 +00:00
|
|
|
Display *disp = FbTk::App::instance()->display();
|
2003-03-04 11:06:03 +00:00
|
|
|
|
2004-12-21 16:17:14 +00:00
|
|
|
/* From Extended Window Manager Hints, draft 1.3:
|
|
|
|
*
|
|
|
|
* _NET_SUPPORTING_WM_CHECK
|
2006-10-30 19:31:15 +00:00
|
|
|
*
|
|
|
|
* The Window Manager MUST set this property on the root window
|
|
|
|
* to be the ID of a child window created by himself, to indicate
|
|
|
|
* that a compliant window manager is active. The child window
|
|
|
|
* MUST also have the _NET_SUPPORTING_WM_CHECK property set to
|
|
|
|
* the ID of the child window. The child window MUST also have
|
2004-12-21 16:17:14 +00:00
|
|
|
* the _NET_WM_NAME property set to the name of the Window Manager.
|
2006-10-30 19:31:15 +00:00
|
|
|
*
|
|
|
|
* Rationale: The child window is used to distinguish an active
|
|
|
|
* Window Manager from a stale _NET_SUPPORTING_WM_CHECK property
|
|
|
|
* that happens to point to another window. If the
|
|
|
|
* _NET_SUPPORTING_WM_CHECK window on the client window is missing
|
|
|
|
* or not properly set, clients SHOULD assume that no conforming
|
2004-12-21 16:17:14 +00:00
|
|
|
* Window Manager is present.
|
|
|
|
*/
|
2002-10-02 16:26:05 +00:00
|
|
|
|
2007-10-13 21:51:37 +00:00
|
|
|
Window wincheck = screen.dummyWindow().window();
|
2002-10-16 23:32:17 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (wincheck != None) {
|
2008-01-02 21:41:50 +00:00
|
|
|
screen.rootWindow().changeProperty(m_net->supporting_wm_check, XA_WINDOW, 32,
|
2003-05-19 22:43:48 +00:00
|
|
|
PropModeReplace, (unsigned char *) &wincheck, 1);
|
2008-01-02 21:41:50 +00:00
|
|
|
XChangeProperty(disp, wincheck, m_net->supporting_wm_check, XA_WINDOW, 32,
|
2004-12-21 16:17:14 +00:00
|
|
|
PropModeReplace, (unsigned char *) &wincheck, 1);
|
2002-10-02 16:26:05 +00:00
|
|
|
|
2008-01-02 21:41:50 +00:00
|
|
|
XChangeProperty(disp, wincheck, m_net->wm_name, m_net->utf8_string, 8,
|
2004-12-21 16:17:14 +00:00
|
|
|
PropModeReplace, (unsigned char *) "Fluxbox", strlen("Fluxbox"));
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
2004-09-10 15:36:04 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
//set supported atoms
|
|
|
|
Atom atomsupported[] = {
|
|
|
|
// window properties
|
2008-01-02 21:41:50 +00:00
|
|
|
m_net->wm_strut,
|
|
|
|
m_net->wm_state,
|
|
|
|
m_net->wm_name,
|
2008-02-24 20:58:24 +00:00
|
|
|
m_net->wm_icon,
|
2008-01-02 21:41:50 +00:00
|
|
|
m_net->wm_icon_name,
|
2006-04-23 21:28:09 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
// states that we support:
|
2008-01-02 21:41:50 +00:00
|
|
|
m_net->wm_state_sticky,
|
|
|
|
m_net->wm_state_shaded,
|
|
|
|
m_net->wm_state_maximized_horz,
|
|
|
|
m_net->wm_state_maximized_vert,
|
|
|
|
m_net->wm_state_fullscreen,
|
|
|
|
m_net->wm_state_hidden,
|
|
|
|
m_net->wm_state_skip_taskbar,
|
|
|
|
m_net->wm_state_modal,
|
|
|
|
m_net->wm_state_below,
|
|
|
|
m_net->wm_state_above,
|
|
|
|
m_net->wm_state_demands_attention,
|
2006-10-30 19:31:15 +00:00
|
|
|
|
2004-01-21 09:37:10 +00:00
|
|
|
// window type
|
2008-01-02 21:41:50 +00:00
|
|
|
m_net->wm_window_type,
|
|
|
|
m_net->wm_window_type_dock,
|
|
|
|
m_net->wm_window_type_desktop,
|
|
|
|
m_net->wm_window_type_splash,
|
|
|
|
m_net->wm_window_type_dialog,
|
|
|
|
m_net->wm_window_type_menu,
|
|
|
|
m_net->wm_window_type_toolbar,
|
|
|
|
m_net->wm_window_type_normal,
|
2006-04-23 17:00:33 +00:00
|
|
|
|
|
|
|
// window actions
|
2008-01-02 21:41:50 +00:00
|
|
|
m_net->wm_allowed_actions,
|
|
|
|
m_net->wm_action_move,
|
|
|
|
m_net->wm_action_resize,
|
|
|
|
m_net->wm_action_minimize,
|
|
|
|
m_net->wm_action_shade,
|
|
|
|
m_net->wm_action_stick,
|
|
|
|
m_net->wm_action_maximize_horz,
|
|
|
|
m_net->wm_action_maximize_vert,
|
|
|
|
m_net->wm_action_fullscreen,
|
|
|
|
m_net->wm_action_change_desktop,
|
|
|
|
m_net->wm_action_close,
|
2004-01-21 09:37:10 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
// root properties
|
2008-01-02 21:41:50 +00:00
|
|
|
m_net->client_list,
|
|
|
|
m_net->client_list_stacking,
|
|
|
|
m_net->number_of_desktops,
|
|
|
|
m_net->current_desktop,
|
|
|
|
m_net->active_window,
|
|
|
|
m_net->close_window,
|
|
|
|
m_net->moveresize_window,
|
|
|
|
m_net->workarea,
|
|
|
|
m_net->restack_window,
|
|
|
|
m_net->request_frame_extents,
|
2004-01-19 18:21:51 +00:00
|
|
|
|
2008-01-02 21:41:50 +00:00
|
|
|
m_net->wm_moveresize,
|
2006-10-30 19:31:15 +00:00
|
|
|
|
2008-01-02 21:41:50 +00:00
|
|
|
m_net->frame_extents,
|
2006-05-13 11:07:50 +00:00
|
|
|
|
2004-01-19 18:21:51 +00:00
|
|
|
// desktop properties
|
2008-01-02 21:41:50 +00:00
|
|
|
m_net->wm_desktop,
|
|
|
|
m_net->desktop_names,
|
|
|
|
m_net->desktop_viewport,
|
|
|
|
m_net->desktop_geometry,
|
2004-09-10 15:36:04 +00:00
|
|
|
|
2008-01-02 21:41:50 +00:00
|
|
|
m_net->supporting_wm_check
|
2002-12-01 13:42:15 +00:00
|
|
|
};
|
2004-01-19 18:21:51 +00:00
|
|
|
/* From Extended Window Manager Hints, draft 1.3:
|
|
|
|
*
|
|
|
|
* _NET_SUPPORTED, ATOM[]/32
|
|
|
|
*
|
|
|
|
* This property MUST be set by the Window Manager
|
2004-09-10 15:36:04 +00:00
|
|
|
* to indicate which hints it supports. For
|
|
|
|
* example: considering _NET_WM_STATE both this
|
|
|
|
* atom and all supported states
|
2004-01-19 18:21:51 +00:00
|
|
|
* e.g. _NET_WM_STATE_MODAL, _NET_WM_STATE_STICKY,
|
2004-09-10 15:36:04 +00:00
|
|
|
* would be listed. This assumes that backwards
|
|
|
|
* incompatible changes will not be made to the
|
|
|
|
* hints (without being renamed).
|
2004-01-19 18:21:51 +00:00
|
|
|
*/
|
2008-01-02 21:41:50 +00:00
|
|
|
screen.rootWindow().changeProperty(m_net->supported, XA_ATOM, 32,
|
2004-09-10 15:36:04 +00:00
|
|
|
PropModeReplace,
|
|
|
|
(unsigned char *) &atomsupported,
|
2003-05-19 22:43:48 +00:00
|
|
|
(sizeof atomsupported)/sizeof atomsupported[0]);
|
2002-10-02 16:26:05 +00:00
|
|
|
|
2004-09-10 15:36:04 +00:00
|
|
|
// update atoms
|
2004-01-19 18:21:51 +00:00
|
|
|
|
|
|
|
updateWorkspaceCount(screen);
|
|
|
|
updateCurrentWorkspace(screen);
|
|
|
|
updateWorkspaceNames(screen);
|
|
|
|
updateClientList(screen);
|
|
|
|
updateViewPort(screen);
|
|
|
|
updateGeometry(screen);
|
|
|
|
updateWorkarea(screen);
|
|
|
|
|
2002-10-02 16:26:05 +00:00
|
|
|
}
|
2002-10-16 19:03:57 +00:00
|
|
|
|
2003-07-28 15:06:36 +00:00
|
|
|
void Ewmh::setupClient(WinClient &winclient) {
|
|
|
|
updateStrut(winclient);
|
2006-05-07 10:08:25 +00:00
|
|
|
|
2008-01-02 21:41:50 +00:00
|
|
|
FbTk::FbString newtitle = winclient.textProperty(m_net->wm_name);
|
2007-11-05 17:05:58 +00:00
|
|
|
if (!newtitle.empty())
|
2006-05-07 10:08:25 +00:00
|
|
|
winclient.setTitle(newtitle);
|
2003-07-28 15:06:36 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
Atom ret_type;
|
|
|
|
int fmt;
|
|
|
|
unsigned long nitems, bytes_after;
|
2008-02-24 20:58:24 +00:00
|
|
|
unsigned char* data = 0;
|
|
|
|
|
|
|
|
|
|
|
|
extractNetWmIcon(m_net->wm_icon, winclient);
|
|
|
|
|
2004-01-18 19:14:08 +00:00
|
|
|
|
2004-01-21 09:37:10 +00:00
|
|
|
/* From Extended Window Manager Hints, draft 1.3:
|
|
|
|
*
|
|
|
|
* _NET_WM_WINDOW_TYPE, ATOM[]/32
|
|
|
|
*
|
|
|
|
* This SHOULD be set by the Client before mapping to a list of atoms
|
|
|
|
* indicating the functional type of the window. This property SHOULD
|
2004-09-10 15:36:04 +00:00
|
|
|
* be used by the window manager in determining the decoration,
|
|
|
|
* stacking position and other behavior of the window. The Client
|
2004-01-21 09:37:10 +00:00
|
|
|
* SHOULD specify window types in order of preference (the first being
|
2004-09-10 15:36:04 +00:00
|
|
|
* most preferable) but MUST include at least one of the basic window
|
|
|
|
* type atoms from the list below. This is to allow for extension of
|
|
|
|
* the list of types whilst providing default behavior for Window
|
|
|
|
* Managers that do not recognize the extensions.
|
2004-01-21 09:37:10 +00:00
|
|
|
*
|
|
|
|
*/
|
2004-12-21 16:17:14 +00:00
|
|
|
|
2008-01-02 21:41:50 +00:00
|
|
|
winclient.property(m_net->wm_window_type, 0, 0x7fffffff, False, XA_ATOM,
|
2007-11-05 17:05:58 +00:00
|
|
|
&ret_type, &fmt, &nitems, &bytes_after,
|
|
|
|
&data);
|
2008-08-27 22:29:33 +00:00
|
|
|
WindowState::WindowType type = WindowState::TYPE_NORMAL;
|
2004-01-21 09:37:10 +00:00
|
|
|
if (data) {
|
|
|
|
Atom *atoms = (unsigned long *)data;
|
2006-02-20 21:04:35 +00:00
|
|
|
for (unsigned long l = 0; l < nitems; ++l) {
|
2008-01-02 21:41:50 +00:00
|
|
|
if (atoms[l] == m_net->wm_window_type_dock)
|
2008-08-27 22:29:33 +00:00
|
|
|
type = WindowState::TYPE_DOCK;
|
2008-01-02 21:41:50 +00:00
|
|
|
else if (atoms[l] == m_net->wm_window_type_desktop)
|
2008-08-27 22:29:33 +00:00
|
|
|
type = WindowState::TYPE_DESKTOP;
|
2008-01-02 21:41:50 +00:00
|
|
|
else if (atoms[l] == m_net->wm_window_type_splash)
|
2008-08-27 22:29:33 +00:00
|
|
|
type = WindowState::TYPE_SPLASH;
|
2008-01-02 21:41:50 +00:00
|
|
|
else if (atoms[l] == m_net->wm_window_type_dialog)
|
2008-08-27 22:29:33 +00:00
|
|
|
type = WindowState::TYPE_DIALOG;
|
2008-01-02 21:41:50 +00:00
|
|
|
else if (atoms[l] == m_net->wm_window_type_menu)
|
2008-08-27 22:29:33 +00:00
|
|
|
type = WindowState::TYPE_MENU;
|
2008-01-02 21:41:50 +00:00
|
|
|
else if (atoms[l] == m_net->wm_window_type_toolbar)
|
2008-08-27 22:29:33 +00:00
|
|
|
type = WindowState::TYPE_TOOLBAR;
|
2008-01-02 21:41:50 +00:00
|
|
|
else if (atoms[l] != m_net->wm_window_type_normal)
|
2007-11-05 17:05:58 +00:00
|
|
|
continue;
|
|
|
|
/*
|
|
|
|
* NOT YET IMPLEMENTED:
|
|
|
|
* _NET_WM_WINDOW_TYPE_UTILITY
|
2004-01-21 09:37:10 +00:00
|
|
|
*/
|
2007-11-05 17:05:58 +00:00
|
|
|
break;
|
2004-01-21 09:37:10 +00:00
|
|
|
}
|
2004-08-26 01:51:21 +00:00
|
|
|
XFree(data);
|
2007-11-05 17:05:58 +00:00
|
|
|
} else if (winclient.isTransient()) {
|
2006-10-30 19:31:15 +00:00
|
|
|
// if _NET_WM_WINDOW_TYPE not set and this window
|
|
|
|
// has transient_for the type must be set to _NET_WM_WINDOW_TYPE_DIALOG
|
2010-09-08 09:19:49 +00:00
|
|
|
type = WindowState::TYPE_DIALOG;
|
|
|
|
winclient.
|
|
|
|
changeProperty(m_net->wm_window_type,
|
|
|
|
XA_ATOM, 32, PropModeReplace,
|
|
|
|
(unsigned char*)&m_net->wm_window_type_dialog, 1);
|
2007-11-05 17:05:58 +00:00
|
|
|
|
2006-06-18 21:23:24 +00:00
|
|
|
}
|
2007-11-05 17:05:58 +00:00
|
|
|
winclient.setWindowType(type);
|
2004-01-21 15:42:14 +00:00
|
|
|
|
2006-07-22 07:15:24 +00:00
|
|
|
|
2007-11-05 17:05:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Ewmh::setupFrame(FluxboxWindow &win) {
|
2004-01-21 15:42:14 +00:00
|
|
|
setupState(win);
|
Can check CARDINAL properties in CLIENT PATTERNS
Introduces a new member function, FbWindow::cardinalProperty()
This change also changes other code that previously used
FbWindow::property() to do the same thing as the new function; this
reduces code duplication.
There are still some bits of code (Ewmh.cc, extractNetWmIcon()) that use
FbWindow::property() to retrieve XA_CARDINAL values, but as the new
method is designed for getting a _single_ property, and that code uses
FbWindow::property() to retrieve the number of values present, and then
grab all of them; it's a different use case. I opted to not try to make
cardinalProperty() into some monolithic all-purpose cardinal method;
FbWindow::property() works just fine for that.
This change also adds an optional (default=NULL) boolean to
FbWindow::textProperty and friends that allows the caller to determine
whether or not a value was actually retrieved. This was necessary for
integrating FbWindow::cardinalProperty with the codebase, and it seemed
to fit with FbWindow::textProperty as well. Prior to this change, if
you got a return value of "", you wouldn't know if you successfully
retrieved the value which happened to be blank, or if you failed to
retrieve the value. Now, you can pass the address of a boolean if you
so choose in order to differentiate these situations; the same applies
to the new FbWindow::cardinalProperty().
2011-05-08 02:38:13 +00:00
|
|
|
bool exists;
|
|
|
|
unsigned int desktop=static_cast<unsigned int>(win.winClient().cardinalProperty(m_net->wm_desktop, &exists));
|
|
|
|
if (exists) {
|
2006-05-07 10:08:25 +00:00
|
|
|
if (desktop == (unsigned int)(-1) && !win.isStuck())
|
2004-01-21 15:42:14 +00:00
|
|
|
win.stick();
|
|
|
|
else
|
2005-01-05 05:37:06 +00:00
|
|
|
win.setWorkspace(desktop);
|
2006-06-18 21:23:24 +00:00
|
|
|
} else {
|
2005-05-14 01:55:31 +00:00
|
|
|
updateWorkspace(win);
|
2006-06-18 21:23:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
updateFrameExtents(win);
|
2004-01-21 15:42:14 +00:00
|
|
|
|
2002-10-02 16:26:05 +00:00
|
|
|
}
|
|
|
|
|
2003-09-23 13:52:05 +00:00
|
|
|
void Ewmh::updateFrameClose(FluxboxWindow &win) {
|
|
|
|
}
|
|
|
|
|
2004-01-19 18:21:51 +00:00
|
|
|
void Ewmh::updateFocusedWindow(BScreen &screen, Window win) {
|
|
|
|
/* From Extended Window Manager Hints, draft 1.3:
|
|
|
|
*
|
|
|
|
* _NET_ACTIVE_WINDOW, WINDOW/32
|
|
|
|
*
|
2004-09-10 15:36:04 +00:00
|
|
|
* The window ID of the currently active window or None
|
|
|
|
* if no window has the focus. This is a read-only
|
|
|
|
* property set by the Window Manager.
|
2004-01-19 18:21:51 +00:00
|
|
|
*
|
|
|
|
*/
|
2008-01-02 21:41:50 +00:00
|
|
|
screen.rootWindow().changeProperty(m_net->active_window,
|
2004-01-19 18:21:51 +00:00
|
|
|
XA_WINDOW, 32,
|
|
|
|
PropModeReplace,
|
|
|
|
(unsigned char *)&win, 1);
|
|
|
|
}
|
|
|
|
|
2007-07-08 22:49:12 +00:00
|
|
|
// EWMH says, regarding _NET_WM_STATE and _NET_WM_DESKTOP
|
|
|
|
// The Window Manager should remove the property whenever a window is withdrawn
|
|
|
|
// but it should leave the property in place when it is shutting down
|
2005-05-14 01:55:31 +00:00
|
|
|
void Ewmh::updateClientClose(WinClient &winclient){
|
2007-07-08 22:49:12 +00:00
|
|
|
if (!winclient.screen().isShuttingdown()) {
|
|
|
|
XDeleteProperty(FbTk::App::instance()->display(), winclient.window(),
|
2008-01-02 21:41:50 +00:00
|
|
|
m_net->wm_state);
|
2007-07-08 22:49:12 +00:00
|
|
|
XDeleteProperty(FbTk::App::instance()->display(), winclient.window(),
|
2008-01-02 21:41:50 +00:00
|
|
|
m_net->wm_desktop);
|
2007-07-08 22:49:12 +00:00
|
|
|
}
|
2005-05-14 01:55:31 +00:00
|
|
|
}
|
|
|
|
|
2003-03-03 21:51:13 +00:00
|
|
|
void Ewmh::updateClientList(BScreen &screen) {
|
2003-04-15 00:17:59 +00:00
|
|
|
|
2007-10-13 21:51:37 +00:00
|
|
|
if (screen.isShuttingdown())
|
|
|
|
return;
|
|
|
|
|
2007-11-12 21:59:43 +00:00
|
|
|
list<Focusable *> creation_order_list =
|
|
|
|
screen.focusControl().creationOrderList().clientList();
|
2004-06-07 11:46:05 +00:00
|
|
|
|
2006-07-29 06:28:58 +00:00
|
|
|
size_t num = creation_order_list.size();
|
2004-10-21 10:57:38 +00:00
|
|
|
Window *wl = FB_new_nothrow Window[num];
|
2002-12-01 13:42:15 +00:00
|
|
|
if (wl == 0) {
|
2004-06-07 11:46:05 +00:00
|
|
|
_FB_USES_NLS;
|
2006-10-30 19:31:15 +00:00
|
|
|
cerr<<_FB_CONSOLETEXT(Ewmh, OutOfMemoryClientList,
|
2006-04-23 17:00:33 +00:00
|
|
|
"Fatal: Out of memory, can't allocate for EWMH client list", "")<<endl;
|
2002-12-01 13:42:15 +00:00
|
|
|
return;
|
|
|
|
}
|
2003-04-15 12:22:06 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
int win=0;
|
2007-10-13 21:51:37 +00:00
|
|
|
list<Focusable *>::iterator client_it = creation_order_list.begin();
|
|
|
|
list<Focusable *>::iterator client_it_end = creation_order_list.end();
|
|
|
|
for (; client_it != client_it_end; ++client_it) {
|
|
|
|
WinClient *client = dynamic_cast<WinClient *>(*client_it);
|
|
|
|
if (client)
|
|
|
|
wl[win++] = client->window();
|
|
|
|
}
|
2002-12-27 02:15:08 +00:00
|
|
|
|
2004-01-19 18:21:51 +00:00
|
|
|
/* From Extended Window Manager Hints, draft 1.3:
|
|
|
|
*
|
|
|
|
* _NET_CLIENT_LIST, WINDOW[]/32
|
|
|
|
* _NET_CLIENT_LIST_STACKING, WINDOW[]/32
|
|
|
|
*
|
|
|
|
* These arrays contain all X Windows managed by
|
2004-09-10 15:36:04 +00:00
|
|
|
* the Window Manager. _NET_CLIENT_LIST has
|
2004-01-19 18:21:51 +00:00
|
|
|
* initial mapping order, starting with the oldest
|
2004-09-10 15:36:04 +00:00
|
|
|
* window. _NET_CLIENT_LIST_STACKING has
|
2004-01-19 18:21:51 +00:00
|
|
|
* bottom-to-top stacking order. These properties
|
2004-09-10 15:36:04 +00:00
|
|
|
* SHOULD be set and updated by the Window
|
|
|
|
* Manager.
|
2004-01-19 18:21:51 +00:00
|
|
|
*/
|
2008-01-02 21:41:50 +00:00
|
|
|
screen.rootWindow().changeProperty(m_net->client_list,
|
2004-01-18 19:14:08 +00:00
|
|
|
XA_WINDOW, 32,
|
2003-05-19 22:43:48 +00:00
|
|
|
PropModeReplace, (unsigned char *)wl, num);
|
2008-01-02 21:41:50 +00:00
|
|
|
screen.rootWindow().changeProperty(m_net->client_list_stacking,
|
2004-01-19 18:21:51 +00:00
|
|
|
XA_WINDOW, 32,
|
|
|
|
PropModeReplace, (unsigned char *)wl, num);
|
2004-09-10 15:36:04 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
delete [] wl;
|
2002-10-02 16:26:05 +00:00
|
|
|
}
|
|
|
|
|
2003-03-03 21:51:13 +00:00
|
|
|
void Ewmh::updateWorkspaceNames(BScreen &screen) {
|
2004-01-19 18:21:51 +00:00
|
|
|
/* From Extended Window Manager Hints, draft 1.3:
|
|
|
|
*
|
|
|
|
* _NET_DESKTOP_NAMES, UTF8_STRING[]
|
|
|
|
*
|
2004-09-10 15:36:04 +00:00
|
|
|
* The names of all virtual desktops.
|
2004-01-19 18:21:51 +00:00
|
|
|
* This is a list of NULL-terminated strings in UTF-8
|
2004-09-10 15:36:04 +00:00
|
|
|
* encoding [UTF8]. This property MAY be changed by a
|
2004-01-19 18:21:51 +00:00
|
|
|
* Pager or the Window Manager at any time.
|
|
|
|
*
|
2004-09-10 15:36:04 +00:00
|
|
|
* Note: The number of names could be different from
|
|
|
|
* _NET_NUMBER_OF_DESKTOPS. If it is less than
|
2004-01-19 18:21:51 +00:00
|
|
|
* _NET_NUMBER_OF_DESKTOPS, then the desktops with high
|
2004-09-10 15:36:04 +00:00
|
|
|
* numbers are unnamed. If it is larger than
|
2004-01-19 18:21:51 +00:00
|
|
|
* _NET_NUMBER_OF_DESKTOPS, then the excess names outside
|
|
|
|
* of the _NET_NUMBER_OF_DESKTOPS are considered to be
|
|
|
|
* reserved in case the number of desktops is increased.
|
|
|
|
*
|
|
|
|
* Rationale: The name is not a necessary attribute of a
|
|
|
|
* virtual desktop. Thus the availability or unavailability
|
|
|
|
* of names has no impact on virtual desktop functionality.
|
2004-09-10 15:36:04 +00:00
|
|
|
* Since names are set by users and users are likely to
|
|
|
|
* preset names for a fixed number of desktops, it
|
2004-01-19 18:21:51 +00:00
|
|
|
* doesn't make sense to shrink or grow this list when the
|
2004-09-10 15:36:04 +00:00
|
|
|
* number of available desktops changes.
|
2004-01-19 18:21:51 +00:00
|
|
|
*
|
|
|
|
*/
|
2002-12-01 13:42:15 +00:00
|
|
|
XTextProperty text;
|
2003-12-12 15:19:22 +00:00
|
|
|
const BScreen::WorkspaceNames &workspacenames = screen.getWorkspaceNames();
|
|
|
|
const size_t number_of_desks = workspacenames.size();
|
2004-09-10 15:36:04 +00:00
|
|
|
|
2009-09-30 19:05:42 +00:00
|
|
|
char** names = new char*[number_of_desks];
|
2004-09-10 15:36:04 +00:00
|
|
|
|
|
|
|
for (size_t i = 0; i < number_of_desks; i++) {
|
2003-12-12 15:19:22 +00:00
|
|
|
names[i] = new char[workspacenames[i].size() + 1]; // +1 for \0
|
|
|
|
memset(names[i], 0, workspacenames[i].size());
|
|
|
|
strcpy(names[i], workspacenames[i].c_str());
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
2003-12-12 15:19:22 +00:00
|
|
|
|
2006-05-07 10:08:25 +00:00
|
|
|
#ifdef X_HAVE_UTF8_STRING
|
2006-12-31 22:13:31 +00:00
|
|
|
int code = Xutf8TextListToTextProperty(FbTk::App::instance()->display(),
|
2006-05-07 10:08:25 +00:00
|
|
|
names, number_of_desks, XUTF8StringStyle, &text);
|
2006-12-31 22:13:31 +00:00
|
|
|
if (code != XNoMemory && code != XLocaleNotSupported) {
|
|
|
|
XSetTextProperty(FbTk::App::instance()->display(),
|
|
|
|
screen.rootWindow().window(),
|
2008-01-02 21:41:50 +00:00
|
|
|
&text, m_net->desktop_names);
|
2006-05-07 10:08:25 +00:00
|
|
|
|
2006-12-31 22:13:31 +00:00
|
|
|
XFree(text.value);
|
|
|
|
}
|
2006-05-07 10:08:25 +00:00
|
|
|
|
|
|
|
#else
|
2002-12-01 13:42:15 +00:00
|
|
|
if (XStringListToTextProperty(names, number_of_desks, &text)) {
|
2003-05-10 22:59:32 +00:00
|
|
|
XSetTextProperty(FbTk::App::instance()->display(), screen.rootWindow().window(),
|
2009-09-30 19:05:42 +00:00
|
|
|
&text, m_net->desktop_names);
|
2002-12-01 13:42:15 +00:00
|
|
|
XFree(text.value);
|
|
|
|
}
|
2006-05-07 10:08:25 +00:00
|
|
|
#endif
|
2004-01-21 09:37:10 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
for (size_t i = 0; i < number_of_desks; i++)
|
2009-09-30 19:05:42 +00:00
|
|
|
delete[] names[i];
|
|
|
|
|
|
|
|
delete[] names;
|
2004-10-21 10:57:38 +00:00
|
|
|
|
2002-10-02 16:26:05 +00:00
|
|
|
}
|
|
|
|
|
2003-03-03 21:51:13 +00:00
|
|
|
void Ewmh::updateCurrentWorkspace(BScreen &screen) {
|
2004-01-19 18:21:51 +00:00
|
|
|
/* From Extended Window Manager Hints, draft 1.3:
|
|
|
|
*
|
|
|
|
* _NET_CURRENT_DESKTOP desktop, CARDINAL/32
|
|
|
|
*
|
|
|
|
* The index of the current desktop. This is always
|
|
|
|
* an integer between 0 and _NET_NUMBER_OF_DESKTOPS - 1.
|
2004-09-10 15:36:04 +00:00
|
|
|
* This MUST be set and updated by the Window Manager.
|
2004-01-19 18:21:51 +00:00
|
|
|
*
|
|
|
|
*/
|
2005-01-31 16:55:38 +00:00
|
|
|
unsigned long workspace = screen.currentWorkspaceID();
|
2008-01-02 21:41:50 +00:00
|
|
|
screen.rootWindow().changeProperty(m_net->current_desktop,
|
2004-01-19 18:21:51 +00:00
|
|
|
XA_CARDINAL, 32,
|
|
|
|
PropModeReplace,
|
2003-05-19 22:43:48 +00:00
|
|
|
(unsigned char *)&workspace, 1);
|
2002-10-02 16:26:05 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2003-03-03 21:51:13 +00:00
|
|
|
void Ewmh::updateWorkspaceCount(BScreen &screen) {
|
2004-01-19 18:21:51 +00:00
|
|
|
/* From Extended Window Manager Hints, draft 1.3:
|
|
|
|
*
|
|
|
|
* _NET_NUMBER_OF_DESKTOPS, CARDINAL/32
|
|
|
|
*
|
|
|
|
* This property SHOULD be set and updated by the
|
|
|
|
* Window Manager to indicate the number of virtual
|
|
|
|
* desktops.
|
|
|
|
*/
|
2005-07-04 18:19:53 +00:00
|
|
|
unsigned long numworkspaces = screen.numberOfWorkspaces();
|
2008-01-02 21:41:50 +00:00
|
|
|
screen.rootWindow().changeProperty(m_net->number_of_desktops,
|
2004-09-10 15:36:04 +00:00
|
|
|
XA_CARDINAL, 32,
|
2004-01-19 18:21:51 +00:00
|
|
|
PropModeReplace,
|
2003-05-19 22:43:48 +00:00
|
|
|
(unsigned char *)&numworkspaces, 1);
|
2002-10-02 16:26:05 +00:00
|
|
|
}
|
|
|
|
|
2004-01-19 18:21:51 +00:00
|
|
|
void Ewmh::updateViewPort(BScreen &screen) {
|
|
|
|
/* From Extended Window Manager Hints, draft 1.3:
|
2004-09-10 15:36:04 +00:00
|
|
|
*
|
2004-01-19 18:21:51 +00:00
|
|
|
* _NET_DESKTOP_VIEWPORT x, y, CARDINAL[][2]/32
|
|
|
|
*
|
2004-09-10 15:36:04 +00:00
|
|
|
* Array of pairs of cardinals that define the
|
|
|
|
* top left corner of each desktop's viewport.
|
2004-01-19 18:21:51 +00:00
|
|
|
* For Window Managers that don't support large
|
2004-09-10 15:36:04 +00:00
|
|
|
* desktops, this MUST always be set to (0,0).
|
2004-01-19 18:21:51 +00:00
|
|
|
*
|
|
|
|
*/
|
2005-01-31 16:55:38 +00:00
|
|
|
long value[2] = {0, 0}; // we dont support large desktops
|
2008-01-02 21:41:50 +00:00
|
|
|
screen.rootWindow().changeProperty(m_net->desktop_viewport,
|
2004-01-19 18:21:51 +00:00
|
|
|
XA_CARDINAL, 32,
|
|
|
|
PropModeReplace,
|
|
|
|
(unsigned char *)value, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Ewmh::updateGeometry(BScreen &screen) {
|
|
|
|
/* From Extended Window Manager Hints, draft 1.3:
|
|
|
|
*
|
|
|
|
* _NET_DESKTOP_GEOMETRY width, height, CARDINAL[2]/32
|
|
|
|
*
|
|
|
|
* Array of two cardinals that defines the common size
|
2004-09-10 15:36:04 +00:00
|
|
|
* of all desktops (this is equal to the screen size
|
|
|
|
* if the Window Manager doesn't support large
|
2004-01-19 18:21:51 +00:00
|
|
|
* desktops, otherwise it's equal to the virtual size
|
|
|
|
* of the desktop). This property SHOULD be set by the
|
2004-09-10 15:36:04 +00:00
|
|
|
* Window Manager.
|
2004-01-19 18:21:51 +00:00
|
|
|
*
|
|
|
|
*/
|
2005-01-31 16:55:38 +00:00
|
|
|
long value[2] = {screen.width(), screen.height()};
|
2008-01-02 21:41:50 +00:00
|
|
|
screen.rootWindow().changeProperty(m_net->desktop_geometry,
|
2004-01-19 18:21:51 +00:00
|
|
|
XA_CARDINAL, 32,
|
|
|
|
PropModeReplace,
|
|
|
|
(unsigned char *)value, 2);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void Ewmh::updateWorkarea(BScreen &screen) {
|
|
|
|
/* From Extended Window Manager Hints, draft 1.3:
|
2004-09-10 15:36:04 +00:00
|
|
|
*
|
2004-01-19 18:21:51 +00:00
|
|
|
* _NET_WORKAREA, x, y, width, height CARDINAL[][4]/32
|
|
|
|
*
|
2004-09-10 15:36:04 +00:00
|
|
|
* This property MUST be set by the Window Manager upon
|
|
|
|
* calculating the work area for each desktop. Contains a
|
|
|
|
* geometry for each desktop. These geometries are
|
2004-01-19 18:21:51 +00:00
|
|
|
* specified relative to the viewport on each desktop and
|
2004-09-10 15:36:04 +00:00
|
|
|
* specify an area that is completely contained within the
|
|
|
|
* viewport. Work area SHOULD be used by desktop applications
|
|
|
|
* to place desktop icons appropriately.
|
2004-01-19 18:21:51 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* !!TODO
|
|
|
|
* Not sure how to handle xinerama stuff here.
|
|
|
|
* So i'm just doing this on the first head.
|
2004-09-10 15:36:04 +00:00
|
|
|
*/
|
2005-07-04 18:19:53 +00:00
|
|
|
unsigned long *coords = new unsigned long[4*screen.numberOfWorkspaces()];
|
|
|
|
for (unsigned int i=0; i < screen.numberOfWorkspaces()*4; i+=4) {
|
2004-01-19 18:21:51 +00:00
|
|
|
// x, y
|
|
|
|
coords[i] = screen.maxLeft(0);
|
|
|
|
coords[i + 1] = screen.maxTop(0);
|
|
|
|
// width, height
|
|
|
|
coords[i + 2] = screen.maxRight(0) - screen.maxLeft(0);
|
|
|
|
coords[i + 3] = screen.maxBottom(0) - screen.maxTop(0);
|
|
|
|
|
|
|
|
}
|
2008-01-02 21:41:50 +00:00
|
|
|
screen.rootWindow().changeProperty(m_net->workarea,
|
2004-01-19 18:21:51 +00:00
|
|
|
XA_CARDINAL, 32,
|
|
|
|
PropModeReplace,
|
|
|
|
(unsigned char *)coords,
|
2005-07-04 18:19:53 +00:00
|
|
|
4 * screen.numberOfWorkspaces());
|
2004-08-26 01:51:21 +00:00
|
|
|
|
|
|
|
delete[] coords;
|
2004-01-19 18:21:51 +00:00
|
|
|
}
|
|
|
|
|
2002-10-02 16:26:05 +00:00
|
|
|
void Ewmh::updateState(FluxboxWindow &win) {
|
2006-10-30 19:31:15 +00:00
|
|
|
|
2006-04-23 17:00:33 +00:00
|
|
|
|
|
|
|
updateActions(win);
|
2006-10-30 19:31:15 +00:00
|
|
|
|
2010-04-30 07:03:57 +00:00
|
|
|
typedef vector<Atom> StateVec;
|
2005-06-02 01:36:28 +00:00
|
|
|
|
|
|
|
StateVec state;
|
2004-12-21 16:17:14 +00:00
|
|
|
|
2007-02-23 22:32:31 +00:00
|
|
|
if (win.isMaximizedHorz())
|
2008-01-02 21:41:50 +00:00
|
|
|
state.push_back(m_net->wm_state_maximized_horz);
|
2007-02-23 22:32:31 +00:00
|
|
|
if (win.isMaximizedVert())
|
2008-01-02 21:41:50 +00:00
|
|
|
state.push_back(m_net->wm_state_maximized_vert);
|
2004-12-21 16:17:14 +00:00
|
|
|
if (win.isStuck())
|
2008-01-02 21:41:50 +00:00
|
|
|
state.push_back(m_net->wm_state_sticky);
|
2004-12-21 16:17:14 +00:00
|
|
|
if (win.isShaded())
|
2008-01-02 21:41:50 +00:00
|
|
|
state.push_back(m_net->wm_state_shaded);
|
2011-03-23 11:02:15 +00:00
|
|
|
if (win.layerNum() == ResourceLayer::BOTTOM)
|
2008-01-02 21:41:50 +00:00
|
|
|
state.push_back(m_net->wm_state_below);
|
2011-03-23 11:02:15 +00:00
|
|
|
if (win.layerNum() == ResourceLayer::ABOVE_DOCK)
|
2008-01-02 21:41:50 +00:00
|
|
|
state.push_back(m_net->wm_state_above);
|
2005-06-02 01:36:28 +00:00
|
|
|
if (win.isIconic())
|
2008-01-02 21:41:50 +00:00
|
|
|
state.push_back(m_net->wm_state_hidden);
|
2005-06-02 01:36:28 +00:00
|
|
|
if (win.isIconHidden())
|
2008-01-02 21:41:50 +00:00
|
|
|
state.push_back(m_net->wm_state_skip_taskbar);
|
2006-04-23 17:00:33 +00:00
|
|
|
if (win.isFullscreen())
|
2008-01-02 21:41:50 +00:00
|
|
|
state.push_back(m_net->wm_state_fullscreen);
|
2004-12-21 16:17:14 +00:00
|
|
|
|
|
|
|
FluxboxWindow::ClientList::iterator it = win.clientList().begin();
|
|
|
|
FluxboxWindow::ClientList::iterator it_end = win.clientList().end();
|
|
|
|
for (; it != it_end; ++it) {
|
2006-10-30 19:31:15 +00:00
|
|
|
|
2005-06-02 01:36:28 +00:00
|
|
|
StateVec client_state(state);
|
|
|
|
Atom ret_type;
|
|
|
|
int fmt;
|
|
|
|
unsigned long nitems, bytes_after;
|
|
|
|
unsigned char *data = 0;
|
|
|
|
|
2007-07-01 17:59:57 +00:00
|
|
|
// set client-specific state
|
|
|
|
if ((*it)->isStateModal())
|
2008-01-02 21:41:50 +00:00
|
|
|
client_state.push_back(m_net->wm_state_modal);
|
2007-07-01 17:59:57 +00:00
|
|
|
if (Fluxbox::instance()->attentionHandler().isDemandingAttention(**it))
|
2008-01-02 21:41:50 +00:00
|
|
|
client_state.push_back(m_net->wm_state_demands_attention);
|
2007-07-01 17:59:57 +00:00
|
|
|
|
|
|
|
// search the old states for _NET_WM_STATE_SKIP_PAGER and append it
|
|
|
|
// to the current state, so it wont get deleted by us.
|
2008-01-02 21:41:50 +00:00
|
|
|
(*it)->property(m_net->wm_state, 0, 0x7fffffff, False, XA_ATOM,
|
2005-06-02 01:36:28 +00:00
|
|
|
&ret_type, &fmt, &nitems, &bytes_after,
|
|
|
|
&data);
|
|
|
|
if (data) {
|
|
|
|
Atom *old_states = (Atom *)data;
|
2006-04-23 17:00:33 +00:00
|
|
|
for (unsigned long i=0; i < nitems; ++i) {
|
2008-01-02 21:41:50 +00:00
|
|
|
if (old_states[i] == m_net->wm_state_skip_pager) {
|
|
|
|
client_state.push_back(m_net->wm_state_skip_pager);
|
2005-06-02 01:36:28 +00:00
|
|
|
}
|
2006-04-23 17:00:33 +00:00
|
|
|
}
|
2005-06-02 01:36:28 +00:00
|
|
|
XFree(data);
|
|
|
|
}
|
|
|
|
|
2006-04-23 17:00:33 +00:00
|
|
|
if (!client_state.empty()) {
|
2008-01-02 21:41:50 +00:00
|
|
|
(*it)->changeProperty(m_net->wm_state, XA_ATOM, 32, PropModeReplace,
|
2006-10-30 19:31:15 +00:00
|
|
|
reinterpret_cast<unsigned char*>(&client_state.front()),
|
2005-06-02 01:36:28 +00:00
|
|
|
client_state.size());
|
2006-04-23 17:00:33 +00:00
|
|
|
} else
|
2008-01-02 21:41:50 +00:00
|
|
|
(*it)->deleteProperty(m_net->wm_state);
|
2004-12-21 16:17:14 +00:00
|
|
|
}
|
2002-10-02 16:26:05 +00:00
|
|
|
}
|
|
|
|
|
2003-02-02 16:32:41 +00:00
|
|
|
void Ewmh::updateLayer(FluxboxWindow &win) {
|
2007-02-27 17:46:48 +00:00
|
|
|
updateState(win);
|
2003-02-02 16:32:41 +00:00
|
|
|
}
|
|
|
|
|
2002-10-02 16:26:05 +00:00
|
|
|
void Ewmh::updateHints(FluxboxWindow &win) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void Ewmh::updateWorkspace(FluxboxWindow &win) {
|
2006-07-29 06:28:58 +00:00
|
|
|
long workspace = win.workspaceNumber();
|
2005-05-14 01:55:31 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (win.isStuck())
|
2006-04-24 14:29:21 +00:00
|
|
|
workspace = -1; // appear on all desktops/workspaces
|
2002-10-02 16:26:05 +00:00
|
|
|
|
2003-07-02 14:31:43 +00:00
|
|
|
FluxboxWindow::ClientList::iterator it = win.clientList().begin();
|
|
|
|
FluxboxWindow::ClientList::iterator it_end = win.clientList().end();
|
|
|
|
for (; it != it_end; ++it) {
|
2008-01-02 21:41:50 +00:00
|
|
|
(*it)->changeProperty(m_net->wm_desktop, XA_CARDINAL, 32, PropModeReplace,
|
2003-07-02 14:31:43 +00:00
|
|
|
(unsigned char *)&workspace, 1);
|
|
|
|
}
|
|
|
|
|
2002-10-02 16:26:05 +00:00
|
|
|
}
|
|
|
|
|
2004-01-21 09:37:10 +00:00
|
|
|
|
2002-10-16 19:03:57 +00:00
|
|
|
// return true if we did handle the atom here
|
2004-09-10 15:36:04 +00:00
|
|
|
bool Ewmh::checkClientMessage(const XClientMessageEvent &ce,
|
2004-02-14 12:15:35 +00:00
|
|
|
BScreen * screen, WinClient * const winclient) {
|
2004-12-21 16:17:14 +00:00
|
|
|
|
2008-01-02 21:41:50 +00:00
|
|
|
if (ce.message_type == m_net->wm_desktop) {
|
2002-12-01 13:42:15 +00:00
|
|
|
// ce.data.l[0] = workspace number
|
2004-03-07 23:37:39 +00:00
|
|
|
// valid window
|
|
|
|
|
|
|
|
if (winclient == 0 || winclient->fbwindow() == 0)
|
2002-12-01 13:42:15 +00:00
|
|
|
return true;
|
2004-03-07 23:37:39 +00:00
|
|
|
|
|
|
|
FluxboxWindow *fbwin = winclient->fbwindow();
|
|
|
|
|
|
|
|
// if it's stick, make sure it is stuck.
|
|
|
|
// otherwise, make sure it isn't stuck
|
2006-04-24 14:29:21 +00:00
|
|
|
if (ce.data.l[0] == -1) {
|
2004-03-07 23:37:39 +00:00
|
|
|
if (!fbwin->isStuck())
|
|
|
|
fbwin->stick();
|
|
|
|
return true;
|
|
|
|
} else if (fbwin->isStuck())
|
|
|
|
fbwin->stick();
|
|
|
|
|
|
|
|
// the screen is the root window of the message,
|
|
|
|
// which doesn't apply here (so borrow the variable :) )
|
|
|
|
screen = &fbwin->screen();
|
|
|
|
// valid workspace number?
|
2006-06-11 13:09:44 +00:00
|
|
|
if (static_cast<unsigned int>
|
|
|
|
(ce.data.l[0]) < screen->numberOfWorkspaces())
|
2004-09-10 15:36:04 +00:00
|
|
|
screen->sendToWorkspace(ce.data.l[0], fbwin, false);
|
2004-03-07 23:37:39 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
return true;
|
2008-01-02 21:41:50 +00:00
|
|
|
} else if (ce.message_type == m_net->wm_state) {
|
2003-07-28 15:06:36 +00:00
|
|
|
if (winclient == 0 || winclient->fbwindow() == 0)
|
2002-12-01 13:42:15 +00:00
|
|
|
return true;
|
2003-07-28 15:06:36 +00:00
|
|
|
|
|
|
|
FluxboxWindow &win = *winclient->fbwindow();
|
2002-12-01 13:42:15 +00:00
|
|
|
// ce.data.l[0] = the action (remove, add or toggle)
|
|
|
|
// ce.data.l[1] = the first property to alter
|
|
|
|
// ce.data.l[2] = second property to alter (can be zero)
|
|
|
|
if (ce.data.l[0] == STATE_REMOVE) {
|
2007-06-30 01:28:54 +00:00
|
|
|
setState(win, ce.data.l[1], false, *winclient);
|
|
|
|
setState(win, ce.data.l[2], false, *winclient);
|
2002-12-01 13:42:15 +00:00
|
|
|
} else if (ce.data.l[0] == STATE_ADD) {
|
2007-06-30 01:28:54 +00:00
|
|
|
setState(win, ce.data.l[1], true, *winclient);
|
|
|
|
setState(win, ce.data.l[2], true, *winclient);
|
2002-12-01 13:42:15 +00:00
|
|
|
} else if (ce.data.l[0] == STATE_TOGGLE) {
|
2003-07-28 15:06:36 +00:00
|
|
|
toggleState(win, ce.data.l[1]);
|
|
|
|
toggleState(win, ce.data.l[2]);
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
|
|
|
return true;
|
2008-01-02 21:41:50 +00:00
|
|
|
} else if (ce.message_type == m_net->number_of_desktops) {
|
2002-12-01 13:42:15 +00:00
|
|
|
if (screen == 0)
|
|
|
|
return true;
|
|
|
|
// ce.data.l[0] = number of workspaces
|
2004-09-10 15:36:04 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
// no need to alter number of desktops if they are the same
|
|
|
|
// or if requested number of workspace is less than zero
|
2005-07-04 18:19:53 +00:00
|
|
|
if (screen->numberOfWorkspaces() == static_cast<unsigned int>(ce.data.l[0]) ||
|
2002-12-01 13:42:15 +00:00
|
|
|
ce.data.l[0] < 0)
|
|
|
|
return true;
|
|
|
|
|
2005-07-04 18:19:53 +00:00
|
|
|
if (screen->numberOfWorkspaces() > static_cast<unsigned int>(ce.data.l[0])) {
|
2002-12-01 13:42:15 +00:00
|
|
|
// remove last workspace until we have
|
|
|
|
// the same number of workspaces
|
2005-07-04 18:19:53 +00:00
|
|
|
while (screen->numberOfWorkspaces() != static_cast<unsigned int>(ce.data.l[0])) {
|
2002-12-01 13:42:15 +00:00
|
|
|
screen->removeLastWorkspace();
|
2005-07-04 18:19:53 +00:00
|
|
|
if (screen->numberOfWorkspaces() == 1) // must have at least one workspace
|
2002-12-01 13:42:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else { // add workspaces to screen until workspace count match the requested size
|
2005-07-04 18:19:53 +00:00
|
|
|
while (screen->numberOfWorkspaces() != static_cast<unsigned int>(ce.data.l[0])) {
|
2004-09-10 15:36:04 +00:00
|
|
|
screen->addWorkspace();
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
|
|
|
}
|
2004-09-10 15:36:04 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
return true;
|
2008-01-02 21:41:50 +00:00
|
|
|
} else if (ce.message_type == m_net->current_desktop) {
|
2002-12-01 13:42:15 +00:00
|
|
|
if (screen == 0)
|
|
|
|
return true;
|
|
|
|
// ce.data.l[0] = workspace number
|
2004-09-10 15:36:04 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
// prevent out of range value
|
2005-07-04 18:19:53 +00:00
|
|
|
if (static_cast<unsigned int>(ce.data.l[0]) >= screen->numberOfWorkspaces())
|
2002-12-01 13:42:15 +00:00
|
|
|
return true;
|
|
|
|
screen->changeWorkspaceID(ce.data.l[0]);
|
|
|
|
return true;
|
2008-01-02 21:41:50 +00:00
|
|
|
} else if (ce.message_type == m_net->active_window) {
|
2004-09-10 15:36:04 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
// make sure we have a valid window
|
2003-07-28 15:06:36 +00:00
|
|
|
if (winclient == 0)
|
2002-12-01 13:42:15 +00:00
|
|
|
return true;
|
|
|
|
// ce.window = window to focus
|
2004-09-10 15:36:04 +00:00
|
|
|
|
2007-10-13 21:51:37 +00:00
|
|
|
// ce.data.l[0] == 2 means the request came from a pager
|
|
|
|
if (winclient->fbwindow() && (ce.data.l[0] == 2 ||
|
2007-12-22 05:24:13 +00:00
|
|
|
winclient->fbwindow()->focusRequestFromClient(*winclient))) {
|
2007-10-13 21:51:37 +00:00
|
|
|
winclient->focus();
|
|
|
|
winclient->fbwindow()->raise();
|
2006-10-30 19:31:15 +00:00
|
|
|
}
|
2002-12-01 13:42:15 +00:00
|
|
|
return true;
|
2008-01-02 21:41:50 +00:00
|
|
|
} else if (ce.message_type == m_net->close_window) {
|
2003-07-28 15:06:36 +00:00
|
|
|
if (winclient == 0)
|
2002-12-01 13:42:15 +00:00
|
|
|
return true;
|
|
|
|
// ce.window = window to close (which in this case is the win argument)
|
2003-07-28 15:06:36 +00:00
|
|
|
winclient->sendClose();
|
2002-12-01 13:42:15 +00:00
|
|
|
return true;
|
2008-01-02 21:41:50 +00:00
|
|
|
} else if (ce.message_type == m_net->moveresize_window) {
|
2004-02-14 12:15:35 +00:00
|
|
|
if (winclient == 0 || winclient->fbwindow() == 0)
|
2002-12-01 13:42:15 +00:00
|
|
|
return true;
|
|
|
|
// ce.data.l[0] = gravity and flags
|
2006-07-09 01:46:47 +00:00
|
|
|
int x = (ce.data.l[0] & 0x0100) ? ce.data.l[1] :
|
|
|
|
winclient->fbwindow()->x();
|
|
|
|
int y = (ce.data.l[0] & 0x0200) ? ce.data.l[2] :
|
|
|
|
winclient->fbwindow()->y();
|
|
|
|
unsigned int width = (ce.data.l[0] & 0x0400) ? ce.data.l[3] :
|
|
|
|
winclient->fbwindow()->width();
|
|
|
|
unsigned int height = (ce.data.l[0] & 0x0800) ? ce.data.l[4] :
|
|
|
|
winclient->fbwindow()->height();
|
2005-03-16 23:19:36 +00:00
|
|
|
int win_gravity=ce.data.l[0] & 0xFF;
|
2006-07-09 01:46:47 +00:00
|
|
|
winclient->fbwindow()->moveResizeForClient(x, y, width, height,
|
|
|
|
win_gravity, winclient->old_bw);
|
2002-12-01 13:42:15 +00:00
|
|
|
return true;
|
2008-01-02 21:41:50 +00:00
|
|
|
} else if (ce.message_type == m_net->restack_window) {
|
2010-03-17 15:35:07 +00:00
|
|
|
|
|
|
|
fbdbg << "Ewmh: restack window" << endl;
|
|
|
|
|
2006-04-23 21:28:09 +00:00
|
|
|
if (winclient == 0 || winclient->fbwindow() == 0)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
// ce.data.l[0] = source indication
|
|
|
|
// ce.data.l[1] = sibling window
|
|
|
|
// ce.data.l[2] = detail
|
2006-10-30 19:31:15 +00:00
|
|
|
|
2006-04-23 21:28:09 +00:00
|
|
|
|
|
|
|
WinClient *above_win = Fluxbox::instance()->searchWindow(ce.data.l[1]);
|
|
|
|
if (above_win == 0 || above_win->fbwindow() == 0 ||
|
|
|
|
above_win == winclient) // this would be very wrong :)
|
|
|
|
return true;
|
|
|
|
|
2011-02-23 21:49:27 +00:00
|
|
|
FbTk::LayerItem &below_item = winclient->fbwindow()->layerItem();
|
|
|
|
FbTk::LayerItem &above_item = above_win->fbwindow()->layerItem();
|
2006-05-13 11:07:50 +00:00
|
|
|
|
2006-04-23 21:28:09 +00:00
|
|
|
// this might break the transient_for layering
|
|
|
|
|
2006-05-13 11:07:50 +00:00
|
|
|
// do restack if both items are on the same layer
|
|
|
|
// else ignore restack
|
|
|
|
if (&below_item.getLayer() == &above_item.getLayer())
|
2008-10-01 09:29:59 +00:00
|
|
|
below_item.getLayer().stackBelowItem(below_item, &above_item);
|
2006-05-13 11:07:50 +00:00
|
|
|
|
2006-04-23 21:28:09 +00:00
|
|
|
|
2006-05-13 11:07:50 +00:00
|
|
|
return true;
|
2008-01-02 21:41:50 +00:00
|
|
|
} else if (ce.message_type == m_net->request_frame_extents) {
|
2006-07-22 07:15:24 +00:00
|
|
|
if (!screen)
|
|
|
|
return true;
|
2008-01-07 20:08:56 +00:00
|
|
|
FbTk::ThemeProxy<FbWinFrameTheme> &theme = screen->focusedWinFrameTheme();
|
|
|
|
unsigned int bw = theme->border().width();
|
2008-05-21 06:30:23 +00:00
|
|
|
long title_h = theme->titleHeight() ? theme->titleHeight() + 2*bw :
|
|
|
|
theme->font().height() + 2*theme->bevelWidth() + 2 + 2*bw;
|
2008-01-05 01:39:19 +00:00
|
|
|
long handle_h = theme->handleWidth() + 2*bw;
|
2006-12-31 14:10:55 +00:00
|
|
|
long extents[4];
|
2006-07-22 07:15:24 +00:00
|
|
|
// our frames currently don't protrude from left/right
|
2008-01-02 01:32:10 +00:00
|
|
|
extents[0] = bw;
|
|
|
|
extents[1] = bw;
|
2006-07-22 07:15:24 +00:00
|
|
|
extents[2] = title_h;
|
|
|
|
extents[3] = handle_h;
|
|
|
|
|
|
|
|
XChangeProperty(FbTk::App::instance()->display(), ce.window,
|
2008-01-02 21:41:50 +00:00
|
|
|
m_net->frame_extents, XA_CARDINAL, 32, PropModeReplace,
|
2006-07-22 07:15:24 +00:00
|
|
|
(unsigned char *)extents, 4);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2008-01-02 21:41:50 +00:00
|
|
|
} else if (ce.message_type == m_net->wm_moveresize) {
|
2006-05-13 11:07:50 +00:00
|
|
|
if (winclient == 0 || winclient->fbwindow() == 0)
|
|
|
|
return true;
|
2006-10-30 19:31:15 +00:00
|
|
|
// data.l[0] = x_root
|
2006-05-13 11:07:50 +00:00
|
|
|
// data.l[1] = y_root
|
|
|
|
// data.l[2] = direction
|
|
|
|
// data.l[3] = button
|
|
|
|
// data.l[4] = source indication
|
|
|
|
switch (ce.data.l[2] ) {
|
|
|
|
case _NET_WM_MOVERESIZE_SIZE_TOPLEFT:
|
|
|
|
case _NET_WM_MOVERESIZE_SIZE_TOP:
|
|
|
|
case _NET_WM_MOVERESIZE_SIZE_TOPRIGHT:
|
|
|
|
case _NET_WM_MOVERESIZE_SIZE_RIGHT:
|
|
|
|
case _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT:
|
|
|
|
case _NET_WM_MOVERESIZE_SIZE_BOTTOM:
|
|
|
|
case _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT:
|
|
|
|
case _NET_WM_MOVERESIZE_SIZE_LEFT:
|
|
|
|
case _NET_WM_MOVERESIZE_SIZE_KEYBOARD:
|
2006-07-20 10:22:31 +00:00
|
|
|
// startResizing uses relative coordinates
|
|
|
|
winclient->fbwindow()->startResizing(ce.data.l[0] -
|
|
|
|
winclient->fbwindow()->x() -
|
|
|
|
winclient->fbwindow()->frame().window().borderWidth(),
|
|
|
|
ce.data.l[1] - winclient->fbwindow()->y() -
|
|
|
|
winclient->fbwindow()->frame().window().borderWidth(),
|
2008-08-18 12:12:30 +00:00
|
|
|
static_cast<FluxboxWindow::ReferenceCorner>(ce.data.l[2]));
|
2006-05-13 11:07:50 +00:00
|
|
|
break;
|
|
|
|
case _NET_WM_MOVERESIZE_MOVE:
|
|
|
|
case _NET_WM_MOVERESIZE_MOVE_KEYBOARD:
|
|
|
|
winclient->fbwindow()->startMoving(ce.data.l[0], ce.data.l[1]);
|
|
|
|
break;
|
2006-07-22 07:15:24 +00:00
|
|
|
case _NET_WM_MOVERESIZE_CANCEL:
|
|
|
|
if (winclient->fbwindow()->isMoving())
|
|
|
|
winclient->fbwindow()->stopMoving(true);
|
|
|
|
if (winclient->fbwindow()->isResizing())
|
|
|
|
winclient->fbwindow()->stopResizing(true);
|
|
|
|
break;
|
2006-05-13 11:07:50 +00:00
|
|
|
default:
|
|
|
|
cerr << "Ewmh: Unknown move/resize direction: " << ce.data.l[2] << endl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2006-06-11 13:09:44 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
// we didn't handle the ce.message_type here
|
|
|
|
return false;
|
2002-10-02 16:26:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-28 15:06:36 +00:00
|
|
|
bool Ewmh::propertyNotify(WinClient &winclient, Atom the_property) {
|
2008-01-02 21:41:50 +00:00
|
|
|
if (the_property == m_net->wm_strut) {
|
2003-07-28 15:06:36 +00:00
|
|
|
updateStrut(winclient);
|
2003-06-18 13:34:30 +00:00
|
|
|
return true;
|
2008-01-02 21:41:50 +00:00
|
|
|
} else if (the_property == m_net->wm_name) {
|
2006-05-07 10:08:25 +00:00
|
|
|
FbTk::FbString newtitle = winclient.textProperty(the_property);
|
|
|
|
if (!newtitle.empty())
|
|
|
|
winclient.setTitle(newtitle);
|
2006-06-19 18:31:36 +00:00
|
|
|
if (winclient.fbwindow())
|
2010-03-26 17:15:45 +00:00
|
|
|
winclient.fbwindow()->titleSig().emit(newtitle, *winclient.fbwindow());
|
2006-05-07 10:08:25 +00:00
|
|
|
return true;
|
2008-01-02 21:41:50 +00:00
|
|
|
} else if (the_property == m_net->wm_icon_name) {
|
2007-11-05 17:05:58 +00:00
|
|
|
// we don't use icon title, since we don't show icons
|
2006-05-07 10:08:25 +00:00
|
|
|
return true;
|
2008-02-24 20:58:24 +00:00
|
|
|
} else if (the_property == m_net->wm_icon) {
|
|
|
|
extractNetWmIcon(m_net->wm_icon, winclient);
|
|
|
|
return true;
|
2006-05-07 10:08:25 +00:00
|
|
|
}
|
2003-06-18 13:34:30 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-06-30 16:54:05 +00:00
|
|
|
// wrapper for real setState, since most operations don't need the client
|
2003-09-23 13:52:05 +00:00
|
|
|
void Ewmh::setState(FluxboxWindow &win, Atom state, bool value) {
|
2007-06-30 01:28:54 +00:00
|
|
|
setState(win, state, value, win.winClient());
|
|
|
|
}
|
|
|
|
|
2007-06-30 16:54:05 +00:00
|
|
|
// wrapper for real toggleState, since most operations don't need the client
|
|
|
|
void Ewmh::toggleState(FluxboxWindow &win, Atom state) {
|
|
|
|
toggleState(win, state, win.winClient());
|
|
|
|
}
|
|
|
|
|
2007-06-30 01:28:54 +00:00
|
|
|
// set window state
|
|
|
|
void Ewmh::setState(FluxboxWindow &win, Atom state, bool value,
|
|
|
|
WinClient &client) {
|
2008-01-02 21:41:50 +00:00
|
|
|
if (state == m_net->wm_state_sticky) { // STICKY
|
2008-08-16 12:54:07 +00:00
|
|
|
if ((value && !win.isStuck()) ||
|
2002-12-01 13:42:15 +00:00
|
|
|
(!value && win.isStuck()))
|
|
|
|
win.stick();
|
2008-01-02 21:41:50 +00:00
|
|
|
} else if (state == m_net->wm_state_shaded) { // SHADED
|
2002-12-01 13:42:15 +00:00
|
|
|
if ((value && !win.isShaded()) ||
|
|
|
|
(!value && win.isShaded()))
|
|
|
|
win.shade();
|
2008-01-02 21:41:50 +00:00
|
|
|
} else if (state == m_net->wm_state_maximized_horz ) { // maximized Horizontal
|
2007-10-23 17:34:30 +00:00
|
|
|
if (value ^ win.isMaximizedHorz())
|
|
|
|
win.maximizeHorizontal();
|
2008-01-02 21:41:50 +00:00
|
|
|
} else if (state == m_net->wm_state_maximized_vert) { // maximized Vertical
|
2007-10-23 17:34:30 +00:00
|
|
|
if (value ^ win.isMaximizedVert())
|
|
|
|
win.maximizeVertical();
|
2008-01-02 21:41:50 +00:00
|
|
|
} else if (state == m_net->wm_state_fullscreen) { // fullscreen
|
2004-12-21 16:17:14 +00:00
|
|
|
if ((value && !win.isFullscreen()) ||
|
|
|
|
(!value && win.isFullscreen()))
|
2007-01-04 20:34:24 +00:00
|
|
|
win.setFullscreen(value);
|
2008-01-02 21:41:50 +00:00
|
|
|
} else if (state == m_net->wm_state_hidden) { // minimized
|
2006-03-09 18:33:36 +00:00
|
|
|
if (value && !win.isIconic())
|
|
|
|
win.iconify();
|
|
|
|
else if (!value && win.isIconic())
|
|
|
|
win.deiconify();
|
2008-01-02 21:41:50 +00:00
|
|
|
} else if (state == m_net->wm_state_skip_taskbar) { // skip taskbar
|
2004-12-21 16:17:14 +00:00
|
|
|
win.setIconHidden(value);
|
2008-01-02 21:41:50 +00:00
|
|
|
} else if (state == m_net->wm_state_below) { // bottom layer
|
2004-01-19 22:43:08 +00:00
|
|
|
if (value)
|
2011-03-23 11:02:15 +00:00
|
|
|
win.moveToLayer(ResourceLayer::BOTTOM);
|
|
|
|
else if (win.layerNum() > ResourceLayer::NORMAL)
|
|
|
|
win.moveToLayer(ResourceLayer::NORMAL);
|
2008-01-02 21:41:50 +00:00
|
|
|
} else if (state == m_net->wm_state_above) { // above layer
|
2004-01-19 22:43:08 +00:00
|
|
|
if (value)
|
2011-03-23 11:02:15 +00:00
|
|
|
win.moveToLayer(ResourceLayer::ABOVE_DOCK);
|
|
|
|
else if (win.layerNum() < ResourceLayer::NORMAL)
|
|
|
|
win.moveToLayer(ResourceLayer::NORMAL);
|
2008-01-02 21:41:50 +00:00
|
|
|
} else if (state == m_net->wm_state_demands_attention) {
|
2006-06-11 12:47:47 +00:00
|
|
|
if (value) { // if add attention
|
2007-06-30 01:28:54 +00:00
|
|
|
Fluxbox::instance()->attentionHandler().addAttention(client);
|
2006-06-11 12:47:47 +00:00
|
|
|
} else { // erase it
|
2010-03-18 18:41:35 +00:00
|
|
|
Fluxbox::instance()->attentionHandler().removeWindow(client);
|
2006-06-11 12:47:47 +00:00
|
|
|
}
|
2008-01-02 21:41:50 +00:00
|
|
|
} else if (state == m_net->wm_state_modal) {
|
2007-06-30 16:54:05 +00:00
|
|
|
client.setStateModal(value);
|
2004-01-19 22:43:08 +00:00
|
|
|
}
|
2006-05-13 16:20:00 +00:00
|
|
|
|
2002-10-11 10:20:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// toggle window state
|
2007-06-30 16:54:05 +00:00
|
|
|
void Ewmh::toggleState(FluxboxWindow &win, Atom state, WinClient &client) {
|
2008-01-02 21:41:50 +00:00
|
|
|
if (state == m_net->wm_state_sticky) { // sticky
|
2002-12-01 13:42:15 +00:00
|
|
|
win.stick();
|
2008-01-02 21:41:50 +00:00
|
|
|
} else if (state == m_net->wm_state_shaded){ // shaded
|
2002-12-01 13:42:15 +00:00
|
|
|
win.shade();
|
2008-01-02 21:41:50 +00:00
|
|
|
} else if (state == m_net->wm_state_maximized_horz ) { // maximized Horizontal
|
2003-08-27 21:06:04 +00:00
|
|
|
win.maximizeHorizontal();
|
2008-01-02 21:41:50 +00:00
|
|
|
} else if (state == m_net->wm_state_maximized_vert) { // maximized Vertical
|
2003-08-27 21:06:04 +00:00
|
|
|
win.maximizeVertical();
|
2008-01-02 21:41:50 +00:00
|
|
|
} else if (state == m_net->wm_state_fullscreen) { // fullscreen
|
2007-01-04 20:34:24 +00:00
|
|
|
win.setFullscreen(!win.isFullscreen()); // toggle current state
|
2008-01-02 21:41:50 +00:00
|
|
|
} else if (state == m_net->wm_state_hidden) { // minimized
|
2006-03-09 18:33:36 +00:00
|
|
|
if(win.isIconic())
|
|
|
|
win.deiconify();
|
|
|
|
else
|
|
|
|
win.iconify();
|
2008-01-02 21:41:50 +00:00
|
|
|
} else if (state == m_net->wm_state_skip_taskbar) { // taskbar
|
2004-02-20 09:07:27 +00:00
|
|
|
win.setIconHidden(!win.isIconHidden());
|
2008-01-02 21:41:50 +00:00
|
|
|
} else if (state == m_net->wm_state_below) { // bottom layer
|
2011-03-23 11:02:15 +00:00
|
|
|
if (win.layerNum() == ResourceLayer::BOTTOM)
|
|
|
|
win.moveToLayer(ResourceLayer::NORMAL);
|
2004-01-19 22:43:08 +00:00
|
|
|
else
|
2011-03-23 11:02:15 +00:00
|
|
|
win.moveToLayer(ResourceLayer::BOTTOM);
|
2004-01-21 15:42:14 +00:00
|
|
|
|
2008-01-02 21:41:50 +00:00
|
|
|
} else if (state == m_net->wm_state_above) { // top layer
|
2011-03-23 11:02:15 +00:00
|
|
|
if (win.layerNum() == ResourceLayer::ABOVE_DOCK)
|
|
|
|
win.moveToLayer(ResourceLayer::NORMAL);
|
2004-01-19 22:43:08 +00:00
|
|
|
else
|
2011-03-23 11:02:15 +00:00
|
|
|
win.moveToLayer(ResourceLayer::ABOVE_DOCK);
|
2008-01-02 21:41:50 +00:00
|
|
|
} else if (state == m_net->wm_state_modal) { // modal
|
2007-06-30 16:54:05 +00:00
|
|
|
client.setStateModal(!client.isStateModal());
|
2003-08-27 21:06:04 +00:00
|
|
|
}
|
2004-01-19 22:43:08 +00:00
|
|
|
|
2002-10-11 10:20:33 +00:00
|
|
|
}
|
|
|
|
|
2003-06-18 13:34:30 +00:00
|
|
|
|
2003-07-28 15:06:36 +00:00
|
|
|
void Ewmh::updateStrut(WinClient &winclient) {
|
2003-06-18 13:34:30 +00:00
|
|
|
Atom ret_type = 0;
|
|
|
|
int fmt = 0;
|
|
|
|
unsigned long nitems = 0, bytes_after = 0;
|
2006-08-09 04:54:58 +00:00
|
|
|
long *data = 0;
|
2008-01-02 21:41:50 +00:00
|
|
|
if (winclient.property(m_net->wm_strut, 0, 4, False, XA_CARDINAL,
|
2003-06-18 13:34:30 +00:00
|
|
|
&ret_type, &fmt, &nitems, &bytes_after,
|
2006-08-09 04:54:58 +00:00
|
|
|
(unsigned char **) &data) && data) {
|
2004-01-21 15:42:14 +00:00
|
|
|
|
2004-09-11 13:45:16 +00:00
|
|
|
int head = winclient.screen().getHead(winclient);
|
2006-10-30 19:31:15 +00:00
|
|
|
winclient.setStrut(winclient.screen().requestStrut(head,
|
|
|
|
data[0], data[1],
|
2004-09-11 13:45:16 +00:00
|
|
|
data[2], data[3]));
|
|
|
|
winclient.screen().updateAvailableWorkspaceArea();
|
2003-06-18 13:34:30 +00:00
|
|
|
}
|
|
|
|
}
|
2003-09-23 13:52:05 +00:00
|
|
|
|
2006-05-07 10:08:25 +00:00
|
|
|
|
|
|
|
|
2006-04-23 17:00:33 +00:00
|
|
|
void Ewmh::updateActions(FluxboxWindow &win) {
|
|
|
|
|
|
|
|
/* From Extended Window Manager Hints, draft 1.3:
|
|
|
|
*
|
|
|
|
* _NET_WM_ALLOWED_ACTIONS, ATOM[]
|
|
|
|
*
|
2006-10-30 19:31:15 +00:00
|
|
|
* A list of atoms indicating user operations that the
|
2006-04-23 17:00:33 +00:00
|
|
|
* Window Manager supports for this window. Atoms present in the
|
2006-10-30 19:31:15 +00:00
|
|
|
* list indicate allowed actions, atoms not present in the list
|
|
|
|
* indicate actions that are not supported for this window. The
|
|
|
|
* Window Manager MUST keep this property updated to reflect the
|
2006-04-23 17:00:33 +00:00
|
|
|
* actions which are currently "active" or "sensitive" for a window.
|
2006-10-30 19:31:15 +00:00
|
|
|
* Taskbars, Pagers, and other tools use _NET_WM_ALLOWED_ACTIONS to
|
|
|
|
* decide which actions should be made available to the user.
|
2006-04-23 17:00:33 +00:00
|
|
|
*/
|
2006-10-30 19:31:15 +00:00
|
|
|
|
|
|
|
typedef vector<Atom> ActionsVector;
|
2006-04-23 17:00:33 +00:00
|
|
|
ActionsVector actions;
|
|
|
|
actions.reserve(10);
|
|
|
|
// all windows can change desktop,
|
|
|
|
// be shaded or be sticky
|
2008-01-02 21:41:50 +00:00
|
|
|
actions.push_back(m_net->wm_action_change_desktop);
|
|
|
|
actions.push_back(m_net->wm_action_shade);
|
|
|
|
actions.push_back(m_net->wm_action_stick);
|
2006-10-30 19:31:15 +00:00
|
|
|
|
2006-04-23 17:00:33 +00:00
|
|
|
if (win.isResizable())
|
2008-01-02 21:41:50 +00:00
|
|
|
actions.push_back(m_net->wm_action_resize);
|
2006-04-23 17:00:33 +00:00
|
|
|
if (win.isMoveable())
|
2008-01-02 21:41:50 +00:00
|
|
|
actions.push_back(m_net->wm_action_move);
|
2006-04-23 17:00:33 +00:00
|
|
|
if (win.isClosable())
|
2008-01-02 21:41:50 +00:00
|
|
|
actions.push_back(m_net->wm_action_close);
|
2006-04-23 17:00:33 +00:00
|
|
|
if (win.isIconifiable())
|
2008-01-02 21:41:50 +00:00
|
|
|
actions.push_back(m_net->wm_action_minimize);
|
2006-04-23 17:00:33 +00:00
|
|
|
|
|
|
|
unsigned int max_width, max_height;
|
2008-08-15 17:38:41 +00:00
|
|
|
win.getMaxSize(&max_width, &max_height);
|
2006-04-23 17:00:33 +00:00
|
|
|
|
|
|
|
// if unlimited max width we can maximize horizontal
|
|
|
|
if (max_width == 0) {
|
2008-01-02 21:41:50 +00:00
|
|
|
actions.push_back(m_net->wm_action_maximize_horz);
|
2006-04-23 17:00:33 +00:00
|
|
|
}
|
|
|
|
// if unlimited max height we can maxmize vert
|
|
|
|
if (max_height == 0) {
|
2008-01-02 21:41:50 +00:00
|
|
|
actions.push_back(m_net->wm_action_maximize_vert);
|
2006-04-23 17:00:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// if we have unlimited size in all directions we can have this window
|
|
|
|
// in fullscreen mode
|
|
|
|
if (max_height == 0 && max_width == 0) {
|
2008-01-02 21:41:50 +00:00
|
|
|
actions.push_back(m_net->wm_action_fullscreen);
|
2006-04-23 17:00:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FluxboxWindow::ClientList::iterator it = win.clientList().begin();
|
|
|
|
FluxboxWindow::ClientList::iterator it_end = win.clientList().end();
|
|
|
|
for (; it != it_end; ++it) {
|
2008-01-02 21:41:50 +00:00
|
|
|
(*it)->changeProperty(m_net->wm_allowed_actions, XA_ATOM, 32, PropModeReplace,
|
2006-04-23 17:00:33 +00:00
|
|
|
reinterpret_cast<unsigned char*>(&actions.front()),
|
2006-10-30 19:31:15 +00:00
|
|
|
actions.size());
|
2006-04-23 17:00:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-01-21 15:42:14 +00:00
|
|
|
void Ewmh::setupState(FluxboxWindow &win) {
|
|
|
|
/* From Extended Window Manager Hints, draft 1.3:
|
|
|
|
*
|
|
|
|
* _NET_WM_STATE, ATOM[]
|
|
|
|
*
|
2004-09-10 15:36:04 +00:00
|
|
|
* A list of hints describing the window state. Atoms present in
|
|
|
|
* the list MUST be considered set, atoms not present in the list
|
|
|
|
* MUST be considered not set. The Window Manager SHOULD honor
|
2004-01-21 15:42:14 +00:00
|
|
|
* _NET_WM_STATE whenever a withdrawn window requests to be mapped.
|
2004-09-10 15:36:04 +00:00
|
|
|
* A Client wishing to change the state of a window MUST send a
|
|
|
|
* _NET_WM_STATE client message to the root window (see below).
|
|
|
|
* The Window Manager MUST keep this property updated to reflect
|
|
|
|
* the current state of the window.
|
|
|
|
*
|
|
|
|
* The Window Manager should remove the property whenever a window
|
2004-01-21 15:42:14 +00:00
|
|
|
* is withdrawn, but it should leave the property in place when it
|
2004-09-10 15:36:04 +00:00
|
|
|
* is shutting down, e.g. in response to losing ownership of the
|
2004-01-21 15:42:14 +00:00
|
|
|
* WM_Sn manager selection.
|
|
|
|
*/
|
|
|
|
Atom ret_type;
|
|
|
|
int fmt;
|
|
|
|
unsigned long nitems, bytes_after;
|
|
|
|
unsigned char *data = 0;
|
|
|
|
|
2008-01-02 21:41:50 +00:00
|
|
|
win.winClient().property(m_net->wm_state, 0, 0x7fffffff, False, XA_ATOM,
|
2004-09-10 15:36:04 +00:00
|
|
|
&ret_type, &fmt, &nitems, &bytes_after,
|
2004-01-21 15:42:14 +00:00
|
|
|
&data);
|
2004-09-10 15:36:04 +00:00
|
|
|
if (data) {
|
2004-01-21 15:42:14 +00:00
|
|
|
Atom *states = (Atom *)data;
|
|
|
|
for (unsigned long i=0; i < nitems; ++i)
|
|
|
|
setState(win, states[i], true);
|
|
|
|
|
|
|
|
XFree(data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-18 21:23:24 +00:00
|
|
|
void Ewmh::updateFrameExtents(FluxboxWindow &win) {
|
2006-10-30 19:31:15 +00:00
|
|
|
/* Frame extents are basically the amount the window manager frame
|
2006-06-26 11:45:14 +00:00
|
|
|
protrudes from the client window, on left, right, top, bottom
|
|
|
|
(it is independent of window position).
|
|
|
|
*/
|
2006-06-18 21:23:24 +00:00
|
|
|
|
|
|
|
FluxboxWindow::ClientList::iterator it = win.clientList().begin();
|
|
|
|
FluxboxWindow::ClientList::iterator it_end = win.clientList().end();
|
|
|
|
for (; it != it_end; ++it) {
|
2008-01-02 01:32:10 +00:00
|
|
|
long extents[4];
|
|
|
|
// our frames currently don't protrude from left/right
|
2008-05-16 01:48:35 +00:00
|
|
|
int bw = win.frame().window().borderWidth();
|
2008-01-02 01:32:10 +00:00
|
|
|
extents[0] = bw;
|
|
|
|
extents[1] = bw;
|
|
|
|
extents[2] = win.frame().titlebarHeight() + bw;
|
|
|
|
extents[3] = win.frame().handleHeight() + bw;
|
|
|
|
|
2008-01-02 21:41:50 +00:00
|
|
|
(*it)->changeProperty(m_net->frame_extents,
|
2006-06-18 21:23:24 +00:00
|
|
|
XA_CARDINAL, 32, PropModeReplace,
|
|
|
|
(unsigned char *)extents, 4);
|
|
|
|
}
|
|
|
|
}
|
2009-09-30 19:02:24 +00:00
|
|
|
|