2002-10-02 16:26:05 +00:00
|
|
|
// Ewmh.cc for fluxbox
|
2003-03-04 11:06:03 +00:00
|
|
|
// Copyright (c) 2002-2003 Henrik Kinnunen (fluxgen at user.sourceforge.net)
|
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.
|
|
|
|
|
2003-07-28 15:06:36 +00:00
|
|
|
// $Id: Ewmh.cc,v 1.30 2003/07/28 15:06:33 rathnor Exp $
|
2002-10-02 16:26:05 +00:00
|
|
|
|
|
|
|
#include "Ewmh.hh"
|
|
|
|
|
|
|
|
#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"
|
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>
|
2002-10-02 16:26:05 +00:00
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
Ewmh::Ewmh() {
|
2002-12-01 13:42:15 +00:00
|
|
|
createAtoms();
|
2003-04-09 17:20:06 +00:00
|
|
|
enableUpdate();
|
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
|
|
|
|
2002-10-02 16:26:05 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
Window wincheck = XCreateSimpleWindow(disp,
|
2003-05-10 22:59:32 +00:00
|
|
|
screen.rootWindow().window(),
|
2003-04-15 12:22:06 +00:00
|
|
|
0, 0, 5, 5, 0, 0, 0);
|
2002-10-16 23:32:17 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (wincheck != None) {
|
|
|
|
m_windows.push_back(wincheck);
|
2002-10-02 16:26:05 +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,
|
2002-10-16 23:32:17 +00:00
|
|
|
PropModeReplace, (unsigned char *) &wincheck, 1);
|
2002-10-02 16:26:05 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
XChangeProperty(disp, wincheck, m_net_wm_name, XA_STRING, 8,
|
2002-10-02 16:26:05 +00:00
|
|
|
PropModeReplace, (unsigned char *) "Fluxbox", strlen("Fluxbox"));
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
2002-10-02 16:26:05 +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,
|
|
|
|
// states that we support:
|
|
|
|
m_net_wm_state_sticky,
|
|
|
|
m_net_wm_state_shaded,
|
2002-10-02 16:26:05 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
m_net_wm_desktop,
|
2002-10-16 19:03:57 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
// root properties
|
|
|
|
m_net_client_list,
|
|
|
|
m_net_number_of_desktops,
|
|
|
|
m_net_current_desktop,
|
|
|
|
m_net_active_window,
|
|
|
|
m_net_close_window,
|
|
|
|
m_net_moveresize_window,
|
|
|
|
m_net_desktop_names,
|
|
|
|
m_net_supporting_wm_check
|
|
|
|
};
|
|
|
|
|
2003-05-19 22:43:48 +00:00
|
|
|
screen.rootWindow().changeProperty(m_net_supported, XA_ATOM, 32,
|
|
|
|
PropModeReplace,
|
|
|
|
(unsigned char *) &atomsupported,
|
|
|
|
(sizeof atomsupported)/sizeof atomsupported[0]);
|
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);
|
|
|
|
}
|
|
|
|
|
2003-07-04 01:03:41 +00:00
|
|
|
void Ewmh::setupFrame(FluxboxWindow &win) {
|
2002-10-16 19:03:57 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
Atom ret_type;
|
|
|
|
int fmt;
|
|
|
|
unsigned long nitems, bytes_after;
|
|
|
|
long *data = 0;
|
2002-10-16 19:03:57 +00:00
|
|
|
/*
|
2003-05-15 11:17:29 +00:00
|
|
|
if (XGetWindowProperty(disp, win.clientWindow(),
|
2002-12-01 13:42:15 +00:00
|
|
|
m_net_wm_state, 0, 1, False, XA_CARDINAL,
|
|
|
|
&ret_type, &fmt, &nitems, &bytes_after,
|
|
|
|
(unsigned char **) &data) == Success && data) {
|
|
|
|
flags = *data;
|
|
|
|
setState(win, flags);
|
|
|
|
XFree(data);
|
2002-10-02 16:26:05 +00:00
|
|
|
}
|
|
|
|
*/
|
2003-05-19 22:43:48 +00:00
|
|
|
if (win.winClient().property(m_net_wm_desktop, 0, 1, False, XA_CARDINAL,
|
|
|
|
&ret_type, &fmt, &nitems, &bytes_after,
|
|
|
|
(unsigned char **) &data) && data) {
|
2002-12-01 13:42:15 +00:00
|
|
|
unsigned int desktop = static_cast<unsigned int>(*data);
|
|
|
|
if (desktop == 0xFFFFFFFF && !win.isStuck())
|
|
|
|
win.stick();
|
2003-04-14 12:13:36 +00:00
|
|
|
else
|
2003-05-11 13:36:12 +00:00
|
|
|
win.screen().sendToWorkspace(desktop, &win, false);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
XFree(data);
|
|
|
|
}
|
2003-06-18 13:34:30 +00:00
|
|
|
|
2002-10-02 16:26:05 +00:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
2003-04-15 00:17:59 +00:00
|
|
|
BScreen::Workspaces::const_iterator workspace_it =
|
|
|
|
screen.getWorkspacesList().begin();
|
|
|
|
BScreen::Workspaces::const_iterator workspace_it_end =
|
|
|
|
screen.getWorkspacesList().end();
|
2002-12-01 13:42:15 +00:00
|
|
|
for (; workspace_it != workspace_it_end; ++workspace_it) {
|
2003-04-15 00:17:59 +00:00
|
|
|
Workspace::Windows::iterator win_it =
|
2003-05-11 17:06:02 +00:00
|
|
|
(*workspace_it)->windowList().begin();
|
2003-04-15 00:17:59 +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
|
|
|
|
BScreen::Icons::const_iterator icon_it = screen.getIconList().begin();
|
|
|
|
BScreen::Icons::const_iterator icon_it_end = screen.getIconList().end();
|
|
|
|
for (; icon_it != icon_it_end; ++icon_it) {
|
|
|
|
num += (*icon_it)->numClients();
|
|
|
|
}
|
2002-10-02 16:26:05 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
Window *wl = new (nothrow) Window[num];
|
|
|
|
if (wl == 0) {
|
|
|
|
cerr<<"Fatal: Out of memory, can't allocate for Ewmh client list"<<endl;
|
|
|
|
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) {
|
2002-10-02 16:26:05 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
// Fill in array of window ID's
|
2003-04-15 00:17:59 +00:00
|
|
|
Workspace::Windows::const_iterator it =
|
2003-05-11 17:06:02 +00:00
|
|
|
(*workspace_it)->windowList().begin();
|
2003-04-15 00:17:59 +00:00
|
|
|
Workspace::Windows::const_iterator it_end =
|
2003-05-11 17:06:02 +00:00
|
|
|
(*workspace_it)->windowList().end();
|
2002-12-01 13:42:15 +00:00
|
|
|
for (; it != it_end; ++it) {
|
2003-04-14 12:13:36 +00:00
|
|
|
if ((*it)->numClients() == 1)
|
2003-05-15 11:17:29 +00:00
|
|
|
wl[win++] = (*it)->clientWindow();
|
2003-04-14 12:13:36 +00:00
|
|
|
else {
|
|
|
|
// add every client in fluxboxwindow to list window list
|
2003-04-15 00:17:59 +00:00
|
|
|
std::list<WinClient *>::iterator client_it =
|
|
|
|
(*it)->clientList().begin();
|
|
|
|
std::list<WinClient *>::iterator client_it_end =
|
|
|
|
(*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
|
2003-04-15 12:22:06 +00:00
|
|
|
icon_it = screen.getIconList().begin();
|
|
|
|
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;
|
2003-05-19 22:43:48 +00:00
|
|
|
screen.rootWindow().changeProperty(m_net_client_list,
|
|
|
|
XA_CARDINAL, 32,
|
|
|
|
PropModeReplace, (unsigned char *)wl, num);
|
2002-10-02 16:26:05 +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) {
|
2002-12-01 13:42:15 +00:00
|
|
|
XTextProperty text;
|
|
|
|
const size_t number_of_desks = screen.getWorkspaceNames().size();
|
2002-10-02 16:26:05 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
char *names[number_of_desks];
|
2002-10-02 16:26:05 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
for (size_t i = 0; i < number_of_desks; i++) {
|
|
|
|
names[i] = new char[screen.getWorkspaceNames()[i].size()];
|
|
|
|
strcpy(names[i], screen.getWorkspaceNames()[i].c_str());
|
|
|
|
}
|
2002-10-02 16:26:05 +00:00
|
|
|
|
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);
|
|
|
|
}
|
2002-10-02 16:26:05 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
for (size_t i = 0; i < number_of_desks; i++)
|
|
|
|
delete [] names[i];
|
2002-10-02 16:26:05 +00:00
|
|
|
}
|
|
|
|
|
2003-03-03 21:51:13 +00:00
|
|
|
void Ewmh::updateCurrentWorkspace(BScreen &screen) {
|
2003-05-15 12:00:46 +00:00
|
|
|
size_t workspace = screen.currentWorkspaceID();
|
2003-05-19 22:43:48 +00:00
|
|
|
screen.rootWindow().changeProperty(m_net_current_desktop, XA_CARDINAL, 32, PropModeReplace,
|
|
|
|
(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) {
|
2002-12-01 13:42:15 +00:00
|
|
|
size_t numworkspaces = screen.getCount();
|
2003-05-19 22:43:48 +00:00
|
|
|
screen.rootWindow().changeProperty(m_net_number_of_desktops, XA_CARDINAL, 32, PropModeReplace,
|
|
|
|
(unsigned char *)&numworkspaces, 1);
|
2002-10-02 16:26:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Ewmh::updateState(FluxboxWindow &win) {
|
2003-04-14 12:13:36 +00:00
|
|
|
//!! TODO
|
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
|
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) {
|
2003-05-15 11:17:29 +00:00
|
|
|
int workspace = win.workspaceNumber();
|
2002-12-01 13:42:15 +00:00
|
|
|
if (win.isStuck())
|
|
|
|
workspace = 0xFFFFFFFF; // 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
|
|
|
}
|
|
|
|
|
2002-10-16 19:03:57 +00:00
|
|
|
// return true if we did handle the atom here
|
2003-07-28 15:06:36 +00:00
|
|
|
bool Ewmh::checkClientMessage(const XClientMessageEvent &ce, BScreen * screen, WinClient * const winclient) {
|
2002-10-16 19:03:57 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (ce.message_type == m_net_wm_desktop) {
|
|
|
|
if (screen == 0)
|
|
|
|
return true;
|
|
|
|
// ce.data.l[0] = workspace number
|
|
|
|
// valid window and workspace number?
|
2003-07-28 15:06:36 +00:00
|
|
|
if (winclient == 0 || winclient->fbwindow() == 0 ||
|
2003-03-04 11:06:03 +00:00
|
|
|
static_cast<unsigned int>(ce.data.l[0]) >= screen->getCount())
|
2002-12-01 13:42:15 +00:00
|
|
|
return true;
|
2002-10-16 19:03:57 +00:00
|
|
|
|
2003-07-28 15:06:36 +00:00
|
|
|
screen->sendToWorkspace(ce.data.l[0], winclient->fbwindow(), false);
|
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
|
|
|
}
|
2003-06-18 13:34:30 +00:00
|
|
|
|
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
|
2002-10-16 19:03:57 +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
|
|
|
|
if (screen->getCount() == static_cast<unsigned int>(ce.data.l[0]) ||
|
|
|
|
ce.data.l[0] < 0)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (screen->getCount() > static_cast<unsigned int>(ce.data.l[0])) {
|
|
|
|
// remove last workspace until we have
|
|
|
|
// the same number of workspaces
|
|
|
|
while (screen->getCount() != static_cast<unsigned int>(ce.data.l[0])) {
|
|
|
|
screen->removeLastWorkspace();
|
|
|
|
if (screen->getCount() == 1) // must have at least one workspace
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else { // add workspaces to screen until workspace count match the requested size
|
|
|
|
while (screen->getCount() != static_cast<unsigned int>(ce.data.l[0])) {
|
|
|
|
screen->addWorkspace();
|
|
|
|
}
|
|
|
|
}
|
2002-10-16 19:03:57 +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
|
2002-10-16 19:03:57 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
// prevent out of range value
|
|
|
|
if (static_cast<unsigned int>(ce.data.l[0]) >= screen->getCount())
|
|
|
|
return true;
|
|
|
|
screen->changeWorkspaceID(ce.data.l[0]);
|
|
|
|
return true;
|
|
|
|
} else if (ce.message_type == m_net_active_window) {
|
2002-10-16 19:03:57 +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
|
2002-10-16 19:03:57 +00:00
|
|
|
|
2003-07-28 15:06:36 +00:00
|
|
|
winclient->focus();
|
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) {
|
2003-07-28 15:06:36 +00:00
|
|
|
if (winclient == 0 && winclient->fbwindow())
|
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
|
|
|
|
// TODO: gravity and flags
|
2003-07-28 15:06:36 +00:00
|
|
|
winclient->fbwindow()->moveResize(ce.data.l[1], ce.data.l[2],
|
2002-12-01 13:42:15 +00:00
|
|
|
ce.data.l[3], ce.data.l[4]);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2002-10-02 16:26:05 +00:00
|
|
|
void Ewmh::createAtoms() {
|
2003-03-04 11:06:03 +00:00
|
|
|
Display *disp = FbTk::App::instance()->display();
|
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);
|
2002-11-23 14:54:50 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
// TODO: implement this one
|
|
|
|
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);
|
|
|
|
m_net_wm_desktop = XInternAtom(disp, "_NET_WM_DESKTOP", False);
|
|
|
|
m_net_wm_window_type = XInternAtom(disp, "_NET_WM_WINDOW_TYPE", False);
|
2002-10-11 10:20:33 +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);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
m_net_wm_ping = XInternAtom(disp, "_NET_WM_PING", False);
|
2002-10-02 16:26:05 +00:00
|
|
|
}
|
|
|
|
|
2002-10-11 10:20:33 +00:00
|
|
|
// set window state
|
|
|
|
void Ewmh::setState(FluxboxWindow &win, Atom state, bool value) const {
|
|
|
|
|
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();
|
|
|
|
}
|
2002-10-11 10:20:33 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// toggle window state
|
|
|
|
void Ewmh::toggleState(FluxboxWindow &win, Atom state) const {
|
2002-12-01 13:42:15 +00:00
|
|
|
if (state == m_net_wm_state_sticky) {
|
|
|
|
win.stick();
|
|
|
|
} else if (state == m_net_wm_state_shaded)
|
|
|
|
win.shade();
|
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) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
cerr<<__FILE__<<"("<<__FUNCTION__<<"): Strut: "<<data[0]<<", "<<data[1]<<", "<<
|
|
|
|
data[2]<<", "<<data[3]<<endl;
|
|
|
|
#endif // DEBUG
|
2003-07-28 15:06:36 +00:00
|
|
|
winclient.setStrut(
|
|
|
|
winclient.screen().requestStrut(data[0], data[1], data[2], data[3]));
|
|
|
|
winclient.screen().updateAvailableWorkspaceArea();
|
2003-06-18 13:34:30 +00:00
|
|
|
}
|
|
|
|
}
|