// Ewmh.cc for fluxbox // Copyright (c) 2002-2004 Henrik Kinnunen (fluxgen at user.sourceforge.net) // // 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, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL // 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. // $Id$ #include "Ewmh.hh" #include "Screen.hh" #include "Window.hh" #include "WinClient.hh" #include "Workspace.hh" #include "fluxbox.hh" #include "FbTk/FbWindow.hh" #include "FbTk/I18n.hh" #include #include #include using namespace std; // mipspro has no new(nothrow) #if defined sgi && ! defined GCC #define FB_new_nothrow new #else #define FB_new_nothrow new(std::nothrow) #endif Ewmh::Ewmh() { createAtoms(); } Ewmh::~Ewmh() { while (!m_windows.empty()) { XDestroyWindow(FbTk::App::instance()->display(), m_windows.back()); m_windows.pop_back(); } } void Ewmh::initForScreen(BScreen &screen) { Display *disp = FbTk::App::instance()->display(); /* 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. */ Window wincheck = XCreateSimpleWindow(disp, screen.rootWindow().window(), -10, -10, 5, 5, 0, 0, 0); if (wincheck != None) { // store the window so we can delete it later m_windows.push_back(wincheck); screen.rootWindow().changeProperty(m_net_supporting_wm_check, XA_WINDOW, 32, PropModeReplace, (unsigned char *) &wincheck, 1); XChangeProperty(disp, wincheck, m_net_supporting_wm_check, XA_WINDOW, 32, PropModeReplace, (unsigned char *) &wincheck, 1); XChangeProperty(disp, wincheck, m_net_wm_name, XA_STRING, 8, PropModeReplace, (unsigned char *) "Fluxbox", strlen("Fluxbox")); } //set supported atoms Atom atomsupported[] = { // window properties m_net_wm_strut, m_net_wm_state, // states that we support: 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, // window type m_net_wm_window_type, m_net_wm_window_type_dock, m_net_wm_window_type_desktop, // root properties 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, // desktop properties m_net_wm_desktop, m_net_desktop_names, m_net_desktop_viewport, m_net_desktop_geometry, m_net_supporting_wm_check }; /* From Extended Window Manager Hints, draft 1.3: * * _NET_SUPPORTED, ATOM[]/32 * * This property MUST be set by the Window Manager * to indicate which hints it supports. For * example: considering _NET_WM_STATE both this * atom and all supported states * e.g. _NET_WM_STATE_MODAL, _NET_WM_STATE_STICKY, * would be listed. This assumes that backwards * incompatible changes will not be made to the * hints (without being renamed). */ screen.rootWindow().changeProperty(m_net_supported, XA_ATOM, 32, PropModeReplace, (unsigned char *) &atomsupported, (sizeof atomsupported)/sizeof atomsupported[0]); // update atoms updateWorkspaceCount(screen); updateCurrentWorkspace(screen); updateWorkspaceNames(screen); updateClientList(screen); updateViewPort(screen); updateGeometry(screen); updateWorkarea(screen); } void Ewmh::setupClient(WinClient &winclient) { updateStrut(winclient); } void Ewmh::setupFrame(FluxboxWindow &win) { Atom ret_type; int fmt; unsigned long nitems, bytes_after; unsigned char *data = 0; /* 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 * be used by the window manager in determining the decoration, * stacking position and other behavior of the window. The Client * SHOULD specify window types in order of preference (the first being * 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. * */ win.winClient().property(m_net_wm_window_type, 0, 0x7fffffff, False, XA_ATOM, &ret_type, &fmt, &nitems, &bytes_after, &data); if (data) { Atom *atoms = (unsigned long *)data; for (unsigned long l=0; l