~ubuntu-branches/ubuntu/trusty/fluxbox/trusty-proposed

« back to all changes in this revision

Viewing changes to src/Ewmh.cc

  • Committer: Bazaar Package Importer
  • Author(s): Dmitry E. Oboukhov
  • Date: 2008-07-01 10:38:14 UTC
  • mfrom: (2.1.12 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080701103814-khx2b6il152x9p93
Tags: 1.0.0+deb1-8
* x-dev has been removed from build-depends (out-of-date package).
* Standards-Version bumped to 3.8.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Ewmh.cc for fluxbox
2
 
// Copyright (c) 2002 - 2005 Henrik Kinnunen (fluxgen at fluxbox dot org)
3
 
//
4
 
// Permission is hereby granted, free of charge, to any person obtaining a
5
 
// copy of this software and associated documentation files (the "Software"),
6
 
// to deal in the Software without restriction, including without limitation
7
 
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
 
// and/or sell copies of the Software, and to permit persons to whom the
9
 
// Software is furnished to do so, subject to the following conditions:
10
 
//
11
 
// The above copyright notice and this permission notice shall be included in
12
 
// all copies or substantial portions of the Software.
13
 
//
14
 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
 
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
 
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17
 
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
 
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19
 
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20
 
// DEALINGS IN THE SOFTWARE.
21
 
 
22
 
// $Id: Ewmh.cc 4074 2005-07-04 18:19:53Z fluxgen $
23
 
 
24
 
#include "Ewmh.hh"
25
 
 
26
 
#include "Screen.hh"
27
 
#include "Window.hh"
28
 
#include "WinClient.hh"
29
 
#include "Workspace.hh"
30
 
#include "fluxbox.hh"
31
 
 
32
 
#include "FbTk/FbWindow.hh"
33
 
#include "FbTk/I18n.hh"
34
 
 
35
 
#include <iostream>
36
 
#include <algorithm>
37
 
#include <new>
38
 
 
39
 
using namespace std;
40
 
 
41
 
// mipspro has no new(nothrow)
42
 
#if defined sgi && ! defined GCC
43
 
#define FB_new_nothrow new
44
 
#else
45
 
#define FB_new_nothrow new(std::nothrow)
46
 
#endif
47
 
 
48
 
 
49
 
Ewmh::Ewmh() {
50
 
    createAtoms();
51
 
}
52
 
 
53
 
Ewmh::~Ewmh() {
54
 
    while (!m_windows.empty()) {
55
 
        XDestroyWindow(FbTk::App::instance()->display(), m_windows.back());
56
 
        m_windows.pop_back();
57
 
    }
58
 
}
59
 
 
60
 
void Ewmh::initForScreen(BScreen &screen) {
61
 
    Display *disp = FbTk::App::instance()->display();
62
 
 
63
 
    /* From Extended Window Manager Hints, draft 1.3:
64
 
     *
65
 
     * _NET_SUPPORTING_WM_CHECK
66
 
     * 
67
 
     * The Window Manager MUST set this property on the root window 
68
 
     * to be the ID of a child window created by himself, to indicate 
69
 
     * that a compliant window manager is active. The child window 
70
 
     * MUST also have the _NET_SUPPORTING_WM_CHECK property set to 
71
 
     * the ID of the child window. The child window MUST also have 
72
 
     * the _NET_WM_NAME property set to the name of the Window Manager.
73
 
     * 
74
 
     * Rationale: The child window is used to distinguish an active 
75
 
     * Window Manager from a stale _NET_SUPPORTING_WM_CHECK property 
76
 
     * that happens to point to another window. If the 
77
 
     * _NET_SUPPORTING_WM_CHECK window on the client window is missing 
78
 
     * or not properly set, clients SHOULD assume that no conforming 
79
 
     * Window Manager is present.
80
 
     */
81
 
 
82
 
    Window wincheck = XCreateSimpleWindow(disp,
83
 
                                          screen.rootWindow().window(),
84
 
                                          -10, -10, 5, 5, 0, 0, 0);
85
 
 
86
 
    if (wincheck != None) {
87
 
        // store the window so we can delete it later
88
 
        m_windows.push_back(wincheck);
89
 
 
90
 
        screen.rootWindow().changeProperty(m_net_supporting_wm_check, XA_WINDOW, 32,
91
 
                                           PropModeReplace, (unsigned char *) &wincheck, 1);
92
 
        XChangeProperty(disp, wincheck, m_net_supporting_wm_check, XA_WINDOW, 32,
93
 
                        PropModeReplace, (unsigned char *) &wincheck, 1);
94
 
 
95
 
        XChangeProperty(disp, wincheck, m_net_wm_name, utf8_string, 8,
96
 
                        PropModeReplace, (unsigned char *) "Fluxbox", strlen("Fluxbox"));
97
 
    }
98
 
 
99
 
    //set supported atoms
100
 
    Atom atomsupported[] = {
101
 
        // window properties
102
 
        m_net_wm_strut,
103
 
        m_net_wm_state,
104
 
        // states that we support:
105
 
        m_net_wm_state_sticky,
106
 
        m_net_wm_state_shaded,
107
 
        m_net_wm_state_maximized_horz,
108
 
        m_net_wm_state_maximized_vert,
109
 
        m_net_wm_state_fullscreen,
110
 
        m_net_wm_state_hidden,
111
 
        m_net_wm_state_skip_taskbar,
112
 
 
113
 
        // window type
114
 
        m_net_wm_window_type,
115
 
        m_net_wm_window_type_dock,
116
 
        m_net_wm_window_type_desktop,
117
 
 
118
 
        // root properties
119
 
        m_net_client_list,
120
 
        m_net_client_list_stacking,
121
 
        m_net_number_of_desktops,
122
 
        m_net_current_desktop,
123
 
        m_net_active_window,
124
 
        m_net_close_window,
125
 
        m_net_moveresize_window,
126
 
        m_net_workarea,
127
 
 
128
 
        // desktop properties
129
 
        m_net_wm_desktop,
130
 
        m_net_desktop_names,
131
 
        m_net_desktop_viewport,
132
 
        m_net_desktop_geometry,
133
 
 
134
 
        m_net_supporting_wm_check
135
 
    };
136
 
    /* From Extended Window Manager Hints, draft 1.3:
137
 
     *
138
 
     * _NET_SUPPORTED, ATOM[]/32
139
 
     *
140
 
     * This property MUST be set by the Window Manager
141
 
     * to indicate which hints it supports. For
142
 
     * example: considering _NET_WM_STATE both this
143
 
     * atom and all supported states
144
 
     * e.g. _NET_WM_STATE_MODAL, _NET_WM_STATE_STICKY,
145
 
     * would be listed. This assumes that backwards
146
 
     * incompatible changes will not be made to the
147
 
     * hints (without being renamed).
148
 
     */
149
 
    screen.rootWindow().changeProperty(m_net_supported, XA_ATOM, 32,
150
 
                                       PropModeReplace,
151
 
                                       (unsigned char *) &atomsupported,
152
 
                                       (sizeof atomsupported)/sizeof atomsupported[0]);
153
 
 
154
 
    // update atoms
155
 
 
156
 
    updateWorkspaceCount(screen);
157
 
    updateCurrentWorkspace(screen);
158
 
    updateWorkspaceNames(screen);
159
 
    updateClientList(screen);
160
 
    updateViewPort(screen);
161
 
    updateGeometry(screen);
162
 
    updateWorkarea(screen);
163
 
 
164
 
}
165
 
 
166
 
void Ewmh::setupClient(WinClient &winclient) {
167
 
    updateStrut(winclient);
168
 
}
169
 
 
170
 
void Ewmh::setupFrame(FluxboxWindow &win) {
171
 
    Atom ret_type;
172
 
    int fmt;
173
 
    unsigned long nitems, bytes_after;
174
 
    unsigned char *data = 0;
175
 
 
176
 
    /* From Extended Window Manager Hints, draft 1.3:
177
 
     *
178
 
     * _NET_WM_WINDOW_TYPE, ATOM[]/32
179
 
     *
180
 
     * This SHOULD be set by the Client before mapping to a list of atoms
181
 
     * indicating the functional type of the window. This property SHOULD
182
 
     * be used by the window manager in determining the decoration,
183
 
     * stacking position and other behavior of the window. The Client
184
 
     * SHOULD specify window types in order of preference (the first being
185
 
     * most preferable) but MUST include at least one of the basic window
186
 
     * type atoms from the list below. This is to allow for extension of
187
 
     * the list of types whilst providing default behavior for Window
188
 
     * Managers that do not recognize the extensions.
189
 
     *
190
 
     */
191
 
 
192
 
    win.winClient().property(m_net_wm_window_type, 0, 0x7fffffff, False, XA_ATOM,
193
 
                             &ret_type, &fmt, &nitems, &bytes_after,
194
 
                             &data);
195
 
    if (data) {
196
 
        Atom *atoms = (unsigned long *)data;
197
 
        for (unsigned long l=0; l<nitems; ++l) {
198
 
            /* From Extended Window Manager Hints, draft 1.3:
199
 
             *
200
 
             * _NET_WM_WINDOW_TYPE_DOCK indicates a dock or panel feature.
201
 
             * Typically a Window Manager would keep such windows on top
202
 
             * of all other windows.
203
 
             *
204
 
             */
205
 
            if (atoms[l] == m_net_wm_window_type_dock) {
206
 
                // we also assume it shouldn't be visible in any toolbar
207
 
                win.setFocusHidden(true);
208
 
                win.setIconHidden(true);
209
 
                break;
210
 
            } else if (atoms[l] == m_net_wm_window_type_desktop) {
211
 
                /*
212
 
                 * _NET_WM_WINDOW_TYPE_DESKTOP indicates a "false desktop" window
213
 
                 * We let it be the size it wants, but it gets no decoration,
214
 
                 * is hidden in the toolbar and window cycling list, plus
215
 
                 * windows don't tab with it and is right on the bottom.
216
 
                 */
217
 
 
218
 
                win.setFocusHidden(true);
219
 
                win.setIconHidden(true);
220
 
                win.moveToLayer(Fluxbox::instance()->getDesktopLayer());
221
 
                win.setDecorationMask(0);
222
 
                win.setTabable(false);
223
 
                win.setMovable(false);
224
 
                win.setResizable(false);
225
 
                win.stick();
226
 
            }
227
 
 
228
 
        }
229
 
        XFree(data);
230
 
    }
231
 
 
232
 
    setupState(win);
233
 
 
234
 
    if (win.winClient().property(m_net_wm_desktop, 0, 1, False, XA_CARDINAL,
235
 
                                 &ret_type, &fmt, &nitems, &bytes_after,
236
 
                                 (unsigned char **) &data) && data) {
237
 
        unsigned int desktop = static_cast<unsigned int>(*data);
238
 
        if (desktop == 0xFFFFFFFF && !win.isStuck())
239
 
            win.stick();
240
 
        else
241
 
            win.setWorkspace(desktop);
242
 
 
243
 
        XFree(data);
244
 
    } else 
245
 
        updateWorkspace(win);
246
 
 
247
 
}
248
 
 
249
 
void Ewmh::updateFrameClose(FluxboxWindow &win) {
250
 
    clearState(win);
251
 
}
252
 
 
253
 
void Ewmh::updateFocusedWindow(BScreen &screen, Window win) {
254
 
    /* From Extended Window Manager Hints, draft 1.3:
255
 
     *
256
 
     * _NET_ACTIVE_WINDOW, WINDOW/32
257
 
     *
258
 
     * The window ID of the currently active window or None
259
 
     * if no window has the focus. This is a read-only
260
 
     * property set by the Window Manager.
261
 
     *
262
 
     */
263
 
    screen.rootWindow().changeProperty(m_net_active_window,
264
 
                                       XA_WINDOW, 32,
265
 
                                       PropModeReplace,
266
 
                                       (unsigned char *)&win, 1);
267
 
}
268
 
 
269
 
void Ewmh::updateClientClose(WinClient &winclient){
270
 
    updateClientList(winclient.screen());
271
 
}
272
 
 
273
 
void Ewmh::updateClientList(BScreen &screen) {
274
 
    size_t num=0;
275
 
 
276
 
    BScreen::Workspaces::const_iterator workspace_it =
277
 
        screen.getWorkspacesList().begin();
278
 
    const BScreen::Workspaces::const_iterator workspace_it_end =
279
 
        screen.getWorkspacesList().end();
280
 
    for (; workspace_it != workspace_it_end; ++workspace_it) {
281
 
        Workspace::Windows::iterator win_it =
282
 
            (*workspace_it)->windowList().begin();
283
 
        Workspace::Windows::iterator win_it_end =
284
 
            (*workspace_it)->windowList().end();
285
 
        for (; win_it != win_it_end; ++win_it) {
286
 
            num += (*win_it)->numClients();
287
 
        }
288
 
 
289
 
    }
290
 
    // and count icons
291
 
    BScreen::Icons::const_iterator icon_it = screen.iconList().begin();
292
 
    BScreen::Icons::const_iterator icon_it_end = screen.iconList().end();
293
 
    for (; icon_it != icon_it_end; ++icon_it) {
294
 
        num += (*icon_it)->numClients();
295
 
    }
296
 
 
297
 
    Window *wl = FB_new_nothrow Window[num];
298
 
    if (wl == 0) {
299
 
        _FB_USES_NLS;
300
 
        cerr<<_FBTEXT(Ewmh, OutOfMemoryClientList, "Fatal: Out of memory, can't allocate for EWMH client list", "")<<endl;
301
 
        return;
302
 
    }
303
 
 
304
 
    //start the iterator from begining
305
 
    workspace_it = screen.getWorkspacesList().begin();
306
 
    int win=0;
307
 
    for (; workspace_it != workspace_it_end; ++workspace_it) {
308
 
 
309
 
        // Fill in array of window ID's
310
 
        Workspace::Windows::const_iterator it =
311
 
            (*workspace_it)->windowList().begin();
312
 
        Workspace::Windows::const_iterator it_end =
313
 
            (*workspace_it)->windowList().end();
314
 
        for (; it != it_end; ++it) {
315
 
            if ((*it)->numClients() == 1) {
316
 
                wl[win++] = (*it)->clientWindow();
317
 
            } else {
318
 
                // add every client in fluxboxwindow to list window list
319
 
                std::list<WinClient *>::iterator client_it =
320
 
                    (*it)->clientList().begin();
321
 
                std::list<WinClient *>::iterator client_it_end =
322
 
                    (*it)->clientList().end();
323
 
                for (; client_it != client_it_end; ++client_it)
324
 
                    wl[win++] = (*client_it)->window();
325
 
            }
326
 
        }
327
 
    }
328
 
 
329
 
    // plus iconified windows
330
 
    icon_it = screen.iconList().begin();
331
 
    for (; icon_it != icon_it_end; ++icon_it) {
332
 
        FluxboxWindow::ClientList::iterator client_it = (*icon_it)->clientList().begin();
333
 
        FluxboxWindow::ClientList::iterator client_it_end = (*icon_it)->clientList().end();
334
 
        for (; client_it != client_it_end; ++client_it)
335
 
            wl[win++] = (*client_it)->window();
336
 
    }
337
 
    //number of windows to show in client list
338
 
    num = win;
339
 
 
340
 
    /*  From Extended Window Manager Hints, draft 1.3:
341
 
     *
342
 
     * _NET_CLIENT_LIST, WINDOW[]/32
343
 
     * _NET_CLIENT_LIST_STACKING, WINDOW[]/32
344
 
     *
345
 
     * These arrays contain all X Windows managed by
346
 
     * the Window Manager. _NET_CLIENT_LIST has
347
 
     * initial mapping order, starting with the oldest
348
 
     * window. _NET_CLIENT_LIST_STACKING has
349
 
     * bottom-to-top stacking order. These properties
350
 
     * SHOULD be set and updated by the Window
351
 
     * Manager.
352
 
     */
353
 
    screen.rootWindow().changeProperty(m_net_client_list,
354
 
                                       XA_WINDOW, 32,
355
 
                                       PropModeReplace, (unsigned char *)wl, num);
356
 
    screen.rootWindow().changeProperty(m_net_client_list_stacking,
357
 
                                       XA_WINDOW, 32,
358
 
                                       PropModeReplace, (unsigned char *)wl, num);
359
 
 
360
 
    delete [] wl;
361
 
}
362
 
 
363
 
void Ewmh::updateWorkspaceNames(BScreen &screen) {
364
 
    /* From Extended Window Manager Hints, draft 1.3:
365
 
     *
366
 
     * _NET_DESKTOP_NAMES, UTF8_STRING[]
367
 
     *
368
 
     * The names of all virtual desktops.
369
 
     * This is a list of NULL-terminated strings in UTF-8
370
 
     * encoding [UTF8]. This property MAY be changed by a
371
 
     * Pager or the Window Manager at any time.
372
 
     *
373
 
     * Note: The number of names could be different from
374
 
     * _NET_NUMBER_OF_DESKTOPS. If it is less than
375
 
     * _NET_NUMBER_OF_DESKTOPS, then the desktops with high
376
 
     *  numbers are unnamed. If it is larger than
377
 
     * _NET_NUMBER_OF_DESKTOPS, then the excess names outside
378
 
     * of the _NET_NUMBER_OF_DESKTOPS are considered to be
379
 
     * reserved in case the number of desktops is increased.
380
 
     *
381
 
     * Rationale: The name is not a necessary attribute of a
382
 
     * virtual desktop. Thus the availability or unavailability
383
 
     * of names has no impact on virtual desktop functionality.
384
 
     * Since names are set by users and users are likely to
385
 
     * preset names for a fixed number of desktops, it
386
 
     * doesn't make sense to shrink or grow this list when the
387
 
     * number of available desktops changes.
388
 
     *
389
 
     */
390
 
    XTextProperty text;
391
 
    const BScreen::WorkspaceNames &workspacenames = screen.getWorkspaceNames();
392
 
    const size_t number_of_desks = workspacenames.size();
393
 
 
394
 
    char *names[number_of_desks];
395
 
 
396
 
    for (size_t i = 0; i < number_of_desks; i++) {
397
 
        names[i] = new char[workspacenames[i].size() + 1]; // +1 for \0
398
 
        memset(names[i], 0, workspacenames[i].size());
399
 
        strcpy(names[i], workspacenames[i].c_str());
400
 
    }
401
 
 
402
 
    if (XStringListToTextProperty(names, number_of_desks, &text)) {
403
 
        XSetTextProperty(FbTk::App::instance()->display(), screen.rootWindow().window(),
404
 
                         &text, m_net_desktop_names);
405
 
        XFree(text.value);
406
 
    }
407
 
 
408
 
    for (size_t i = 0; i < number_of_desks; i++)
409
 
        delete [] names[i];
410
 
 
411
 
}
412
 
 
413
 
void Ewmh::updateCurrentWorkspace(BScreen &screen) {
414
 
    /* From Extended Window Manager Hints, draft 1.3:
415
 
     *
416
 
     * _NET_CURRENT_DESKTOP desktop, CARDINAL/32
417
 
     *
418
 
     * The index of the current desktop. This is always
419
 
     * an integer between 0 and _NET_NUMBER_OF_DESKTOPS - 1.
420
 
     * This MUST be set and updated by the Window Manager.
421
 
     *
422
 
     */
423
 
    unsigned long workspace = screen.currentWorkspaceID();
424
 
    screen.rootWindow().changeProperty(m_net_current_desktop,
425
 
                                       XA_CARDINAL, 32,
426
 
                                       PropModeReplace,
427
 
                                       (unsigned char *)&workspace, 1);
428
 
 
429
 
}
430
 
 
431
 
void Ewmh::updateWorkspaceCount(BScreen &screen) {
432
 
    /* From Extended Window Manager Hints, draft 1.3:
433
 
     *
434
 
     * _NET_NUMBER_OF_DESKTOPS, CARDINAL/32
435
 
     *
436
 
     * This property SHOULD be set and updated by the
437
 
     * Window Manager to indicate the number of virtual
438
 
     * desktops.
439
 
     */
440
 
    unsigned long numworkspaces = screen.numberOfWorkspaces();
441
 
    screen.rootWindow().changeProperty(m_net_number_of_desktops,
442
 
                                       XA_CARDINAL, 32,
443
 
                                       PropModeReplace,
444
 
                                       (unsigned char *)&numworkspaces, 1);
445
 
}
446
 
 
447
 
void Ewmh::updateViewPort(BScreen &screen) {
448
 
    /* From Extended Window Manager Hints, draft 1.3:
449
 
     *
450
 
     * _NET_DESKTOP_VIEWPORT x, y, CARDINAL[][2]/32
451
 
     *
452
 
     * Array of pairs of cardinals that define the
453
 
     * top left corner of each desktop's viewport.
454
 
     * For Window Managers that don't support large
455
 
     * desktops, this MUST always be set to (0,0).
456
 
     *
457
 
     */
458
 
    long value[2] = {0, 0}; // we dont support large desktops
459
 
    screen.rootWindow().changeProperty(m_net_desktop_viewport,
460
 
                                       XA_CARDINAL, 32,
461
 
                                       PropModeReplace,
462
 
                                       (unsigned char *)value, 2);
463
 
}
464
 
 
465
 
void Ewmh::updateGeometry(BScreen &screen) {
466
 
    /* From Extended Window Manager Hints, draft 1.3:
467
 
     *
468
 
     * _NET_DESKTOP_GEOMETRY width, height, CARDINAL[2]/32
469
 
     *
470
 
     * Array of two cardinals that defines the common size
471
 
     * of all desktops (this is equal to the screen size
472
 
     * if the Window Manager doesn't support large
473
 
     * desktops, otherwise it's equal to the virtual size
474
 
     * of the desktop). This property SHOULD be set by the
475
 
     * Window Manager.
476
 
     *
477
 
     */
478
 
    long value[2] = {screen.width(), screen.height()};
479
 
    screen.rootWindow().changeProperty(m_net_desktop_geometry,
480
 
                                       XA_CARDINAL, 32,
481
 
                                       PropModeReplace,
482
 
                                       (unsigned char *)value, 2);
483
 
 
484
 
}
485
 
 
486
 
void Ewmh::updateWorkarea(BScreen &screen) {
487
 
    /* From Extended Window Manager Hints, draft 1.3:
488
 
     *
489
 
     * _NET_WORKAREA, x, y, width, height CARDINAL[][4]/32
490
 
     *
491
 
     * This property MUST be set by the Window Manager upon
492
 
     * calculating the work area for each desktop. Contains a
493
 
     * geometry for each desktop. These geometries are
494
 
     * specified relative to the viewport on each desktop and
495
 
     * specify an area that is completely contained within the
496
 
     * viewport. Work area SHOULD be used by desktop applications
497
 
     * to place desktop icons appropriately.
498
 
     *
499
 
     */
500
 
 
501
 
    /* !!TODO
502
 
     * Not sure how to handle xinerama stuff here.
503
 
     * So i'm just doing this on the first head.
504
 
     */
505
 
    unsigned long *coords = new unsigned long[4*screen.numberOfWorkspaces()];
506
 
    for (unsigned int i=0; i < screen.numberOfWorkspaces()*4; i+=4) {
507
 
        // x, y
508
 
        coords[i] = screen.maxLeft(0);
509
 
        coords[i + 1] = screen.maxTop(0);
510
 
        // width, height
511
 
        coords[i + 2] = screen.maxRight(0) - screen.maxLeft(0);
512
 
        coords[i + 3] = screen.maxBottom(0) - screen.maxTop(0);
513
 
 
514
 
    }
515
 
    screen.rootWindow().changeProperty(m_net_workarea,
516
 
                                       XA_CARDINAL, 32,
517
 
                                       PropModeReplace,
518
 
                                       (unsigned char *)coords,
519
 
                                       4 * screen.numberOfWorkspaces());
520
 
 
521
 
    delete[] coords;
522
 
}
523
 
 
524
 
void Ewmh::updateState(FluxboxWindow &win) {
525
 
    
526
 
    // TODO: should we update the _NET_WM_ALLOWED_ACTIONS
527
 
    //       here too?
528
 
    
529
 
    typedef std::vector<unsigned int> StateVec;
530
 
 
531
 
    StateVec state;
532
 
 
533
 
    if (win.isStuck())
534
 
        state.push_back(m_net_wm_state_sticky);
535
 
    if (win.isShaded())
536
 
        state.push_back(m_net_wm_state_shaded);
537
 
    if (win.layerNum() == Fluxbox::instance()->getBottomLayer())
538
 
        state.push_back(m_net_wm_state_below);
539
 
    if (win.layerNum() == Fluxbox::instance()->getAboveDockLayer())
540
 
        state.push_back(m_net_wm_state_above);
541
 
    if (win.isIconic())
542
 
        state.push_back(m_net_wm_state_hidden);
543
 
    if (win.isIconHidden())
544
 
        state.push_back(m_net_wm_state_skip_taskbar);
545
 
    if (win.isFullscreen()) {
546
 
        state.push_back(m_net_wm_state_fullscreen);
547
 
    }
548
 
 
549
 
    FluxboxWindow::ClientList::iterator it = win.clientList().begin();
550
 
    FluxboxWindow::ClientList::iterator it_end = win.clientList().end();
551
 
    
552
 
    it = win.clientList().begin();
553
 
    for (; it != it_end; ++it) {
554
 
        
555
 
        // search the old states for _NET_WM_STATE_SKIP_PAGER and append it
556
 
        // to the current state, so it wont get deleted by us.
557
 
        StateVec client_state(state);
558
 
        Atom ret_type;
559
 
        int fmt;
560
 
        unsigned long nitems, bytes_after;
561
 
        unsigned char *data = 0;
562
 
 
563
 
        (*it)->property(m_net_wm_state, 0, 0x7fffffff, False, XA_ATOM,
564
 
                                 &ret_type, &fmt, &nitems, &bytes_after,
565
 
                                 &data);
566
 
        if (data) {
567
 
            Atom *old_states = (Atom *)data;
568
 
            for (unsigned long i=0; i < nitems; ++i)
569
 
                if (old_states[i] == m_net_wm_state_skip_pager) {
570
 
                    client_state.push_back(m_net_wm_state_skip_pager);
571
 
                }
572
 
            XFree(data);
573
 
        }
574
 
 
575
 
        if (!client_state.empty())
576
 
            (*it)->changeProperty(m_net_wm_state, XA_ATOM, 32, PropModeReplace,
577
 
                                  reinterpret_cast<unsigned char*>(&client_state.front()), 
578
 
                                  client_state.size());
579
 
        else
580
 
            (*it)->deleteProperty(m_net_wm_state);
581
 
    }
582
 
}
583
 
 
584
 
void Ewmh::updateLayer(FluxboxWindow &win) {
585
 
    //!! TODO _NET_WM_WINDOW_TYPE
586
 
    /*
587
 
    if (win.getLayer() == Fluxbox::instance()->getAboveDockLayer()) {
588
 
        // _NET_WM_STATE_BELOW
589
 
 
590
 
    } else if (win.getLayer() == Fluxbox::instance()->getBottomLayer()) {
591
 
        // _NET_WM_STATE_ABOVE
592
 
    }
593
 
    */
594
 
}
595
 
 
596
 
void Ewmh::updateHints(FluxboxWindow &win) {
597
 
}
598
 
 
599
 
void Ewmh::updateWorkspace(FluxboxWindow &win) {
600
 
    long workspace = win.isInitialized() ? win.workspaceNumber() : win.screen().currentWorkspaceID();
601
 
 
602
 
    if (win.isStuck())
603
 
        workspace = 0xFFFFFFFF; // appear on all desktops/workspaces
604
 
 
605
 
    FluxboxWindow::ClientList::iterator it = win.clientList().begin();
606
 
    FluxboxWindow::ClientList::iterator it_end = win.clientList().end();
607
 
    for (; it != it_end; ++it) {
608
 
        (*it)->changeProperty(m_net_wm_desktop, XA_CARDINAL, 32, PropModeReplace,
609
 
                              (unsigned char *)&workspace, 1);
610
 
    }
611
 
 
612
 
}
613
 
 
614
 
 
615
 
// return true if we did handle the atom here
616
 
bool Ewmh::checkClientMessage(const XClientMessageEvent &ce,
617
 
                              BScreen * screen, WinClient * const winclient) {
618
 
 
619
 
    if (ce.message_type == m_net_wm_desktop) {
620
 
        // ce.data.l[0] = workspace number
621
 
        // valid window
622
 
 
623
 
        if (winclient == 0 || winclient->fbwindow() == 0)
624
 
            return true;
625
 
 
626
 
        FluxboxWindow *fbwin = winclient->fbwindow();
627
 
 
628
 
        // if it's stick, make sure it is stuck.
629
 
        // otherwise, make sure it isn't stuck
630
 
        if (ce.data.l[0] == 0xFFFFFFFF) {
631
 
            if (!fbwin->isStuck())
632
 
                fbwin->stick();
633
 
            return true;
634
 
        } else if (fbwin->isStuck())
635
 
            fbwin->stick();
636
 
 
637
 
        // the screen is the root window of the message,
638
 
        // which doesn't apply here (so borrow the variable :) )
639
 
        screen = &fbwin->screen();
640
 
        // valid workspace number?
641
 
        if (static_cast<unsigned int>(ce.data.l[0]) < screen->numberOfWorkspaces())
642
 
            screen->sendToWorkspace(ce.data.l[0], fbwin, false);
643
 
 
644
 
        return true;
645
 
    } else if (ce.message_type == m_net_wm_state) {
646
 
        if (winclient == 0 || winclient->fbwindow() == 0)
647
 
            return true;
648
 
 
649
 
        FluxboxWindow &win = *winclient->fbwindow();
650
 
        // ce.data.l[0] = the action (remove, add or toggle)
651
 
        // ce.data.l[1] = the first property to alter
652
 
        // ce.data.l[2] = second property to alter (can be zero)
653
 
        if (ce.data.l[0] == STATE_REMOVE) {
654
 
            setState(win, ce.data.l[1], false);
655
 
            setState(win, ce.data.l[2], false);
656
 
        } else if (ce.data.l[0] == STATE_ADD) {
657
 
            setState(win, ce.data.l[1], true);
658
 
            setState(win, ce.data.l[2], true);
659
 
        } else if (ce.data.l[0] == STATE_TOGGLE) {
660
 
            toggleState(win, ce.data.l[1]);
661
 
            toggleState(win, ce.data.l[2]);
662
 
        }
663
 
        return true;
664
 
    } else if (ce.message_type == m_net_number_of_desktops) {
665
 
        if (screen == 0)
666
 
            return true;
667
 
        // ce.data.l[0] = number of workspaces
668
 
 
669
 
        // no need to alter number of desktops if they are the same
670
 
        // or if requested number of workspace is less than zero
671
 
        if (screen->numberOfWorkspaces() == static_cast<unsigned int>(ce.data.l[0]) ||
672
 
            ce.data.l[0] < 0)
673
 
            return true;
674
 
 
675
 
        if (screen->numberOfWorkspaces() > static_cast<unsigned int>(ce.data.l[0])) {
676
 
            // remove last workspace until we have
677
 
            // the same number of workspaces
678
 
            while (screen->numberOfWorkspaces() != static_cast<unsigned int>(ce.data.l[0])) {
679
 
                screen->removeLastWorkspace();
680
 
                if (screen->numberOfWorkspaces() == 1) // must have at least one workspace
681
 
                    break;
682
 
            }
683
 
        } else { // add workspaces to screen until workspace count match the requested size
684
 
            while (screen->numberOfWorkspaces() != static_cast<unsigned int>(ce.data.l[0])) {
685
 
                screen->addWorkspace();
686
 
            }
687
 
        }
688
 
 
689
 
        return true;
690
 
    } else if (ce.message_type == m_net_current_desktop) {
691
 
        if (screen == 0)
692
 
            return true;
693
 
        // ce.data.l[0] = workspace number
694
 
 
695
 
        // prevent out of range value
696
 
        if (static_cast<unsigned int>(ce.data.l[0]) >= screen->numberOfWorkspaces())
697
 
            return true;
698
 
        screen->changeWorkspaceID(ce.data.l[0]);
699
 
        return true;
700
 
    } else if (ce.message_type == m_net_active_window) {
701
 
 
702
 
        // make sure we have a valid window
703
 
        if (winclient == 0)
704
 
            return true;
705
 
        // ce.window = window to focus
706
 
 
707
 
        winclient->focus();
708
 
        if (winclient->fbwindow()) {
709
 
 
710
 
            FluxboxWindow* fbwin = winclient->fbwindow();
711
 
            fbwin->raise();
712
 
 
713
 
            // if the raised window is on a different workspace
714
 
            // we do what the user wish: 
715
 
            //   either ignore|go to that workspace|get the window
716
 
            if (fbwin->screen().currentWorkspaceID() != fbwin->workspaceNumber()) {
717
 
                if (fbwin->screen().getFollowModel() == BScreen::FOLLOW_ACTIVE_WINDOW) {
718
 
                    fbwin->screen().changeWorkspaceID(fbwin->workspaceNumber());
719
 
                } else if (fbwin->screen().getFollowModel() == BScreen::FETCH_ACTIVE_WINDOW) {
720
 
                    fbwin->screen().sendToWorkspace(fbwin->screen().currentWorkspaceID(), fbwin);
721
 
                } // else we ignore it. my favourite mode :)
722
 
            }
723
 
        } 
724
 
        return true;
725
 
    } else if (ce.message_type == m_net_close_window) {
726
 
        if (winclient == 0)
727
 
            return true;
728
 
        // ce.window = window to close (which in this case is the win argument)
729
 
        winclient->sendClose();
730
 
        return true;
731
 
    } else if (ce.message_type == m_net_moveresize_window) {
732
 
        if (winclient == 0 || winclient->fbwindow() == 0)
733
 
            return true;
734
 
        // ce.data.l[0] = gravity and flags
735
 
        // ce.data.l[1] = x
736
 
        // ce.data.l[2] = y
737
 
        // ce.data.l[3] = width
738
 
        // ce.data.l[4] = height
739
 
        // TODO: flags
740
 
        int win_gravity=ce.data.l[0] & 0xFF;
741
 
        winclient->fbwindow()->moveResizeForClient(ce.data.l[1], ce.data.l[2],
742
 
                                          ce.data.l[3], ce.data.l[4], win_gravity);
743
 
        return true;
744
 
    }
745
 
 
746
 
    // we didn't handle the ce.message_type here
747
 
    return false;
748
 
}
749
 
 
750
 
 
751
 
bool Ewmh::propertyNotify(WinClient &winclient, Atom the_property) {
752
 
    if (the_property == m_net_wm_strut) {
753
 
#ifdef DEBUG
754
 
        cerr<<"_NET_WM_STRUT"<<endl;
755
 
#endif // DEBUG
756
 
        updateStrut(winclient);
757
 
        return true;
758
 
    } 
759
 
 
760
 
    return false;
761
 
}
762
 
 
763
 
void Ewmh::createAtoms() {
764
 
 
765
 
    Display *disp = FbTk::App::instance()->display();
766
 
 
767
 
    m_net_supported = XInternAtom(disp, "_NET_SUPPORTED", False);
768
 
    m_net_client_list = XInternAtom(disp, "_NET_CLIENT_LIST", False);
769
 
    m_net_client_list_stacking = XInternAtom(disp, "_NET_CLIENT_LIST_STACKING", False);
770
 
    m_net_number_of_desktops = XInternAtom(disp, "_NET_NUMBER_OF_DESKTOPS", False);
771
 
    m_net_desktop_geometry = XInternAtom(disp, "_NET_DESKTOP_GEOMETRY", False);
772
 
    m_net_desktop_viewport = XInternAtom(disp, "_NET_DESKTOP_VIEWPORT", False);
773
 
    m_net_current_desktop = XInternAtom(disp, "_NET_CURRENT_DESKTOP", False);
774
 
    m_net_desktop_names = XInternAtom(disp, "_NET_DESKTOP_NAMES", False);
775
 
    m_net_active_window = XInternAtom(disp, "_NET_ACTIVE_WINDOW", False);
776
 
    m_net_workarea = XInternAtom(disp, "_NET_WORKAREA", False);
777
 
    m_net_supporting_wm_check = XInternAtom(disp, "_NET_SUPPORTING_WM_CHECK", False);
778
 
    m_net_virtual_roots = XInternAtom(disp, "_NET_VIRTUAL_ROOTS", False);
779
 
 
780
 
    m_net_close_window = XInternAtom(disp, "_NET_CLOSE_WINDOW", False);
781
 
    m_net_moveresize_window = XInternAtom(disp, "_NET_MOVERESIZE_WINDOW", False);
782
 
 
783
 
    // TODO: implement this one
784
 
    m_net_wm_moveresize = XInternAtom(disp, "_NET_WM_MOVERESIZE", False);
785
 
 
786
 
    m_net_properties = XInternAtom(disp, "_NET_PROPERTIES", False);
787
 
    m_net_wm_name = XInternAtom(disp, "_NET_WM_NAME", False);
788
 
    m_net_wm_desktop = XInternAtom(disp, "_NET_WM_DESKTOP", False);
789
 
 
790
 
    // type atoms
791
 
    m_net_wm_window_type = XInternAtom(disp, "_NET_WM_WINDOW_TYPE", False);
792
 
    m_net_wm_window_type_dock = XInternAtom(disp, "_NET_WM_WINDOW_TYPE_DOCK", False);
793
 
    m_net_wm_window_type_desktop = XInternAtom(disp, "_NET_WM_WINDOW_TYPE_DESKTOP", False);
794
 
 
795
 
    // state atom and the supported state atoms
796
 
    m_net_wm_state = XInternAtom(disp, "_NET_WM_STATE", False);
797
 
    m_net_wm_state_sticky = XInternAtom(disp, "_NET_WM_STATE_STICKY", False);
798
 
    m_net_wm_state_shaded = XInternAtom(disp, "_NET_WM_STATE_SHADED", False);
799
 
    m_net_wm_state_maximized_horz = XInternAtom(disp, "_NET_WM_STATE_MAXIMIZED_HORZ", False);
800
 
    m_net_wm_state_maximized_vert = XInternAtom(disp, "_NET_WM_STATE_MAXIMIZED_VERT", False);
801
 
    m_net_wm_state_fullscreen = XInternAtom(disp, "_NET_WM_STATE_FULLSCREEN", False);
802
 
    m_net_wm_state_hidden = XInternAtom(disp, "_NET_WM_STATE_HIDDEN", False);
803
 
    m_net_wm_state_skip_taskbar = XInternAtom(disp, "_NET_WM_STATE_SKIP_TASKBAR", False);
804
 
    m_net_wm_state_skip_pager = XInternAtom(disp, "_NET_WM_STATE_SKIP_PAGER", False);
805
 
    m_net_wm_state_above = XInternAtom(disp, "_NET_WM_STATE_ABOVE", False);
806
 
    m_net_wm_state_below = XInternAtom(disp, "_NET_WM_STATE_BELOW", False);
807
 
 
808
 
    // allowed actions
809
 
    m_net_wm_allowed_actions = XInternAtom(disp, "_NET_WM_ALLOWED_ACTIONS", False);
810
 
    m_net_wm_action_move = XInternAtom(disp, "_NET_WM_ACTIONS_MOVE", False);
811
 
    m_net_wm_action_resize = XInternAtom(disp, "_NET_WM_ACTIONS_RESIZE", False);
812
 
    m_net_wm_action_minimize = XInternAtom(disp, "_NET_WM_ACTIONS_MINIMIZE", False);
813
 
    m_net_wm_action_shade = XInternAtom(disp, "_NET_WM_ACTIONS_SHADE", False);
814
 
    m_net_wm_action_stick = XInternAtom(disp, "_NET_WM_ACTIONS_STICK", False);
815
 
    m_net_wm_action_maximize_horz = XInternAtom(disp, "_NET_WM_ACTIONS_MAXIMIZE_HORZ", False);
816
 
    m_net_wm_action_maximize_vert = XInternAtom(disp, "_NET_WM_ACTIONS_MAXIMIZE_VERT", False);
817
 
    m_net_wm_action_fullscreen = XInternAtom(disp, "_NET_WM_ACTIONS_FULLSCREEN", False);
818
 
    m_net_wm_action_change_desktop = XInternAtom(disp, "_NET_WM_ACTIONS_CHANGE_DESKTOP", False);
819
 
    m_net_wm_action_close = XInternAtom(disp, "_NET_WM_ACTIONS_CLOSE", False);
820
 
 
821
 
    m_net_wm_strut = XInternAtom(disp, "_NET_WM_STRUT", False);
822
 
    m_net_wm_icon_geometry = XInternAtom(disp, "_NET_WM_ICON_GEOMETRY", False);
823
 
    m_net_wm_icon = XInternAtom(disp, "_NET_WM_ICON", False);
824
 
    m_net_wm_pid = XInternAtom(disp, "_NET_WM_PID", False);
825
 
    m_net_wm_handled_icons = XInternAtom(disp, "_NET_WM_HANDLED_ICONS", False);
826
 
 
827
 
    m_net_wm_ping = XInternAtom(disp, "_NET_WM_PING", False);
828
 
    utf8_string = XInternAtom(disp, "UTF8_STRING", False);
829
 
}
830
 
 
831
 
 
832
 
void Ewmh::setFullscreen(FluxboxWindow &win, bool value) {
833
 
    // fullscreen implies maximised, above dock layer,
834
 
    // and no decorations (or decorations offscreen)
835
 
    // 
836
 
    // TODO: do we need the WindowState etc here anymore?
837
 
    //       FluxboxWindow::setFullscreen() remembering old values
838
 
    //       already and set them...
839
 
    //       only reason i can see is that the user manually
840
 
    //       moved the (fullscreened) window
841
 
    WindowState *saved_state = getState(win);
842
 
    if (value) {
843
 
        // fullscreen on
844
 
        if (!saved_state) { // not already fullscreen
845
 
            saved_state = new WindowState(win.x(), win.y(), win.width(),
846
 
                                          win.height(), win.layerNum(), win.decorationMask());
847
 
            saveState(win, saved_state);
848
 
            win.setFullscreen(true);
849
 
        }
850
 
    } else { // turn off fullscreen
851
 
        if (saved_state) { // no saved state, can't restore it
852
 
            win.setFullscreen(false);
853
 
            /*
854
 
            win.setDecorationMask(saved_state->decor);
855
 
            win.moveResize(saved_state->x, saved_state->y,
856
 
                           saved_state->width, saved_state->height);
857
 
            win.moveToLayer(saved_state->layer);
858
 
            */
859
 
            clearState(win);
860
 
            saved_state = 0;
861
 
        }
862
 
    }
863
 
}
864
 
 
865
 
// set window state
866
 
void Ewmh::setState(FluxboxWindow &win, Atom state, bool value) {
867
 
 
868
 
    if (state == m_net_wm_state_sticky) { // STICKY
869
 
        if (value && !win.isStuck() ||
870
 
            (!value && win.isStuck()))
871
 
            win.stick();
872
 
    } else if (state == m_net_wm_state_shaded) { // SHADED
873
 
        if ((value && !win.isShaded()) ||
874
 
            (!value && win.isShaded()))
875
 
            win.shade();
876
 
    }  else if (state == m_net_wm_state_maximized_horz ) { // maximized Horizontal
877
 
        if ((value && !win.isMaximized()) ||
878
 
            (!value && win.isMaximized()))
879
 
        win.maximizeHorizontal();
880
 
    } else if (state == m_net_wm_state_maximized_vert) { // maximized Vertical
881
 
        if ((value && !win.isMaximized()) ||
882
 
            (!value && win.isMaximized()))
883
 
        win.maximizeVertical();
884
 
    } else if (state == m_net_wm_state_fullscreen) { // fullscreen
885
 
        if ((value && !win.isFullscreen()) ||
886
 
            (!value && win.isFullscreen()))
887
 
        setFullscreen(win, value);
888
 
    } else if (state == m_net_wm_state_skip_taskbar) {
889
 
        win.setIconHidden(value);
890
 
    } else if (state == m_net_wm_state_below) {  // bottom layer
891
 
        if (value)
892
 
            win.moveToLayer(Fluxbox::instance()->getBottomLayer());
893
 
        else
894
 
            win.moveToLayer(Fluxbox::instance()->getNormalLayer());
895
 
 
896
 
    } else if (state == m_net_wm_state_above) { // above layer
897
 
        if (value)
898
 
            win.moveToLayer(Fluxbox::instance()->getAboveDockLayer());
899
 
        else
900
 
            win.moveToLayer(Fluxbox::instance()->getNormalLayer());
901
 
    }
902
 
}
903
 
 
904
 
// toggle window state
905
 
void Ewmh::toggleState(FluxboxWindow &win, Atom state) {
906
 
    if (state == m_net_wm_state_sticky) {
907
 
        win.stick();
908
 
    } else if (state == m_net_wm_state_shaded){
909
 
        win.shade();
910
 
    } else if (state == m_net_wm_state_maximized_horz ) { // maximized Horizontal
911
 
        win.maximizeHorizontal();
912
 
    } else if (state == m_net_wm_state_maximized_vert) { // maximized Vertical
913
 
        win.maximizeVertical();
914
 
    } else if (state == m_net_wm_state_fullscreen) { // fullscreen
915
 
        setFullscreen(win, getState(win) == 0); // toggle current state
916
 
    } else if (state == m_net_wm_state_skip_taskbar) {
917
 
        win.setIconHidden(!win.isIconHidden());
918
 
    } else if (state == m_net_wm_state_below) { // bottom layer
919
 
        if (win.layerNum() == Fluxbox::instance()->getBottomLayer())
920
 
            win.moveToLayer(Fluxbox::instance()->getNormalLayer());
921
 
        else
922
 
            win.moveToLayer(Fluxbox::instance()->getBottomLayer());
923
 
 
924
 
    } else if (state == m_net_wm_state_above) { // top layer
925
 
        if (win.layerNum() == Fluxbox::instance()->getAboveDockLayer())
926
 
            win.moveToLayer(Fluxbox::instance()->getNormalLayer());
927
 
        else
928
 
            win.moveToLayer(Fluxbox::instance()->getAboveDockLayer());
929
 
    }
930
 
 
931
 
}
932
 
 
933
 
 
934
 
void Ewmh::updateStrut(WinClient &winclient) {
935
 
    Atom ret_type = 0;
936
 
    int fmt = 0;
937
 
    unsigned long nitems = 0, bytes_after = 0;
938
 
    long *data = 0;
939
 
    if (winclient.property(m_net_wm_strut, 0, 4, False, XA_CARDINAL,
940
 
                                 &ret_type, &fmt, &nitems, &bytes_after,
941
 
                                 (unsigned char **) &data) && data) {
942
 
 
943
 
        int head = winclient.screen().getHead(winclient);
944
 
        winclient.setStrut(winclient.screen().requestStrut(head, 
945
 
                           data[0], data[1], 
946
 
                           data[2], data[3]));
947
 
        winclient.screen().updateAvailableWorkspaceArea();
948
 
    }
949
 
}
950
 
 
951
 
void Ewmh::setupState(FluxboxWindow &win) {
952
 
    /* From Extended Window Manager Hints, draft 1.3:
953
 
     *
954
 
     * _NET_WM_STATE, ATOM[]
955
 
     *
956
 
     * A list of hints describing the window state. Atoms present in
957
 
     * the list MUST be considered set, atoms not present in the list
958
 
     * MUST be considered not set. The Window Manager SHOULD honor
959
 
     * _NET_WM_STATE whenever a withdrawn window requests to be mapped.
960
 
     * A Client wishing to change the state of a window MUST send a
961
 
     * _NET_WM_STATE client message to the root window (see below).
962
 
     * The Window Manager MUST keep this property updated to reflect
963
 
     * the current state of the window.
964
 
     *
965
 
     * The Window Manager should remove the property whenever a window
966
 
     * is withdrawn, but it should leave the property in place when it
967
 
     * is shutting down, e.g. in response to losing ownership of the
968
 
     * WM_Sn manager selection.
969
 
     */
970
 
    Atom ret_type;
971
 
    int fmt;
972
 
    unsigned long nitems, bytes_after;
973
 
    unsigned char *data = 0;
974
 
 
975
 
    win.winClient().property(m_net_wm_state, 0, 0x7fffffff, False, XA_ATOM,
976
 
                             &ret_type, &fmt, &nitems, &bytes_after,
977
 
                             &data);
978
 
    if (data) {
979
 
        Atom *states = (Atom *)data;
980
 
        for (unsigned long i=0; i < nitems; ++i)
981
 
            setState(win, states[i], true);
982
 
 
983
 
        XFree(data);
984
 
    }
985
 
}
986
 
 
987
 
Ewmh::WindowState::WindowState(int t_x, int t_y,
988
 
                               unsigned int t_width,
989
 
                               unsigned int t_height,
990
 
                               int t_layer, unsigned int t_decor) :
991
 
    x(t_x), y(t_y),
992
 
    layer(t_layer),
993
 
    width(t_width),
994
 
    height(t_height),
995
 
    decor(t_decor)
996
 
{}
997
 
 
998
 
Ewmh::WindowState *Ewmh::getState(FluxboxWindow &win) {
999
 
    SavedState::iterator it = m_savedstate.find(&win);
1000
 
    if (it == m_savedstate.end())
1001
 
        return 0;
1002
 
    else
1003
 
        return it->second;
1004
 
}
1005
 
 
1006
 
void Ewmh::clearState(FluxboxWindow &win) {
1007
 
    WindowState *state = 0;
1008
 
    SavedState::iterator it = m_savedstate.find(&win);
1009
 
    if (it == m_savedstate.end())
1010
 
        return;
1011
 
 
1012
 
    state = it->second;
1013
 
 
1014
 
    m_savedstate.erase(it);
1015
 
    delete state;
1016
 
}
1017
 
 
1018
 
void Ewmh::saveState(FluxboxWindow &win, WindowState *state) {
1019
 
    m_savedstate[&win] = state;
1020
 
}