Revision: 4949
          http://tigervnc.svn.sourceforge.net/tigervnc/?rev=4949&view=rev
Author:   astrand
Date:     2012-08-01 08:09:09 +0000 (Wed, 01 Aug 2012)
Log Message:
-----------
Added new option "-Maximize", for maximizing the window at startup.

Modified Paths:
--------------
    trunk/vncviewer/DesktopWindow.cxx
    trunk/vncviewer/DesktopWindow.h
    trunk/vncviewer/parameters.cxx
    trunk/vncviewer/parameters.h
    trunk/vncviewer/vncviewer.man

Modified: trunk/vncviewer/DesktopWindow.cxx
===================================================================
--- trunk/vncviewer/DesktopWindow.cxx   2012-07-22 20:25:57 UTC (rev 4948)
+++ trunk/vncviewer/DesktopWindow.cxx   2012-08-01 08:09:09 UTC (rev 4949)
@@ -90,6 +90,13 @@
 
   show();
 
+  // Unfortunately, current FLTK does not allow us to set the
+  // maximized property before showing the window. See STR #2083 and
+  // STR #2178
+  if (maximize) {
+    maximizeWindow();
+  }
+
   // The window manager might give us an initial window size that is different
   // than the one we requested, and in those cases we need to manually adjust
   // the scroll widget for things to behave sanely.
@@ -428,6 +435,43 @@
 }
 
 
+#define _NET_WM_STATE_ADD           1  /* add/set property */
+void DesktopWindow::maximizeWindow()
+{
+#if defined(WIN32)
+  WINDOWPLACEMENT wp;
+  wp.length = sizeof(WINDOWPLACEMENT);
+  GetWindowPlacement(fl_xid(this), &wp);
+  wp.showCmd = SW_MAXIMIZE;
+  SetWindowPlacement(fl_xid(this), &wp);
+#elif defined(__APPLE__)
+  /* OS X is somewhat strange and does not really have a concept of a
+     maximized window, so we can simply resize the window to the workarea */
+  int X, Y, W, H;
+  Fl::screen_work_area(X, Y, W, H, this->x(), this->y());
+  size(W, H);
+#else
+  // X11
+  fl_open_display();
+  Atom net_wm_state = XInternAtom (fl_display, "_NET_WM_STATE", 0);
+  Atom net_wm_state_maximized_vert = XInternAtom (fl_display, 
"_NET_WM_STATE_MAXIMIZED_VERT", 0);
+  Atom net_wm_state_maximized_horz = XInternAtom (fl_display, 
"_NET_WM_STATE_MAXIMIZED_HORZ", 0);
+
+  XEvent e;
+  e.xany.type = ClientMessage;
+  e.xany.window = fl_xid(this);
+  e.xclient.message_type = net_wm_state;
+  e.xclient.format = 32;
+  e.xclient.data.l[0] = _NET_WM_STATE_ADD;
+  e.xclient.data.l[1] = net_wm_state_maximized_vert;
+  e.xclient.data.l[2] = net_wm_state_maximized_horz;
+  e.xclient.data.l[3] = 0;
+  e.xclient.data.l[4] = 0;
+  XSendEvent(fl_display, RootWindow(fl_display, fl_screen), 0, 
SubstructureNotifyMask | SubstructureRedirectMask, &e);
+#endif
+}
+
+
 void DesktopWindow::handleResizeTimeout(void *data)
 {
   DesktopWindow *self = (DesktopWindow *)data;

Modified: trunk/vncviewer/DesktopWindow.h
===================================================================
--- trunk/vncviewer/DesktopWindow.h     2012-07-22 20:25:57 UTC (rev 4948)
+++ trunk/vncviewer/DesktopWindow.h     2012-08-01 08:09:09 UTC (rev 4949)
@@ -88,6 +88,8 @@
 
   static void handleGrab(void *data);
 
+  void maximizeWindow();
+
   static void handleResizeTimeout(void *data);
   void remoteResize();
 

Modified: trunk/vncviewer/parameters.cxx
===================================================================
--- trunk/vncviewer/parameters.cxx      2012-07-22 20:25:57 UTC (rev 4948)
+++ trunk/vncviewer/parameters.cxx      2012-08-01 08:09:09 UTC (rev 4949)
@@ -64,6 +64,7 @@
                           "JPEG quality level. 0 = Low, 9 = High",
                           8);
 
+BoolParameter maximize("Maximize", "Maximize viewer window", false);
 #ifdef HAVE_FLTK_FULLSCREEN
 BoolParameter fullScreen("FullScreen", "Full screen mode", false);
 #ifdef HAVE_FLTK_FULLSCREEN_SCREENS

Modified: trunk/vncviewer/parameters.h
===================================================================
--- trunk/vncviewer/parameters.h        2012-07-22 20:25:57 UTC (rev 4948)
+++ trunk/vncviewer/parameters.h        2012-08-01 08:09:09 UTC (rev 4949)
@@ -39,6 +39,7 @@
 
 #ifdef HAVE_FLTK_FULLSCREEN
 extern rfb::BoolParameter fullScreen;
+extern rfb::BoolParameter maximize;
 #ifdef HAVE_FLTK_FULLSCREEN_SCREENS
 extern rfb::BoolParameter fullScreenAllMonitors;
 #endif // HAVE_FLTK_FULLSCREEN_SCREENS

Modified: trunk/vncviewer/vncviewer.man
===================================================================
--- trunk/vncviewer/vncviewer.man       2012-07-22 20:25:57 UTC (rev 4948)
+++ trunk/vncviewer/vncviewer.man       2012-08-01 08:09:09 UTC (rev 4949)
@@ -132,6 +132,10 @@
 .B \-Shared.
 
 .TP
+.B \-Maximize
+Maximize viewer window. 
+
+.TP
 .B \-FullScreen
 Start in full-screen mode.
 

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Tigervnc-commits mailing list
Tigervnc-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tigervnc-commits

Reply via email to