patch for NET_WM_STATE_FULLSCREEN support in openbox 2.3

Arwed von Merkatz v.merkatz at gmx.net
Sat Mar 15 15:11:03 EST 2003


Hi,
openbox 2.3.0 claims to support NET_WM_STATE_FULLSCREEN, but to really
support it, it should resize windows setting that hint to fullscreen and
remove decorations.
The wm spec on freedesktop.org doesn't state this clearly, but that's
how metactiy, sawfish and kwin implement it.

The attached patch adds this functionality to openbox 2.3



Arwed v. Merkatz
Grimoire Guru for video
Sourcemage GNU/Linux
http://www.sourcemage.org
-------------- next part --------------
Index: src/Window.cc
===================================================================
RCS file: /cvs/cvsroot/openbox/src/Attic/Window.cc,v
retrieving revision 1.183.2.9
diff -p -u -r1.183.2.9 Window.cc
--- src/Window.cc	2003/02/03 01:31:46	1.183.2.9
+++ src/Window.cc	2003/03/15 19:48:19
@@ -337,6 +337,8 @@ BlackboxWindow::BlackboxWindow(Blackbox 
 
   if (flags.maximized && (functions & Func_Maximize))
     remaximize();
+  if (flags.fullscreen)
+    doFullscreen();
 
   // create this last so it only needs to be configured once
   windowmenu = new Windowmenu(this);
@@ -2077,6 +2079,38 @@ void BlackboxWindow::remaximize(void) {
   blackbox_attrib.premax_h = premax_h;
 }
 
+
+void BlackboxWindow::doFullscreen(void) {
+  if (flags.fullscreen) {
+    // save current size/position (can i use the premax variables???)
+    blackbox_attrib.prefull_x = frame.rect.x();
+    blackbox_attrib.prefull_y = frame.rect.y();
+    blackbox_attrib.prefull_w = frame.rect.width();
+    blackbox_attrib.prefull_h =
+      client.rect.height() + frame.margin.top + frame.margin.bottom;
+    // go fullscreen
+    client.rect = screen->getRect();
+    frame.rect = screen->getRect();
+    configure(frame.rect.x(), frame.rect.y(),
+              frame.rect.width(), frame.rect.height());
+    // disbale decorations
+    enableDecor(False);
+    screen->getWorkspace(blackbox_attrib.workspace)->raiseWindow(this);
+    // disable functions, save old functions
+    blackbox_attrib.prefull_functions = functions;
+    functions = 0;
+  } else {
+    // reenable functions
+    functions = blackbox_attrib.prefull_functions;
+    // reenable decorations
+    enableDecor(True);
+    // restore size
+    configure(blackbox_attrib.prefull_x, blackbox_attrib.prefull_y,
+              blackbox_attrib.prefull_w, blackbox_attrib.prefull_h);
+    blackbox_attrib.prefull_x = blackbox_attrib.prefull_y = 0;
+    blackbox_attrib.prefull_w = blackbox_attrib.prefull_h = 0;
+  }
+}
 
 void BlackboxWindow::setWorkspace(unsigned int n) {
   blackbox_attrib.flags |= AttribWorkspace;
Index: src/Window.hh
===================================================================
RCS file: /cvs/cvsroot/openbox/src/Attic/Window.hh,v
retrieving revision 1.27.2.1
diff -p -u -r1.27.2.1 Window.hh
--- src/Window.hh	2003/01/11 20:37:50	1.27.2.1
+++ src/Window.hh	2003/03/15 19:48:20
@@ -400,6 +400,7 @@ public:
   void withdraw(void);
   void maximize(unsigned int button);
   void remaximize(void);
+  void doFullscreen(void);
   void shade(void);
   void stick(void);
   void reconfigure(void);
Index: src/blackbox.cc
===================================================================
RCS file: /cvs/cvsroot/openbox/src/Attic/blackbox.cc,v
retrieving revision 1.42
diff -p -u -r1.42 blackbox.cc
--- src/blackbox.cc	2002/08/27 08:18:04	1.42
+++ src/blackbox.cc	2003/03/15 19:48:24
@@ -827,6 +827,7 @@ void Blackbox::process_event(XEvent *e) 
               } else if (state[i] ==
                          xatom->getAtom(XAtom::net_wm_state_fullscreen)) {
                 win->setFullscreen(True);
+                win->doFullscreen();
               }
             } else if (action == 0) {
               // REMOVE
@@ -861,6 +862,7 @@ void Blackbox::process_event(XEvent *e) 
               } else if (state[i] ==
                          xatom->getAtom(XAtom::net_wm_state_fullscreen)) {
                 win->setFullscreen(False);
+                win->doFullscreen();
               }
             } else if (action == 2) {
               // TOGGLE
@@ -904,6 +906,7 @@ void Blackbox::process_event(XEvent *e) 
               } else if (state[i] ==
                          xatom->getAtom(XAtom::net_wm_state_fullscreen)) {
                 win->setFullscreen(! win->isFullscreen());
+                win->doFullscreen();
               }
             }
           }
Index: src/blackbox.hh
===================================================================
RCS file: /cvs/cvsroot/openbox/src/Attic/blackbox.hh,v
retrieving revision 1.15
diff -p -u -r1.15 blackbox.hh
--- src/blackbox.hh	2002/08/10 18:21:10	1.15
+++ src/blackbox.hh	2003/03/15 19:48:24
@@ -78,6 +78,9 @@ struct BlackboxAttributes {
   unsigned long flags, attrib, workspace, stack, decoration;
   int premax_x, premax_y;
   unsigned int premax_w, premax_h;
+  unsigned char prefull_functions;
+  int prefull_x, prefull_y;
+  unsigned int prefull_w, prefull_h;
 };
 
 #define PropBlackboxHintsElements      (5)


More information about the openbox mailing list