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 | |
parent | 36d598600becf7cf6797d33d41e106ba8beb26e6 (diff) | |
download | fluxbox_lack-a4c41f621b97084516299a322d62750f2e86b6a9.zip fluxbox_lack-a4c41f621b97084516299a322d62750f2e86b6a9.tar.bz2 |
add support for _NET_WM_STATE_FULLSCREEN
Diffstat (limited to 'src')
-rw-r--r-- | src/Ewmh.cc | 94 | ||||
-rw-r--r-- | src/Ewmh.hh | 30 | ||||
-rw-r--r-- | src/Window.cc | 12 | ||||
-rw-r--r-- | src/Window.hh | 6 |
4 files changed, 121 insertions, 21 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 | } | ||
diff --git a/src/Ewmh.hh b/src/Ewmh.hh index 08de6cf..c4419ba 100644 --- a/src/Ewmh.hh +++ b/src/Ewmh.hh | |||
@@ -19,12 +19,13 @@ | |||
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.hh,v 1.11 2003/08/27 21:06:04 fluxgen Exp $ | 22 | // $Id: Ewmh.hh,v 1.12 2003/09/23 13:52:05 rathnor Exp $ |
23 | 23 | ||
24 | #include "AtomHandler.hh" | 24 | #include "AtomHandler.hh" |
25 | 25 | ||
26 | #include <X11/Xatom.h> | 26 | #include <X11/Xatom.h> |
27 | #include <vector> | 27 | #include <vector> |
28 | #include <map> | ||
28 | 29 | ||
29 | class Ewmh:public AtomHandler { | 30 | class Ewmh:public AtomHandler { |
30 | public: | 31 | public: |
@@ -50,16 +51,25 @@ public: | |||
50 | BScreen * screen, WinClient * const winclient); | 51 | BScreen * screen, WinClient * const winclient); |
51 | 52 | ||
52 | bool propertyNotify(WinClient &winclient, Atom the_property); | 53 | bool propertyNotify(WinClient &winclient, Atom the_property); |
53 | //ignore these ones | 54 | void updateFrameClose(FluxboxWindow &win); |
54 | void updateFrameClose(FluxboxWindow &win) {} | 55 | |
56 | //ignore this one | ||
55 | void updateClientClose(WinClient &winclient) {} | 57 | void updateClientClose(WinClient &winclient) {} |
56 | 58 | ||
59 | void setFullscreen(FluxboxWindow &win, bool value); | ||
60 | |||
57 | private: | 61 | private: |
58 | 62 | ||
63 | typedef struct WindowState { | ||
64 | WindowState(int x, int y, unsigned int width, unsigned int height, int layer, unsigned int decor); | ||
65 | int x, y, layer; | ||
66 | unsigned int width, height, decor; | ||
67 | } WindowState; | ||
68 | |||
59 | enum { STATE_REMOVE = 0, STATE_ADD = 1, STATE_TOGGLE = 2}; | 69 | enum { STATE_REMOVE = 0, STATE_ADD = 1, STATE_TOGGLE = 2}; |
60 | 70 | ||
61 | void setState(FluxboxWindow &win, Atom state, bool value) const; | 71 | void setState(FluxboxWindow &win, Atom state, bool value); |
62 | void toggleState(FluxboxWindow &win, Atom state) const; | 72 | void toggleState(FluxboxWindow &win, Atom state); |
63 | void createAtoms(); | 73 | void createAtoms(); |
64 | void updateStrut(WinClient &winclient); | 74 | void updateStrut(WinClient &winclient); |
65 | 75 | ||
@@ -76,6 +86,7 @@ private: | |||
76 | Atom m_net_properties, m_net_wm_name, m_net_wm_desktop, m_net_wm_window_type, | 86 | Atom m_net_properties, m_net_wm_name, m_net_wm_desktop, m_net_wm_window_type, |
77 | m_net_wm_state, m_net_wm_state_sticky, m_net_wm_state_shaded, | 87 | m_net_wm_state, m_net_wm_state_sticky, m_net_wm_state_shaded, |
78 | m_net_wm_state_maximized_horz, m_net_wm_state_maximized_vert, | 88 | m_net_wm_state_maximized_horz, m_net_wm_state_maximized_vert, |
89 | m_net_wm_state_fullscreen, | ||
79 | m_net_wm_strut, m_net_wm_icon_geometry, m_net_wm_icon, m_net_wm_pid, | 90 | m_net_wm_strut, m_net_wm_icon_geometry, m_net_wm_icon, m_net_wm_pid, |
80 | m_net_wm_handled_icons; | 91 | m_net_wm_handled_icons; |
81 | 92 | ||
@@ -83,4 +94,11 @@ private: | |||
83 | Atom m_net_wm_ping; | 94 | Atom m_net_wm_ping; |
84 | 95 | ||
85 | std::vector<Window> m_windows; | 96 | std::vector<Window> m_windows; |
97 | typedef std::map<FluxboxWindow *, WindowState *> SavedState; | ||
98 | SavedState m_savedstate; | ||
99 | |||
100 | WindowState *getState(FluxboxWindow &win); | ||
101 | void clearState(FluxboxWindow &win); | ||
102 | void saveState(FluxboxWindow &win, WindowState *state); | ||
103 | |||
86 | }; | 104 | }; |
diff --git a/src/Window.cc b/src/Window.cc index 38fe3f5..7c331c1 100644 --- a/src/Window.cc +++ b/src/Window.cc | |||
@@ -22,7 +22,7 @@ | |||
22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
23 | // DEALINGS IN THE SOFTWARE. | 23 | // DEALINGS IN THE SOFTWARE. |
24 | 24 | ||
25 | // $Id: Window.cc,v 1.231 2003/09/16 13:11:42 rathnor Exp $ | 25 | // $Id: Window.cc,v 1.232 2003/09/23 13:52:05 rathnor Exp $ |
26 | 26 | ||
27 | #include "Window.hh" | 27 | #include "Window.hh" |
28 | 28 | ||
@@ -1084,8 +1084,8 @@ void FluxboxWindow::getBlackboxHints() { | |||
1084 | } | 1084 | } |
1085 | } | 1085 | } |
1086 | 1086 | ||
1087 | void FluxboxWindow::move(int x, int y) { | 1087 | void FluxboxWindow::move(int x, int y, int gravity) { |
1088 | moveResize(x, y, frame().width(), frame().height()); | 1088 | moveResize(x, y, frame().width(), frame().height(), gravity); |
1089 | } | 1089 | } |
1090 | 1090 | ||
1091 | void FluxboxWindow::resize(unsigned int width, unsigned int height) { | 1091 | void FluxboxWindow::resize(unsigned int width, unsigned int height) { |
@@ -1093,7 +1093,11 @@ void FluxboxWindow::resize(unsigned int width, unsigned int height) { | |||
1093 | } | 1093 | } |
1094 | 1094 | ||
1095 | void FluxboxWindow::moveResize(int new_x, int new_y, | 1095 | void FluxboxWindow::moveResize(int new_x, int new_y, |
1096 | unsigned int new_width, unsigned int new_height) { | 1096 | unsigned int new_width, unsigned int new_height, int gravity) { |
1097 | |||
1098 | if (gravity != ForgetGravity) { | ||
1099 | frame().gravityTranslate(new_x, new_y, gravity, false); | ||
1100 | } | ||
1097 | 1101 | ||
1098 | bool send_event = (frame().x() != new_x || frame().y() != new_y); | 1102 | bool send_event = (frame().x() != new_x || frame().y() != new_y); |
1099 | 1103 | ||
diff --git a/src/Window.hh b/src/Window.hh index ee0b35e..a07bf66 100644 --- a/src/Window.hh +++ b/src/Window.hh | |||
@@ -22,7 +22,7 @@ | |||
22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
23 | // DEALINGS IN THE SOFTWARE. | 23 | // DEALINGS IN THE SOFTWARE. |
24 | 24 | ||
25 | // $Id: Window.hh,v 1.93 2003/09/12 16:30:21 fluxgen Exp $ | 25 | // $Id: Window.hh,v 1.94 2003/09/23 13:52:05 rathnor Exp $ |
26 | 26 | ||
27 | #ifndef WINDOW_HH | 27 | #ifndef WINDOW_HH |
28 | #define WINDOW_HH | 28 | #define WINDOW_HH |
@@ -206,11 +206,11 @@ public: | |||
206 | void restore(WinClient *client, bool remap); | 206 | void restore(WinClient *client, bool remap); |
207 | void restore(bool remap); | 207 | void restore(bool remap); |
208 | /// move frame to x, y | 208 | /// move frame to x, y |
209 | void move(int x, int y); | 209 | void move(int x, int y, int gravity = ForgetGravity); |
210 | /// resize frame to width, height | 210 | /// resize frame to width, height |
211 | void resize(unsigned int width, unsigned int height); | 211 | void resize(unsigned int width, unsigned int height); |
212 | /// move and resize frame to pox x,y and size width, height | 212 | /// move and resize frame to pox x,y and size width, height |
213 | void moveResize(int x, int y, unsigned int width, unsigned int height); | 213 | void moveResize(int x, int y, unsigned int width, unsigned int height, int gravity = ForgetGravity); |
214 | 214 | ||
215 | void setWorkspace(int n); | 215 | void setWorkspace(int n); |
216 | void changeBlackboxHints(const BlackboxHints &bh); | 216 | void changeBlackboxHints(const BlackboxHints &bh); |