diff options
author | rathnor <rathnor> | 2003-09-23 13:52:05 (GMT) |
---|---|---|
committer | rathnor <rathnor> | 2003-09-23 13:52:05 (GMT) |
commit | a4c41f621b97084516299a322d62750f2e86b6a9 (patch) | |
tree | 8c7d95e18fc86611f74156664967aa24ceb75447 /src/Ewmh.cc | |
parent | 36d598600becf7cf6797d33d41e106ba8beb26e6 (diff) | |
download | fluxbox-a4c41f621b97084516299a322d62750f2e86b6a9.zip fluxbox-a4c41f621b97084516299a322d62750f2e86b6a9.tar.bz2 |
add support for _NET_WM_STATE_FULLSCREEN
Diffstat (limited to 'src/Ewmh.cc')
-rw-r--r-- | src/Ewmh.cc | 94 |
1 files changed, 86 insertions, 8 deletions
diff --git a/src/Ewmh.cc b/src/Ewmh.cc index 6b38e86..5924203 100644 --- a/src/Ewmh.cc +++ b/src/Ewmh.cc | |||
@@ -19,7 +19,7 @@ | |||
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
20 | // DEALINGS IN THE SOFTWARE. | 20 | // DEALINGS IN THE SOFTWARE. |
21 | 21 | ||
22 | // $Id: Ewmh.cc,v 1.32 2003/08/27 21:06:04 fluxgen Exp $ | 22 | // $Id: Ewmh.cc,v 1.33 2003/09/23 13:52:05 rathnor Exp $ |
23 | 23 | ||
24 | #include "Ewmh.hh" | 24 | #include "Ewmh.hh" |
25 | 25 | ||
@@ -76,9 +76,10 @@ void Ewmh::initForScreen(BScreen &screen) { | |||
76 | m_net_wm_state_shaded, | 76 | m_net_wm_state_shaded, |
77 | m_net_wm_state_maximized_horz, | 77 | m_net_wm_state_maximized_horz, |
78 | m_net_wm_state_maximized_vert, | 78 | m_net_wm_state_maximized_vert, |
79 | 79 | m_net_wm_state_fullscreen, | |
80 | |||
80 | m_net_wm_desktop, | 81 | m_net_wm_desktop, |
81 | 82 | ||
82 | // root properties | 83 | // root properties |
83 | m_net_client_list, | 84 | m_net_client_list, |
84 | m_net_number_of_desktops, | 85 | m_net_number_of_desktops, |
@@ -132,6 +133,10 @@ void Ewmh::setupFrame(FluxboxWindow &win) { | |||
132 | 133 | ||
133 | } | 134 | } |
134 | 135 | ||
136 | void Ewmh::updateFrameClose(FluxboxWindow &win) { | ||
137 | clearState(win); | ||
138 | } | ||
139 | |||
135 | void Ewmh::updateClientList(BScreen &screen) { | 140 | void Ewmh::updateClientList(BScreen &screen) { |
136 | size_t num=0; | 141 | size_t num=0; |
137 | 142 | ||
@@ -411,6 +416,7 @@ void Ewmh::createAtoms() { | |||
411 | m_net_wm_state_shaded = XInternAtom(disp, "_NET_WM_STATE_SHADED", False); | 416 | m_net_wm_state_shaded = XInternAtom(disp, "_NET_WM_STATE_SHADED", False); |
412 | m_net_wm_state_maximized_horz = XInternAtom(disp, "_NET_WM_STATE_MAXIMIZED_HORZ", False); | 417 | m_net_wm_state_maximized_horz = XInternAtom(disp, "_NET_WM_STATE_MAXIMIZED_HORZ", False); |
413 | m_net_wm_state_maximized_vert = XInternAtom(disp, "_NET_WM_STATE_MAXIMIZED_VERT", False); | 418 | m_net_wm_state_maximized_vert = XInternAtom(disp, "_NET_WM_STATE_MAXIMIZED_VERT", False); |
419 | m_net_wm_state_fullscreen = XInternAtom(disp, "_NET_WM_STATE_FULLSCREEN", False); | ||
414 | 420 | ||
415 | m_net_wm_strut = XInternAtom(disp, "_NET_WM_STRUT", False); | 421 | m_net_wm_strut = XInternAtom(disp, "_NET_WM_STRUT", False); |
416 | m_net_wm_icon_geometry = XInternAtom(disp, "_NET_WM_ICON_GEOMETRY", False); | 422 | m_net_wm_icon_geometry = XInternAtom(disp, "_NET_WM_ICON_GEOMETRY", False); |
@@ -421,8 +427,44 @@ void Ewmh::createAtoms() { | |||
421 | m_net_wm_ping = XInternAtom(disp, "_NET_WM_PING", False); | 427 | m_net_wm_ping = XInternAtom(disp, "_NET_WM_PING", False); |
422 | } | 428 | } |
423 | 429 | ||
430 | |||
431 | void Ewmh::setFullscreen(FluxboxWindow &win, bool value) { | ||
432 | // fullscreen implies maximised, above dock layer, | ||
433 | // and no decorations (or decorations offscreen) | ||
434 | WindowState *saved_state = getState(win); | ||
435 | if (value) { | ||
436 | // fullscreen on | ||
437 | if (!saved_state) { // not already fullscreen | ||
438 | saved_state = new WindowState(win.x(), win.y(), win.width(), | ||
439 | win.height(), win.layerNum(), win.decorationMask()); | ||
440 | saveState(win, saved_state); | ||
441 | |||
442 | // actually make it fullscreen | ||
443 | |||
444 | // clear decorations | ||
445 | win.setDecorationMask(0); | ||
446 | |||
447 | // be xinerama aware | ||
448 | BScreen &screen = win.screen(); | ||
449 | int head = screen.getHead(win.fbWindow()); | ||
450 | win.moveResize(screen.getHeadX(head), screen.getHeadY(head), | ||
451 | screen.getHeadWidth(head), screen.getHeadHeight(head)); | ||
452 | win.moveToLayer(Fluxbox::instance()->getAboveDockLayer()); | ||
453 | } | ||
454 | } else { // turn off fullscreen | ||
455 | if (saved_state) { // no saved state, can't restore it | ||
456 | win.setDecorationMask(saved_state->decor); | ||
457 | win.moveResize(saved_state->x, saved_state->y, | ||
458 | saved_state->width, saved_state->height); | ||
459 | win.moveToLayer(saved_state->layer); | ||
460 | clearState(win); | ||
461 | saved_state = 0; | ||
462 | } | ||
463 | } | ||
464 | } | ||
465 | |||
424 | // set window state | 466 | // set window state |
425 | void Ewmh::setState(FluxboxWindow &win, Atom state, bool value) const { | 467 | void Ewmh::setState(FluxboxWindow &win, Atom state, bool value) { |
426 | 468 | ||
427 | if (state == m_net_wm_state_sticky) { // STICKY | 469 | if (state == m_net_wm_state_sticky) { // STICKY |
428 | if (value && !win.isStuck() || | 470 | if (value && !win.isStuck() || |
@@ -440,13 +482,13 @@ void Ewmh::setState(FluxboxWindow &win, Atom state, bool value) const { | |||
440 | if ((value && !win.isMaximized()) || | 482 | if ((value && !win.isMaximized()) || |
441 | (!value && win.isMaximized())) | 483 | (!value && win.isMaximized())) |
442 | win.maximizeVertical(); | 484 | win.maximizeVertical(); |
485 | } else if (state == m_net_wm_state_fullscreen) { // fullscreen | ||
486 | setFullscreen(win, value); | ||
443 | } | 487 | } |
444 | |||
445 | |||
446 | } | 488 | } |
447 | 489 | ||
448 | // toggle window state | 490 | // toggle window state |
449 | void Ewmh::toggleState(FluxboxWindow &win, Atom state) const { | 491 | void Ewmh::toggleState(FluxboxWindow &win, Atom state) { |
450 | if (state == m_net_wm_state_sticky) { | 492 | if (state == m_net_wm_state_sticky) { |
451 | win.stick(); | 493 | win.stick(); |
452 | } else if (state == m_net_wm_state_shaded){ | 494 | } else if (state == m_net_wm_state_shaded){ |
@@ -455,8 +497,9 @@ void Ewmh::toggleState(FluxboxWindow &win, Atom state) const { | |||
455 | win.maximizeHorizontal(); | 497 | win.maximizeHorizontal(); |
456 | } else if (state == m_net_wm_state_maximized_vert) { // maximized Vertical | 498 | } else if (state == m_net_wm_state_maximized_vert) { // maximized Vertical |
457 | win.maximizeVertical(); | 499 | win.maximizeVertical(); |
500 | } else if (state == m_net_wm_state_fullscreen) { // fullscreen | ||
501 | setFullscreen(win, getState(win) == 0); // toggle current state | ||
458 | } | 502 | } |
459 | |||
460 | } | 503 | } |
461 | 504 | ||
462 | 505 | ||
@@ -477,3 +520,38 @@ void Ewmh::updateStrut(WinClient &winclient) { | |||
477 | winclient.screen().updateAvailableWorkspaceArea(); | 520 | winclient.screen().updateAvailableWorkspaceArea(); |
478 | } | 521 | } |
479 | } | 522 | } |
523 | |||
524 | Ewmh::WindowState::WindowState(int t_x, int t_y, | ||
525 | unsigned int t_width, | ||
526 | unsigned int t_height, | ||
527 | int t_layer, unsigned int t_decor) : | ||
528 | x(t_x), y(t_y), | ||
529 | layer(t_layer), | ||
530 | width(t_width), | ||
531 | height(t_height), | ||
532 | decor(t_decor) | ||
533 | {} | ||
534 | |||
535 | Ewmh::WindowState *Ewmh::getState(FluxboxWindow &win) { | ||
536 | SavedState::iterator it = m_savedstate.find(&win); | ||
537 | if (it == m_savedstate.end()) | ||
538 | return 0; | ||
539 | else | ||
540 | return it->second; | ||
541 | } | ||
542 | |||
543 | void Ewmh::clearState(FluxboxWindow &win) { | ||
544 | WindowState *state = 0; | ||
545 | SavedState::iterator it = m_savedstate.find(&win); | ||
546 | if (it == m_savedstate.end()) | ||
547 | return; | ||
548 | |||
549 | state = it->second; | ||
550 | |||
551 | m_savedstate.erase(it); | ||
552 | delete state; | ||
553 | } | ||
554 | |||
555 | void Ewmh::saveState(FluxboxWindow &win, WindowState *state) { | ||
556 | m_savedstate[&win] = state; | ||
557 | } | ||