summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vncviewer/DesktopWindow.cxx44
-rw-r--r--vncviewer/DesktopWindow.h2
-rw-r--r--vncviewer/parameters.cxx1
-rw-r--r--vncviewer/parameters.h1
-rw-r--r--vncviewer/vncviewer.man4
5 files changed, 52 insertions, 0 deletions
diff --git a/vncviewer/DesktopWindow.cxx b/vncviewer/DesktopWindow.cxx
index 0431e04b..89398ba9 100644
--- a/vncviewer/DesktopWindow.cxx
+++ b/vncviewer/DesktopWindow.cxx
@@ -90,6 +90,13 @@ DesktopWindow::DesktopWindow(int w, int h, const char *name,
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 @@ void DesktopWindow::handleGrab(void *data)
}
+#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;
diff --git a/vncviewer/DesktopWindow.h b/vncviewer/DesktopWindow.h
index 2a4613c7..6008d067 100644
--- a/vncviewer/DesktopWindow.h
+++ b/vncviewer/DesktopWindow.h
@@ -88,6 +88,8 @@ private:
static void handleGrab(void *data);
+ void maximizeWindow();
+
static void handleResizeTimeout(void *data);
void remoteResize();
diff --git a/vncviewer/parameters.cxx b/vncviewer/parameters.cxx
index 22fa1ac5..7b60b621 100644
--- a/vncviewer/parameters.cxx
+++ b/vncviewer/parameters.cxx
@@ -64,6 +64,7 @@ IntParameter qualityLevel("QualityLevel",
"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
diff --git a/vncviewer/parameters.h b/vncviewer/parameters.h
index 59909d11..5a9170eb 100644
--- a/vncviewer/parameters.h
+++ b/vncviewer/parameters.h
@@ -39,6 +39,7 @@ extern rfb::IntParameter qualityLevel;
#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
diff --git a/vncviewer/vncviewer.man b/vncviewer/vncviewer.man
index 9a0c864c..f8796da9 100644
--- a/vncviewer/vncviewer.man
+++ b/vncviewer/vncviewer.man
@@ -132,6 +132,10 @@ combined with
.B \-Shared.
.TP
+.B \-Maximize
+Maximize viewer window.
+
+.TP
.B \-FullScreen
Start in full-screen mode.