Toolbar handling restored.

git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/branches/merge-with-vnc-4.1.1@556 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/vncviewer/CConn.cxx b/vncviewer/CConn.cxx
index 2d90730..d141e50 100644
--- a/vncviewer/CConn.cxx
+++ b/vncviewer/CConn.cxx
@@ -177,10 +177,8 @@
     window->setFullscreen(options.fullScreen);
     return true;
   case IDM_SHOW_TOOLBAR:
-    options.showToolbar = !options.showToolbar;
+    options.showToolbar = !window->isToolbarEnabled();
     window->setShowToolbar(options.showToolbar);
-    // FIXME: Update menu in DesktopWindow?
-    // FIXME: Actually show or hide the toolbar?
     return true;
   case IDM_CTRL_KEY:
     window->kbd.keyEvent(this, VK_CONTROL, 0, !window->kbd.keyPressed(VK_CONTROL));
@@ -283,8 +281,12 @@
   // Set the menu fullscreen option tick
   CheckMenuItem(menu, IDM_FULLSCREEN, (window->isFullscreen() ? MF_CHECKED : 0) | MF_BYCOMMAND);
 
+  // Set the menu toolbar option tick
+  int toolbarFlags = window->isToolbarEnabled() ? MF_CHECKED : 0;
+  CheckMenuItem(menu, IDM_SHOW_TOOLBAR, MF_BYCOMMAND | toolbarFlags);
+
   // In the full-screen mode, "Show toolbar" should be grayed.
-  int toolbarFlags = options.fullScreen ? MF_GRAYED : MF_ENABLED;
+  toolbarFlags = window->isFullscreen() ? MF_GRAYED : MF_ENABLED;
   EnableMenuItem(menu, IDM_SHOW_TOOLBAR, MF_BYCOMMAND | toolbarFlags);
 }
 
diff --git a/vncviewer/DesktopWindow.cxx b/vncviewer/DesktopWindow.cxx
index acddf45..47ddf7d 100644
--- a/vncviewer/DesktopWindow.cxx
+++ b/vncviewer/DesktopWindow.cxx
@@ -177,7 +177,7 @@
 
 DesktopWindow::DesktopWindow(Callback* cb) 
   : buffer(0),
-    showToolbar(true),
+    showToolbar(false),
     client_size(0, 0, 16, 16), window_size(0, 0, 32, 32),
     cursorVisible(false), cursorAvailable(false), cursorInBuffer(false),
     systemCursorVisible(true), trackingMouseLeave(false),
@@ -255,7 +255,7 @@
     MonitorInfo mi(handle);
 
     // Hide the toolbar
-    if (showToolbar)
+    if (tb.isVisible())
       tb.hide();
     SetWindowLong(frameHandle, GWL_EXSTYLE, 0);
 
@@ -294,6 +294,17 @@
   setViewportOffset(scrolloffset);
 }
 
+void DesktopWindow::setShowToolbar(bool st)
+{
+  showToolbar = st;
+
+  if (showToolbar && !tb.isVisible()) {
+    tb.show();
+  } else if (!showToolbar && tb.isVisible()) {
+    tb.hide();
+  }
+}
+
 void DesktopWindow::setDisableWinKeys(bool dwk) {
   // Enable low-level event hooking, so we get special keys directly
   if (dwk)
diff --git a/vncviewer/DesktopWindow.h b/vncviewer/DesktopWindow.h
index dd1bcdc..d54cd5f 100644
--- a/vncviewer/DesktopWindow.h
+++ b/vncviewer/DesktopWindow.h
@@ -87,14 +87,14 @@
       void setCursor(int w, int h, const Point& hotspot, void* data, void* mask);
       void showCursor() { showLocalCursor(); }
 
-      // - Set whether to show the toolbar
-      // FIXME: Actually show/hide the toolbar.
-      void setShowToolbar(bool st) { showToolbar = st; }
-
       // - Set the window fullscreen / determine whether it is fullscreen
       void setFullscreen(bool fs);
       bool isFullscreen() { return fullscreenActive; }
 
+      // - Set/get the toolbar's state
+      void setShowToolbar(bool st);
+      bool isToolbarEnabled() { return showToolbar; }
+
       // - Set whether to disable special Windows keys & pass them straight to server
       void setDisableWinKeys(bool dwk);