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-11-19 11:37:27 +00:00
|
|
|
// $Id$
|
2002-10-02 16:26:05 +00:00
|
|
|
|
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 17:00:33 +00:00
|
|
|
#include "WinClientUtil.hh"
|
2006-04-23 21:42:11 +00:00
|
|
|
#include "fluxbox.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"
|
2006-04-23 21:42:11 +00:00
|
|
|
#include "FbTk/XLayerItem.hh"
|
|
|
|
#include "FbTk/XLayer.hh"
|
2004-01-19 18:21:51 +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>
|
2004-10-21 10:57:38 +00:00
|
|
|
|
2002-10-02 16:26:05 +00:00
|
|
|
using namespace std;
|
|
|
|
|
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
|
|
|
|
|
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,
|
|
|
|
_NET_WM_MOVERESIZE_MOVE = 8, // movement only
|
|
|
|
_NET_WM_MOVERESIZE_SIZE_KEYBOARD = 9, // size via keyboard
|
|
|
|
_NET_WM_MOVERESIZE_MOVE_KEYBOARD = 10
|
|
|
|
};
|
2004-10-21 10:57:38 +00:00
|
|
|
|
2002-10-02 16:26:05 +00:00
|
|
|
Ewmh::Ewmh() {
|
2002-12-01 13:42:15 +00:00
|
|
|
createAtoms();
|
2002-10-02 16:26:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Ewmh::~Ewmh() {
|
2002-12-01 13:42:15 +00:00
|
|
|
while (!m_windows.empty()) {
|
2003-03-04 11:06:03 +00:00
|
|
|
XDestroyWindow(FbTk::App::instance()->display(), m_windows.back());
|
2002-12-01 13:42:15 +00:00
|
|
|
m_windows.pop_back();
|
|
|
|
}
|
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
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* the _NET_WM_NAME property set to the name of the Window Manager.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* Window Manager is present.
|
|
|
|
*/
|
2002-10-02 16:26:05 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
Window wincheck = XCreateSimpleWindow(disp,
|
2004-09-10 15:36:04 +00:00
|
|
|
screen.rootWindow().window(),
|
2004-12-21 16:17:14 +00:00
|
|
|
-10, -10, 5, 5, 0, 0, 0);
|
2002-10-16 23:32:17 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (wincheck != None) {
|
2003-08-11 14:51:15 +00:00
|
|
|
// store the window so we can delete it later
|
2002-12-01 13:42:15 +00:00
|
|
|
m_windows.push_back(wincheck);
|
2004-09-10 15:36:04 +00:00
|
|
|
|
2003-05-19 22:43:48 +00:00
|
|
|
screen.rootWindow().changeProperty(m_net_supporting_wm_check, XA_WINDOW, 32,
|
|
|
|
PropModeReplace, (unsigned char *) &wincheck, 1);
|
2002-12-01 13:42:15 +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
|
|
|
|
2005-05-06 15:24:53 +00:00
|
|
|
XChangeProperty(disp, wincheck, m_net_wm_name, 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
|
2003-06-18 13:34:30 +00:00
|
|
|
m_net_wm_strut,
|
2002-12-01 13:42:15 +00:00
|
|
|
m_net_wm_state,
|
2006-05-13 11:07:50 +00:00
|
|
|
m_net_wm_name,
|
|
|
|
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:
|
|
|
|
m_net_wm_state_sticky,
|
|
|
|
m_net_wm_state_shaded,
|
2004-12-21 16:17:14 +00:00
|
|
|
m_net_wm_state_maximized_horz,
|
|
|
|
m_net_wm_state_maximized_vert,
|
|
|
|
m_net_wm_state_fullscreen,
|
2004-01-18 19:14:08 +00:00
|
|
|
m_net_wm_state_hidden,
|
|
|
|
m_net_wm_state_skip_taskbar,
|
2006-04-23 17:00:33 +00:00
|
|
|
m_net_wm_state_modal,
|
|
|
|
m_net_wm_state_below,
|
|
|
|
m_net_wm_state_above,
|
2006-05-13 16:20:00 +00:00
|
|
|
m_net_wm_state_demands_attention,
|
2006-04-23 17:00:33 +00:00
|
|
|
|
2004-01-21 09:37:10 +00:00
|
|
|
// window type
|
|
|
|
m_net_wm_window_type,
|
|
|
|
m_net_wm_window_type_dock,
|
2004-06-20 04:49:33 +00:00
|
|
|
m_net_wm_window_type_desktop,
|
2006-04-23 17:00:33 +00:00
|
|
|
m_net_wm_window_type_splash,
|
2006-06-18 21:23:24 +00:00
|
|
|
m_net_wm_window_type_dialog,
|
2006-05-13 16:20:00 +00:00
|
|
|
m_net_wm_window_type_normal,
|
2006-04-23 17:00:33 +00:00
|
|
|
|
|
|
|
// window actions
|
|
|
|
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
|
|
|
|
m_net_client_list,
|
2004-01-19 18:21:51 +00:00
|
|
|
m_net_client_list_stacking,
|
2002-12-01 13:42:15 +00:00
|
|
|
m_net_number_of_desktops,
|
|
|
|
m_net_current_desktop,
|
|
|
|
m_net_active_window,
|
|
|
|
m_net_close_window,
|
2004-09-10 15:36:04 +00:00
|
|
|
m_net_moveresize_window,
|
2004-01-19 18:21:51 +00:00
|
|
|
m_net_workarea,
|
2006-04-23 21:28:09 +00:00
|
|
|
m_net_restack_window,
|
2004-01-19 18:21:51 +00:00
|
|
|
|
2006-06-11 13:09:44 +00:00
|
|
|
m_net_wm_moveresize,
|
2006-05-13 11:07:50 +00:00
|
|
|
|
2006-06-18 21:23:24 +00:00
|
|
|
m_net_frame_extents,
|
2006-05-13 11:07:50 +00:00
|
|
|
|
2004-01-19 18:21:51 +00:00
|
|
|
// desktop properties
|
|
|
|
m_net_wm_desktop,
|
2002-12-01 13:42:15 +00:00
|
|
|
m_net_desktop_names,
|
2004-01-19 18:21:51 +00:00
|
|
|
m_net_desktop_viewport,
|
|
|
|
m_net_desktop_geometry,
|
2004-09-10 15:36:04 +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
|
|
|
*/
|
2003-05-19 22:43:48 +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
|
|
|
|
|
|
|
FbTk::FbString newtitle = winclient.textProperty(m_net_wm_name);
|
|
|
|
if (!newtitle.empty()) {
|
|
|
|
winclient.setTitle(newtitle);
|
|
|
|
}
|
|
|
|
newtitle = winclient.textProperty(m_net_wm_icon_name);
|
|
|
|
if (!newtitle.empty()) {
|
|
|
|
winclient.setIconTitle(newtitle);
|
|
|
|
}
|
2006-06-19 18:31:36 +00:00
|
|
|
|
|
|
|
if ( winclient.fbwindow() )
|
|
|
|
winclient.fbwindow()->titleSig().notify();
|
2003-07-28 15:06:36 +00:00
|
|
|
}
|
|
|
|
|
2003-07-04 01:03:41 +00:00
|
|
|
void Ewmh::setupFrame(FluxboxWindow &win) {
|
2002-12-01 13:42:15 +00:00
|
|
|
Atom ret_type;
|
|
|
|
int fmt;
|
|
|
|
unsigned long nitems, bytes_after;
|
2004-01-18 19:14:08 +00:00
|
|
|
unsigned char *data = 0;
|
|
|
|
|
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
|
|
|
|
2004-09-10 15:36:04 +00:00
|
|
|
win.winClient().property(m_net_wm_window_type, 0, 0x7fffffff, False, XA_ATOM,
|
|
|
|
&ret_type, &fmt, &nitems, &bytes_after,
|
|
|
|
&data);
|
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) {
|
2004-01-21 09:37:10 +00:00
|
|
|
/* From Extended Window Manager Hints, draft 1.3:
|
|
|
|
*
|
2004-09-10 15:36:04 +00:00
|
|
|
* _NET_WM_WINDOW_TYPE_DOCK indicates a dock or panel feature.
|
|
|
|
* Typically a Window Manager would keep such windows on top
|
2004-01-21 09:37:10 +00:00
|
|
|
* of all other windows.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
if (atoms[l] == m_net_wm_window_type_dock) {
|
|
|
|
// we also assume it shouldn't be visible in any toolbar
|
2004-02-20 09:07:27 +00:00
|
|
|
win.setFocusHidden(true);
|
|
|
|
win.setIconHidden(true);
|
2004-06-20 04:49:33 +00:00
|
|
|
} else if (atoms[l] == m_net_wm_window_type_desktop) {
|
|
|
|
/*
|
2004-07-21 18:56:34 +00:00
|
|
|
* _NET_WM_WINDOW_TYPE_DESKTOP indicates a "false desktop" window
|
2004-06-20 04:49:33 +00:00
|
|
|
* We let it be the size it wants, but it gets no decoration,
|
|
|
|
* is hidden in the toolbar and window cycling list, plus
|
|
|
|
* windows don't tab with it and is right on the bottom.
|
|
|
|
*/
|
|
|
|
|
|
|
|
win.setFocusHidden(true);
|
|
|
|
win.setIconHidden(true);
|
2006-02-20 21:04:35 +00:00
|
|
|
win.moveToLayer(Layer::DESKTOP);
|
2004-06-20 04:49:33 +00:00
|
|
|
win.setDecorationMask(0);
|
|
|
|
win.setTabable(false);
|
|
|
|
win.setMovable(false);
|
|
|
|
win.setResizable(false);
|
|
|
|
win.stick();
|
2006-04-23 17:00:33 +00:00
|
|
|
|
|
|
|
} else if (atoms[l] == m_net_wm_window_type_splash) {
|
|
|
|
/*
|
|
|
|
* _NET_WM_WINDOW_TYPE_SPLASH indicates that the
|
|
|
|
* window is a splash screen displayed as an application
|
|
|
|
* is starting up.
|
|
|
|
*/
|
|
|
|
win.setDecoration(FluxboxWindow::DECOR_NONE);
|
2006-06-18 21:23:24 +00:00
|
|
|
win.setFocusHidden(true);
|
|
|
|
win.setIconHidden(true);
|
2006-04-23 17:00:33 +00:00
|
|
|
win.setMovable(false);
|
2006-05-13 16:20:00 +00:00
|
|
|
} else if (atoms[l] == m_net_wm_window_type_normal) {
|
|
|
|
// do nothing, this is ..normal..
|
2006-06-18 21:23:24 +00:00
|
|
|
} else if (atoms[l] == m_net_wm_window_type_dialog) {
|
|
|
|
// dialog windows should not be tabable
|
|
|
|
win.setTabable(false);
|
2004-01-21 09:37:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2004-08-26 01:51:21 +00:00
|
|
|
XFree(data);
|
2006-06-18 21:23:24 +00:00
|
|
|
} else {
|
|
|
|
// if _NET_WM_WINDOW_TYPE not set and this window
|
|
|
|
// has transient_for the type must be set to _NET_WM_WINDOW_TYPE_DIALOG
|
|
|
|
if ( win.winClient().isTransient() ) {
|
|
|
|
win.winClient().
|
|
|
|
changeProperty(m_net_wm_window_type,
|
|
|
|
XA_ATOM, 32, PropModeReplace,
|
|
|
|
(unsigned char*)&m_net_wm_window_type_dialog, 1);
|
|
|
|
}
|
|
|
|
}
|
2004-01-21 15:42:14 +00:00
|
|
|
|
|
|
|
setupState(win);
|
|
|
|
|
2004-09-10 15:36:04 +00:00
|
|
|
if (win.winClient().property(m_net_wm_desktop, 0, 1, False, XA_CARDINAL,
|
|
|
|
&ret_type, &fmt, &nitems, &bytes_after,
|
2004-01-21 15:42:14 +00:00
|
|
|
(unsigned char **) &data) && data) {
|
2006-04-24 14:29:21 +00:00
|
|
|
unsigned int desktop = static_cast<long>(*data);
|
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);
|
2004-01-21 15:42:14 +00:00
|
|
|
|
|
|
|
XFree(data);
|
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) {
|
|
|
|
clearState(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
|
|
|
*
|
|
|
|
*/
|
|
|
|
screen.rootWindow().changeProperty(m_net_active_window,
|
|
|
|
XA_WINDOW, 32,
|
|
|
|
PropModeReplace,
|
|
|
|
(unsigned char *)&win, 1);
|
|
|
|
}
|
|
|
|
|
2005-05-14 01:55:31 +00:00
|
|
|
void Ewmh::updateClientClose(WinClient &winclient){
|
|
|
|
updateClientList(winclient.screen());
|
|
|
|
}
|
|
|
|
|
2003-03-03 21:51:13 +00:00
|
|
|
void Ewmh::updateClientList(BScreen &screen) {
|
2002-12-01 13:42:15 +00:00
|
|
|
size_t num=0;
|
|
|
|
|
2004-09-10 15:36:04 +00:00
|
|
|
BScreen::Workspaces::const_iterator workspace_it =
|
2003-04-15 00:17:59 +00:00
|
|
|
screen.getWorkspacesList().begin();
|
2004-09-10 15:36:04 +00:00
|
|
|
const BScreen::Workspaces::const_iterator workspace_it_end =
|
2003-04-15 00:17:59 +00:00
|
|
|
screen.getWorkspacesList().end();
|
2002-12-01 13:42:15 +00:00
|
|
|
for (; workspace_it != workspace_it_end; ++workspace_it) {
|
2004-09-10 15:36:04 +00:00
|
|
|
Workspace::Windows::iterator win_it =
|
2003-05-11 17:06:02 +00:00
|
|
|
(*workspace_it)->windowList().begin();
|
2004-09-10 15:36:04 +00:00
|
|
|
Workspace::Windows::iterator win_it_end =
|
2003-05-11 17:06:02 +00:00
|
|
|
(*workspace_it)->windowList().end();
|
2003-04-15 00:17:59 +00:00
|
|
|
for (; win_it != win_it_end; ++win_it) {
|
|
|
|
num += (*win_it)->numClients();
|
|
|
|
}
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
2003-04-15 12:22:06 +00:00
|
|
|
// and count icons
|
2005-07-04 18:19:53 +00:00
|
|
|
BScreen::Icons::const_iterator icon_it = screen.iconList().begin();
|
|
|
|
BScreen::Icons::const_iterator icon_it_end = screen.iconList().end();
|
2003-04-15 12:22:06 +00:00
|
|
|
for (; icon_it != icon_it_end; ++icon_it) {
|
|
|
|
num += (*icon_it)->numClients();
|
|
|
|
}
|
2004-06-07 11:46:05 +00:00
|
|
|
|
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-04-23 17:00:33 +00:00
|
|
|
cerr<<_FBTEXT(Ewmh, OutOfMemoryClientList,
|
|
|
|
"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
|
|
|
//start the iterator from begining
|
|
|
|
workspace_it = screen.getWorkspacesList().begin();
|
|
|
|
int win=0;
|
|
|
|
for (; workspace_it != workspace_it_end; ++workspace_it) {
|
2004-09-10 15:36:04 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
// Fill in array of window ID's
|
2004-09-10 15:36:04 +00:00
|
|
|
Workspace::Windows::const_iterator it =
|
2003-05-11 17:06:02 +00:00
|
|
|
(*workspace_it)->windowList().begin();
|
2004-09-10 15:36:04 +00:00
|
|
|
Workspace::Windows::const_iterator it_end =
|
|
|
|
(*workspace_it)->windowList().end();
|
2002-12-01 13:42:15 +00:00
|
|
|
for (; it != it_end; ++it) {
|
2004-01-18 19:14:08 +00:00
|
|
|
if ((*it)->numClients() == 1) {
|
2003-05-15 11:17:29 +00:00
|
|
|
wl[win++] = (*it)->clientWindow();
|
2004-01-18 19:14:08 +00:00
|
|
|
} else {
|
2003-04-14 12:13:36 +00:00
|
|
|
// add every client in fluxboxwindow to list window list
|
2004-09-10 15:36:04 +00:00
|
|
|
std::list<WinClient *>::iterator client_it =
|
2003-04-15 00:17:59 +00:00
|
|
|
(*it)->clientList().begin();
|
2004-09-10 15:36:04 +00:00
|
|
|
std::list<WinClient *>::iterator client_it_end =
|
2003-04-15 00:17:59 +00:00
|
|
|
(*it)->clientList().end();
|
2003-04-14 12:13:36 +00:00
|
|
|
for (; client_it != client_it_end; ++client_it)
|
|
|
|
wl[win++] = (*client_it)->window();
|
|
|
|
}
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
|
|
|
}
|
2002-12-27 02:15:08 +00:00
|
|
|
|
|
|
|
// plus iconified windows
|
2005-07-04 18:19:53 +00:00
|
|
|
icon_it = screen.iconList().begin();
|
2003-04-15 12:22:06 +00:00
|
|
|
for (; icon_it != icon_it_end; ++icon_it) {
|
|
|
|
FluxboxWindow::ClientList::iterator client_it = (*icon_it)->clientList().begin();
|
|
|
|
FluxboxWindow::ClientList::iterator client_it_end = (*icon_it)->clientList().end();
|
|
|
|
for (; client_it != client_it_end; ++client_it)
|
|
|
|
wl[win++] = (*client_it)->window();
|
2002-12-27 02:15:08 +00:00
|
|
|
}
|
2002-12-01 13:42:15 +00:00
|
|
|
//number of windows to show in client list
|
|
|
|
num = win;
|
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
|
|
|
*/
|
2003-12-18 18:03:23 +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);
|
2004-01-19 18:21:51 +00:00
|
|
|
screen.rootWindow().changeProperty(m_net_client_list_stacking,
|
|
|
|
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
|
|
|
|
|
|
|
char *names[number_of_desks];
|
|
|
|
|
|
|
|
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
|
|
|
|
Xutf8TextListToTextProperty(FbTk::App::instance()->display(),
|
|
|
|
names, number_of_desks, XUTF8StringStyle, &text);
|
|
|
|
XSetTextProperty(FbTk::App::instance()->display(), screen.rootWindow().window(),
|
|
|
|
&text, m_net_desktop_names);
|
|
|
|
|
|
|
|
XFree(text.value);
|
|
|
|
|
|
|
|
#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(),
|
2002-10-02 16:26:05 +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++)
|
2004-09-10 15:36:04 +00:00
|
|
|
delete [] names[i];
|
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();
|
2004-09-10 15:36:04 +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();
|
2004-09-10 15:36:04 +00:00
|
|
|
screen.rootWindow().changeProperty(m_net_number_of_desktops,
|
|
|
|
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
|
2004-01-19 18:21:51 +00:00
|
|
|
screen.rootWindow().changeProperty(m_net_desktop_viewport,
|
|
|
|
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()};
|
2004-01-19 18:21:51 +00:00
|
|
|
screen.rootWindow().changeProperty(m_net_desktop_geometry,
|
|
|
|
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);
|
|
|
|
|
|
|
|
}
|
|
|
|
screen.rootWindow().changeProperty(m_net_workarea,
|
|
|
|
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) {
|
2004-12-21 16:17:14 +00:00
|
|
|
|
2006-04-23 17:00:33 +00:00
|
|
|
|
|
|
|
updateActions(win);
|
2004-12-21 16:17:14 +00:00
|
|
|
|
2005-06-02 01:36:28 +00:00
|
|
|
typedef std::vector<unsigned int> StateVec;
|
|
|
|
|
|
|
|
StateVec state;
|
2004-12-21 16:17:14 +00:00
|
|
|
|
|
|
|
if (win.isStuck())
|
|
|
|
state.push_back(m_net_wm_state_sticky);
|
|
|
|
if (win.isShaded())
|
|
|
|
state.push_back(m_net_wm_state_shaded);
|
2006-02-20 21:04:35 +00:00
|
|
|
if (win.layerNum() == Layer::BOTTOM)
|
2004-12-21 16:17:14 +00:00
|
|
|
state.push_back(m_net_wm_state_below);
|
2006-02-20 21:04:35 +00:00
|
|
|
if (win.layerNum() == Layer::ABOVE_DOCK)
|
2004-12-21 16:17:14 +00:00
|
|
|
state.push_back(m_net_wm_state_above);
|
2005-06-02 01:36:28 +00:00
|
|
|
if (win.isIconic())
|
2004-12-21 16:17:14 +00:00
|
|
|
state.push_back(m_net_wm_state_hidden);
|
2005-06-02 01:36:28 +00:00
|
|
|
if (win.isIconHidden())
|
2004-12-21 16:17:14 +00:00
|
|
|
state.push_back(m_net_wm_state_skip_taskbar);
|
2006-04-23 17:00:33 +00:00
|
|
|
if (win.isFullscreen())
|
2004-12-21 16:17:14 +00:00
|
|
|
state.push_back(m_net_wm_state_fullscreen);
|
2006-04-23 17:00:33 +00:00
|
|
|
if (win.winClient().isModal())
|
|
|
|
state.push_back(m_net_wm_state_modal);
|
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) {
|
2005-06-02 01:36:28 +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.
|
|
|
|
StateVec client_state(state);
|
|
|
|
Atom ret_type;
|
|
|
|
int fmt;
|
|
|
|
unsigned long nitems, bytes_after;
|
|
|
|
unsigned char *data = 0;
|
|
|
|
|
|
|
|
(*it)->property(m_net_wm_state, 0, 0x7fffffff, False, XA_ATOM,
|
|
|
|
&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) {
|
2005-06-02 01:36:28 +00:00
|
|
|
if (old_states[i] == m_net_wm_state_skip_pager) {
|
|
|
|
client_state.push_back(m_net_wm_state_skip_pager);
|
|
|
|
}
|
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()) {
|
2004-12-21 16:17:14 +00:00
|
|
|
(*it)->changeProperty(m_net_wm_state, XA_ATOM, 32, PropModeReplace,
|
2005-06-02 01:36:28 +00:00
|
|
|
reinterpret_cast<unsigned char*>(&client_state.front()),
|
|
|
|
client_state.size());
|
2006-04-23 17:00:33 +00:00
|
|
|
} else
|
2004-12-21 16:17:14 +00:00
|
|
|
(*it)->deleteProperty(m_net_wm_state);
|
|
|
|
}
|
2002-10-02 16:26:05 +00:00
|
|
|
}
|
|
|
|
|
2003-02-02 16:32:41 +00:00
|
|
|
void Ewmh::updateLayer(FluxboxWindow &win) {
|
2003-04-14 12:13:36 +00:00
|
|
|
//!! TODO _NET_WM_WINDOW_TYPE
|
2004-07-21 18:56:34 +00:00
|
|
|
/*
|
|
|
|
if (win.getLayer() == Fluxbox::instance()->getAboveDockLayer()) {
|
|
|
|
// _NET_WM_STATE_BELOW
|
2004-09-10 15:36:04 +00:00
|
|
|
|
2004-07-21 18:56:34 +00:00
|
|
|
} else if (win.getLayer() == Fluxbox::instance()->getBottomLayer()) {
|
|
|
|
// _NET_WM_STATE_ABOVE
|
|
|
|
}
|
|
|
|
*/
|
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-06-11 13:09:44 +00:00
|
|
|
long workspace = win.isInitialized() ?
|
|
|
|
win.workspaceNumber() :
|
|
|
|
win.screen().currentWorkspaceID();
|
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) {
|
|
|
|
(*it)->changeProperty(m_net_wm_desktop, XA_CARDINAL, 32, PropModeReplace,
|
|
|
|
(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
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (ce.message_type == m_net_wm_desktop) {
|
|
|
|
// 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;
|
|
|
|
} 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) {
|
2003-07-28 15:06:36 +00:00
|
|
|
setState(win, ce.data.l[1], false);
|
|
|
|
setState(win, ce.data.l[2], false);
|
2002-12-01 13:42:15 +00:00
|
|
|
} else if (ce.data.l[0] == STATE_ADD) {
|
2003-07-28 15:06:36 +00:00
|
|
|
setState(win, ce.data.l[1], true);
|
|
|
|
setState(win, ce.data.l[2], true);
|
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;
|
|
|
|
} else if (ce.message_type == m_net_number_of_desktops) {
|
|
|
|
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;
|
|
|
|
} else if (ce.message_type == m_net_current_desktop) {
|
|
|
|
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;
|
|
|
|
} 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
|
|
|
|
2003-07-28 15:06:36 +00:00
|
|
|
winclient->focus();
|
2004-10-16 22:20:05 +00:00
|
|
|
if (winclient->fbwindow()) {
|
|
|
|
|
|
|
|
FluxboxWindow* fbwin = winclient->fbwindow();
|
|
|
|
fbwin->raise();
|
|
|
|
|
|
|
|
// if the raised window is on a different workspace
|
|
|
|
// we do what the user wish:
|
|
|
|
// either ignore|go to that workspace|get the window
|
|
|
|
if (fbwin->screen().currentWorkspaceID() != fbwin->workspaceNumber()) {
|
|
|
|
if (fbwin->screen().getFollowModel() == BScreen::FOLLOW_ACTIVE_WINDOW) {
|
|
|
|
fbwin->screen().changeWorkspaceID(fbwin->workspaceNumber());
|
|
|
|
} else if (fbwin->screen().getFollowModel() == BScreen::FETCH_ACTIVE_WINDOW) {
|
|
|
|
fbwin->screen().sendToWorkspace(fbwin->screen().currentWorkspaceID(), fbwin);
|
|
|
|
} // else we ignore it. my favourite mode :)
|
|
|
|
}
|
|
|
|
}
|
2002-12-01 13:42:15 +00:00
|
|
|
return true;
|
|
|
|
} 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;
|
|
|
|
} 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
|
|
|
|
// ce.data.l[1] = x
|
|
|
|
// ce.data.l[2] = y
|
|
|
|
// ce.data.l[3] = width
|
|
|
|
// ce.data.l[4] = height
|
2005-03-16 23:19:36 +00:00
|
|
|
// TODO: flags
|
|
|
|
int win_gravity=ce.data.l[0] & 0xFF;
|
|
|
|
winclient->fbwindow()->moveResizeForClient(ce.data.l[1], ce.data.l[2],
|
|
|
|
ce.data.l[3], ce.data.l[4], win_gravity);
|
2002-12-01 13:42:15 +00:00
|
|
|
return true;
|
2006-04-23 21:28:09 +00:00
|
|
|
} else if (ce.message_type == m_net_restack_window) {
|
|
|
|
#ifndef DEBUG
|
|
|
|
cerr << "Ewmh: restack window" << endl;
|
|
|
|
#endif // DEBUG
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2006-04-23 21:42:11 +00:00
|
|
|
FbTk::XLayerItem &below_item = winclient->fbwindow()->layerItem();
|
|
|
|
FbTk::XLayerItem &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())
|
|
|
|
below_item.getLayer().stackBelowItem(&below_item, &above_item);
|
|
|
|
|
2006-04-23 21:28:09 +00:00
|
|
|
|
2006-05-13 11:07:50 +00:00
|
|
|
return true;
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2006-06-11 13:09:44 +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;
|
|
|
|
// data.l[0] = x_root
|
|
|
|
// 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:
|
|
|
|
winclient->fbwindow()->startResizing(ce.data.l[0], ce.data.l[1],
|
|
|
|
static_cast<FluxboxWindow::ResizeDirection>
|
|
|
|
(ce.data.l[2]));
|
|
|
|
break;
|
|
|
|
case _NET_WM_MOVERESIZE_MOVE:
|
|
|
|
case _NET_WM_MOVERESIZE_MOVE_KEYBOARD:
|
|
|
|
winclient->fbwindow()->startMoving(ce.data.l[0], ce.data.l[1]);
|
|
|
|
break;
|
|
|
|
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) {
|
2003-06-18 13:34:30 +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;
|
2006-05-07 10:08:25 +00:00
|
|
|
} else if (the_property == m_net_wm_name) {
|
|
|
|
FbTk::FbString newtitle = winclient.textProperty(the_property);
|
|
|
|
if (!newtitle.empty())
|
|
|
|
winclient.setTitle(newtitle);
|
2006-06-19 18:31:36 +00:00
|
|
|
if (winclient.fbwindow())
|
|
|
|
winclient.fbwindow()->titleSig().notify();
|
2006-05-07 10:08:25 +00:00
|
|
|
return true;
|
|
|
|
} else if (the_property == m_net_wm_icon_name) {
|
|
|
|
FbTk::FbString newtitle = winclient.textProperty(the_property);
|
|
|
|
if (!newtitle.empty())
|
|
|
|
winclient.setIconTitle(newtitle);
|
2006-06-19 18:31:36 +00:00
|
|
|
if (winclient.fbwindow())
|
|
|
|
winclient.fbwindow()->titleSig().notify();
|
2006-05-07 10:08:25 +00:00
|
|
|
return true;
|
|
|
|
}
|
2003-06-18 13:34:30 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2002-10-02 16:26:05 +00:00
|
|
|
void Ewmh::createAtoms() {
|
2003-08-11 14:51:15 +00:00
|
|
|
|
2003-03-04 11:06:03 +00:00
|
|
|
Display *disp = FbTk::App::instance()->display();
|
2003-08-11 14:51:15 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
m_net_supported = XInternAtom(disp, "_NET_SUPPORTED", False);
|
|
|
|
m_net_client_list = XInternAtom(disp, "_NET_CLIENT_LIST", False);
|
|
|
|
m_net_client_list_stacking = XInternAtom(disp, "_NET_CLIENT_LIST_STACKING", False);
|
|
|
|
m_net_number_of_desktops = XInternAtom(disp, "_NET_NUMBER_OF_DESKTOPS", False);
|
|
|
|
m_net_desktop_geometry = XInternAtom(disp, "_NET_DESKTOP_GEOMETRY", False);
|
|
|
|
m_net_desktop_viewport = XInternAtom(disp, "_NET_DESKTOP_VIEWPORT", False);
|
|
|
|
m_net_current_desktop = XInternAtom(disp, "_NET_CURRENT_DESKTOP", False);
|
|
|
|
m_net_desktop_names = XInternAtom(disp, "_NET_DESKTOP_NAMES", False);
|
|
|
|
m_net_active_window = XInternAtom(disp, "_NET_ACTIVE_WINDOW", False);
|
|
|
|
m_net_workarea = XInternAtom(disp, "_NET_WORKAREA", False);
|
|
|
|
m_net_supporting_wm_check = XInternAtom(disp, "_NET_SUPPORTING_WM_CHECK", False);
|
|
|
|
m_net_virtual_roots = XInternAtom(disp, "_NET_VIRTUAL_ROOTS", False);
|
|
|
|
|
|
|
|
m_net_close_window = XInternAtom(disp, "_NET_CLOSE_WINDOW", False);
|
|
|
|
m_net_moveresize_window = XInternAtom(disp, "_NET_MOVERESIZE_WINDOW", False);
|
2006-04-23 21:28:09 +00:00
|
|
|
m_net_restack_window = XInternAtom(disp, "_NET_RESTACK_WINDOW", False);
|
2004-09-10 15:36:04 +00:00
|
|
|
|
2006-06-11 13:09:44 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
m_net_wm_moveresize = XInternAtom(disp, "_NET_WM_MOVERESIZE", False);
|
2002-10-02 16:26:05 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
m_net_properties = XInternAtom(disp, "_NET_PROPERTIES", False);
|
|
|
|
m_net_wm_name = XInternAtom(disp, "_NET_WM_NAME", False);
|
2006-05-07 10:08:25 +00:00
|
|
|
m_net_wm_icon_name = XInternAtom(disp, "_NET_WM_ICON_NAME", False);
|
2002-12-01 13:42:15 +00:00
|
|
|
m_net_wm_desktop = XInternAtom(disp, "_NET_WM_DESKTOP", False);
|
2004-01-21 09:37:10 +00:00
|
|
|
|
|
|
|
// type atoms
|
2002-12-01 13:42:15 +00:00
|
|
|
m_net_wm_window_type = XInternAtom(disp, "_NET_WM_WINDOW_TYPE", False);
|
2004-01-21 09:37:10 +00:00
|
|
|
m_net_wm_window_type_dock = XInternAtom(disp, "_NET_WM_WINDOW_TYPE_DOCK", False);
|
2004-06-20 04:49:33 +00:00
|
|
|
m_net_wm_window_type_desktop = XInternAtom(disp, "_NET_WM_WINDOW_TYPE_DESKTOP", False);
|
2006-04-23 17:00:33 +00:00
|
|
|
m_net_wm_window_type_splash = XInternAtom(disp, "_NET_WM_WINDOW_TYPE_SPLASH", False);
|
2006-06-18 21:23:24 +00:00
|
|
|
m_net_wm_window_type_dialog = XInternAtom(disp, "_NET_WM_WINDOW_TYPE_DIALOG", False);
|
2006-05-13 16:20:00 +00:00
|
|
|
m_net_wm_window_type_normal = XInternAtom(disp, "_NET_WM_WINDOW_TYPE_NORMAL", False);
|
2004-01-21 09:37:10 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
// state atom and the supported state atoms
|
|
|
|
m_net_wm_state = XInternAtom(disp, "_NET_WM_STATE", False);
|
|
|
|
m_net_wm_state_sticky = XInternAtom(disp, "_NET_WM_STATE_STICKY", False);
|
|
|
|
m_net_wm_state_shaded = XInternAtom(disp, "_NET_WM_STATE_SHADED", False);
|
2003-08-27 21:06:04 +00:00
|
|
|
m_net_wm_state_maximized_horz = XInternAtom(disp, "_NET_WM_STATE_MAXIMIZED_HORZ", False);
|
|
|
|
m_net_wm_state_maximized_vert = XInternAtom(disp, "_NET_WM_STATE_MAXIMIZED_VERT", False);
|
2003-09-23 13:52:05 +00:00
|
|
|
m_net_wm_state_fullscreen = XInternAtom(disp, "_NET_WM_STATE_FULLSCREEN", False);
|
2004-01-18 19:14:08 +00:00
|
|
|
m_net_wm_state_hidden = XInternAtom(disp, "_NET_WM_STATE_HIDDEN", False);
|
|
|
|
m_net_wm_state_skip_taskbar = XInternAtom(disp, "_NET_WM_STATE_SKIP_TASKBAR", False);
|
2005-06-02 01:36:28 +00:00
|
|
|
m_net_wm_state_skip_pager = XInternAtom(disp, "_NET_WM_STATE_SKIP_PAGER", False);
|
2004-01-19 22:43:08 +00:00
|
|
|
m_net_wm_state_above = XInternAtom(disp, "_NET_WM_STATE_ABOVE", False);
|
|
|
|
m_net_wm_state_below = XInternAtom(disp, "_NET_WM_STATE_BELOW", False);
|
2006-04-23 17:00:33 +00:00
|
|
|
m_net_wm_state_modal = XInternAtom(disp, "_NET_WM_STATE_MODAL", False);
|
2006-05-13 16:20:00 +00:00
|
|
|
m_net_wm_state_demands_attention = XInternAtom(disp, "_NET_WM_STATE_DEMANDS_ATTENTION", False);
|
2004-01-19 22:43:08 +00:00
|
|
|
|
2004-12-21 16:17:14 +00:00
|
|
|
// allowed actions
|
|
|
|
m_net_wm_allowed_actions = XInternAtom(disp, "_NET_WM_ALLOWED_ACTIONS", False);
|
2006-04-23 17:00:33 +00:00
|
|
|
m_net_wm_action_move = XInternAtom(disp, "_NET_WM_ACTION_MOVE", False);
|
|
|
|
m_net_wm_action_resize = XInternAtom(disp, "_NET_WM_ACTION_RESIZE", False);
|
|
|
|
m_net_wm_action_minimize = XInternAtom(disp, "_NET_WM_ACTION_MINIMIZE", False);
|
|
|
|
m_net_wm_action_shade = XInternAtom(disp, "_NET_WM_ACTION_SHADE", False);
|
|
|
|
m_net_wm_action_stick = XInternAtom(disp, "_NET_WM_ACTION_STICK", False);
|
|
|
|
m_net_wm_action_maximize_horz = XInternAtom(disp, "_NET_WM_ACTION_MAXIMIZE_HORZ", False);
|
|
|
|
m_net_wm_action_maximize_vert = XInternAtom(disp, "_NET_WM_ACTION_MAXIMIZE_VERT", False);
|
|
|
|
m_net_wm_action_fullscreen = XInternAtom(disp, "_NET_WM_ACTION_FULLSCREEN", False);
|
|
|
|
m_net_wm_action_change_desktop = XInternAtom(disp, "_NET_WM_ACTION_CHANGE_DESKTOP", False);
|
|
|
|
m_net_wm_action_close = XInternAtom(disp, "_NET_WM_ACTION_CLOSE", False);
|
2004-01-18 19:14:08 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
m_net_wm_strut = XInternAtom(disp, "_NET_WM_STRUT", False);
|
|
|
|
m_net_wm_icon_geometry = XInternAtom(disp, "_NET_WM_ICON_GEOMETRY", False);
|
|
|
|
m_net_wm_icon = XInternAtom(disp, "_NET_WM_ICON", False);
|
|
|
|
m_net_wm_pid = XInternAtom(disp, "_NET_WM_PID", False);
|
|
|
|
m_net_wm_handled_icons = XInternAtom(disp, "_NET_WM_HANDLED_ICONS", False);
|
|
|
|
|
2006-06-18 21:23:24 +00:00
|
|
|
m_net_frame_extents = XInternAtom(disp, "_NET_FRAME_EXTENTS", False);
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
m_net_wm_ping = XInternAtom(disp, "_NET_WM_PING", False);
|
2005-05-06 15:24:53 +00:00
|
|
|
utf8_string = XInternAtom(disp, "UTF8_STRING", False);
|
2002-10-02 16:26:05 +00:00
|
|
|
}
|
|
|
|
|
2003-09-23 13:52:05 +00:00
|
|
|
|
|
|
|
void Ewmh::setFullscreen(FluxboxWindow &win, bool value) {
|
2004-09-10 15:36:04 +00:00
|
|
|
// fullscreen implies maximised, above dock layer,
|
2003-09-23 13:52:05 +00:00
|
|
|
// and no decorations (or decorations offscreen)
|
2004-12-21 16:17:14 +00:00
|
|
|
//
|
|
|
|
// TODO: do we need the WindowState etc here anymore?
|
|
|
|
// FluxboxWindow::setFullscreen() remembering old values
|
|
|
|
// already and set them...
|
|
|
|
// only reason i can see is that the user manually
|
|
|
|
// moved the (fullscreened) window
|
2003-09-23 13:52:05 +00:00
|
|
|
WindowState *saved_state = getState(win);
|
|
|
|
if (value) {
|
|
|
|
// fullscreen on
|
|
|
|
if (!saved_state) { // not already fullscreen
|
|
|
|
saved_state = new WindowState(win.x(), win.y(), win.width(),
|
|
|
|
win.height(), win.layerNum(), win.decorationMask());
|
|
|
|
saveState(win, saved_state);
|
2004-12-21 16:17:14 +00:00
|
|
|
win.setFullscreen(true);
|
2003-09-23 13:52:05 +00:00
|
|
|
}
|
|
|
|
} else { // turn off fullscreen
|
|
|
|
if (saved_state) { // no saved state, can't restore it
|
2004-12-21 16:17:14 +00:00
|
|
|
win.setFullscreen(false);
|
|
|
|
/*
|
2003-09-23 13:52:05 +00:00
|
|
|
win.setDecorationMask(saved_state->decor);
|
|
|
|
win.moveResize(saved_state->x, saved_state->y,
|
|
|
|
saved_state->width, saved_state->height);
|
|
|
|
win.moveToLayer(saved_state->layer);
|
2004-12-21 16:17:14 +00:00
|
|
|
*/
|
2003-09-23 13:52:05 +00:00
|
|
|
clearState(win);
|
|
|
|
saved_state = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-11 10:20:33 +00:00
|
|
|
// set window state
|
2003-09-23 13:52:05 +00:00
|
|
|
void Ewmh::setState(FluxboxWindow &win, Atom state, bool value) {
|
2002-12-01 13:42:15 +00:00
|
|
|
if (state == m_net_wm_state_sticky) { // STICKY
|
|
|
|
if (value && !win.isStuck() ||
|
|
|
|
(!value && win.isStuck()))
|
|
|
|
win.stick();
|
|
|
|
} else if (state == m_net_wm_state_shaded) { // SHADED
|
|
|
|
if ((value && !win.isShaded()) ||
|
|
|
|
(!value && win.isShaded()))
|
|
|
|
win.shade();
|
2003-08-27 21:06:04 +00:00
|
|
|
} else if (state == m_net_wm_state_maximized_horz ) { // maximized Horizontal
|
|
|
|
if ((value && !win.isMaximized()) ||
|
|
|
|
(!value && win.isMaximized()))
|
2004-09-10 15:36:04 +00:00
|
|
|
win.maximizeHorizontal();
|
2003-08-27 21:06:04 +00:00
|
|
|
} else if (state == m_net_wm_state_maximized_vert) { // maximized Vertical
|
|
|
|
if ((value && !win.isMaximized()) ||
|
|
|
|
(!value && win.isMaximized()))
|
2004-09-10 15:36:04 +00:00
|
|
|
win.maximizeVertical();
|
2003-09-23 13:52:05 +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()))
|
2003-09-23 13:52:05 +00:00
|
|
|
setFullscreen(win, value);
|
2006-03-09 18:33:36 +00:00
|
|
|
} else if (state == m_net_wm_state_hidden) { // minimized
|
|
|
|
if (value && !win.isIconic())
|
|
|
|
win.iconify();
|
|
|
|
else if (!value && win.isIconic())
|
|
|
|
win.deiconify();
|
2006-04-23 17:00:33 +00:00
|
|
|
} else if (state == m_net_wm_state_skip_taskbar) { // skip taskbar
|
2004-12-21 16:17:14 +00:00
|
|
|
win.setIconHidden(value);
|
2004-07-21 18:56:34 +00:00
|
|
|
} else if (state == m_net_wm_state_below) { // bottom layer
|
2004-01-19 22:43:08 +00:00
|
|
|
if (value)
|
2006-02-20 21:04:35 +00:00
|
|
|
win.moveToLayer(Layer::BOTTOM);
|
2004-01-19 22:43:08 +00:00
|
|
|
else
|
2006-02-20 21:04:35 +00:00
|
|
|
win.moveToLayer(Layer::NORMAL);
|
2004-01-19 22:43:08 +00:00
|
|
|
|
2004-07-21 18:56:34 +00:00
|
|
|
} else if (state == m_net_wm_state_above) { // above layer
|
2004-01-19 22:43:08 +00:00
|
|
|
if (value)
|
2006-02-20 21:04:35 +00:00
|
|
|
win.moveToLayer(Layer::ABOVE_DOCK);
|
2004-01-19 22:43:08 +00:00
|
|
|
else
|
2006-02-20 21:04:35 +00:00
|
|
|
win.moveToLayer(Layer::NORMAL);
|
2006-05-13 16:20:00 +00:00
|
|
|
} else if (state == m_net_wm_state_demands_attention) {
|
2006-06-11 12:47:47 +00:00
|
|
|
if (value) { // if add attention
|
|
|
|
Fluxbox::instance()->attentionHandler().addAttention(win);
|
|
|
|
} else { // erase it
|
|
|
|
Fluxbox::instance()->attentionHandler().
|
|
|
|
update(&win.attentionSig());
|
|
|
|
}
|
2004-01-19 22:43:08 +00:00
|
|
|
}
|
2006-05-13 16:20:00 +00:00
|
|
|
|
2006-04-23 17:00:33 +00:00
|
|
|
// Note: state == net_wm_state_modal, We should not change it
|
2002-10-11 10:20:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// toggle window state
|
2003-09-23 13:52:05 +00:00
|
|
|
void Ewmh::toggleState(FluxboxWindow &win, Atom state) {
|
2006-04-23 17:00:33 +00:00
|
|
|
if (state == m_net_wm_state_sticky) { // sticky
|
2002-12-01 13:42:15 +00:00
|
|
|
win.stick();
|
2006-04-23 17:00:33 +00:00
|
|
|
} else if (state == m_net_wm_state_shaded){ // shaded
|
2002-12-01 13:42:15 +00:00
|
|
|
win.shade();
|
2003-08-27 21:06:04 +00:00
|
|
|
} else if (state == m_net_wm_state_maximized_horz ) { // maximized Horizontal
|
|
|
|
win.maximizeHorizontal();
|
|
|
|
} else if (state == m_net_wm_state_maximized_vert) { // maximized Vertical
|
|
|
|
win.maximizeVertical();
|
2003-09-23 13:52:05 +00:00
|
|
|
} else if (state == m_net_wm_state_fullscreen) { // fullscreen
|
|
|
|
setFullscreen(win, getState(win) == 0); // toggle current state
|
2006-03-09 18:33:36 +00:00
|
|
|
} else if (state == m_net_wm_state_hidden) { // minimized
|
|
|
|
if(win.isIconic())
|
|
|
|
win.deiconify();
|
|
|
|
else
|
|
|
|
win.iconify();
|
2006-04-23 17:00:33 +00:00
|
|
|
} else if (state == m_net_wm_state_skip_taskbar) { // taskbar
|
2004-02-20 09:07:27 +00:00
|
|
|
win.setIconHidden(!win.isIconHidden());
|
2004-07-21 18:56:34 +00:00
|
|
|
} else if (state == m_net_wm_state_below) { // bottom layer
|
2006-02-20 21:04:35 +00:00
|
|
|
if (win.layerNum() == Layer::BOTTOM)
|
|
|
|
win.moveToLayer(Layer::NORMAL);
|
2004-01-19 22:43:08 +00:00
|
|
|
else
|
2006-02-20 21:04:35 +00:00
|
|
|
win.moveToLayer(Layer::BOTTOM);
|
2004-01-21 15:42:14 +00:00
|
|
|
|
2004-07-21 18:56:34 +00:00
|
|
|
} else if (state == m_net_wm_state_above) { // top layer
|
2006-02-20 21:04:35 +00:00
|
|
|
if (win.layerNum() == Layer::ABOVE_DOCK)
|
|
|
|
win.moveToLayer(Layer::NORMAL);
|
2004-01-19 22:43:08 +00:00
|
|
|
else
|
2006-02-20 21:04:35 +00:00
|
|
|
win.moveToLayer(Layer::ABOVE_DOCK);
|
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;
|
|
|
|
long *data = 0;
|
2003-07-28 15:06:36 +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,
|
|
|
|
(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);
|
|
|
|
winclient.setStrut(winclient.screen().requestStrut(head,
|
|
|
|
data[0], data[1],
|
|
|
|
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[]
|
|
|
|
*
|
|
|
|
* A list of atoms indicating user operations that the
|
|
|
|
* Window Manager supports for this window. Atoms present in the
|
|
|
|
* 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
|
|
|
|
* actions which are currently "active" or "sensitive" for a window.
|
|
|
|
* Taskbars, Pagers, and other tools use _NET_WM_ALLOWED_ACTIONS to
|
|
|
|
* decide which actions should be made available to the user.
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef std::vector<Atom> ActionsVector;
|
|
|
|
ActionsVector actions;
|
|
|
|
actions.reserve(10);
|
|
|
|
// all windows can change desktop,
|
|
|
|
// be shaded or be sticky
|
|
|
|
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);
|
|
|
|
|
|
|
|
if (win.isResizable())
|
|
|
|
actions.push_back(m_net_wm_action_resize);
|
|
|
|
if (win.isMoveable())
|
|
|
|
actions.push_back(m_net_wm_action_move);
|
|
|
|
if (win.isClosable())
|
|
|
|
actions.push_back(m_net_wm_action_close);
|
|
|
|
if (win.isIconifiable())
|
|
|
|
actions.push_back(m_net_wm_action_minimize);
|
|
|
|
|
|
|
|
unsigned int max_width, max_height;
|
|
|
|
WinClientUtil::maxSize(win.clientList(), max_width, max_height);
|
|
|
|
|
|
|
|
// if unlimited max width we can maximize horizontal
|
|
|
|
if (max_width == 0) {
|
|
|
|
actions.push_back(m_net_wm_action_maximize_horz);
|
|
|
|
}
|
|
|
|
// if unlimited max height we can maxmize vert
|
|
|
|
if (max_height == 0) {
|
|
|
|
actions.push_back(m_net_wm_action_maximize_vert);
|
|
|
|
}
|
|
|
|
|
|
|
|
// if we have unlimited size in all directions we can have this window
|
|
|
|
// in fullscreen mode
|
|
|
|
if (max_height == 0 && max_width == 0) {
|
|
|
|
actions.push_back(m_net_wm_action_fullscreen);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FluxboxWindow::ClientList::iterator it = win.clientList().begin();
|
|
|
|
FluxboxWindow::ClientList::iterator it_end = win.clientList().end();
|
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
(*it)->changeProperty(m_net_wm_allowed_actions, XA_ATOM, 32, PropModeReplace,
|
|
|
|
reinterpret_cast<unsigned char*>(&actions.front()),
|
|
|
|
actions.size());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
2004-09-10 15:36:04 +00:00
|
|
|
win.winClient().property(m_net_wm_state, 0, 0x7fffffff, False, XA_ATOM,
|
|
|
|
&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) {
|
|
|
|
int extents[4];
|
|
|
|
extents[0] = win.frame().x();
|
|
|
|
extents[1] = win.frame().x() + win.frame().width();
|
|
|
|
extents[2] = win.frame().y();
|
|
|
|
extents[3] = win.frame().y() + win.frame().height();
|
|
|
|
|
|
|
|
FluxboxWindow::ClientList::iterator it = win.clientList().begin();
|
|
|
|
FluxboxWindow::ClientList::iterator it_end = win.clientList().end();
|
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
(*it)->changeProperty(m_net_frame_extents,
|
|
|
|
XA_CARDINAL, 32, PropModeReplace,
|
|
|
|
(unsigned char *)extents, 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-09-10 15:36:04 +00:00
|
|
|
Ewmh::WindowState::WindowState(int t_x, int t_y,
|
|
|
|
unsigned int t_width,
|
2003-09-23 13:52:05 +00:00
|
|
|
unsigned int t_height,
|
|
|
|
int t_layer, unsigned int t_decor) :
|
|
|
|
x(t_x), y(t_y),
|
|
|
|
layer(t_layer),
|
|
|
|
width(t_width),
|
|
|
|
height(t_height),
|
|
|
|
decor(t_decor)
|
|
|
|
{}
|
|
|
|
|
|
|
|
Ewmh::WindowState *Ewmh::getState(FluxboxWindow &win) {
|
|
|
|
SavedState::iterator it = m_savedstate.find(&win);
|
|
|
|
if (it == m_savedstate.end())
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return it->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Ewmh::clearState(FluxboxWindow &win) {
|
|
|
|
WindowState *state = 0;
|
|
|
|
SavedState::iterator it = m_savedstate.find(&win);
|
|
|
|
if (it == m_savedstate.end())
|
|
|
|
return;
|
|
|
|
|
|
|
|
state = it->second;
|
|
|
|
|
|
|
|
m_savedstate.erase(it);
|
|
|
|
delete state;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Ewmh::saveState(FluxboxWindow &win, WindowState *state) {
|
|
|
|
m_savedstate[&win] = state;
|
|
|
|
}
|
2006-05-07 10:08:25 +00:00
|
|
|
|
2006-06-18 21:23:24 +00:00
|
|
|
|