Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 1 | /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. |
| 2 | * Copyright 2011 Pierre Ossman <ossman@cendio.se> for Cendio AB |
| 3 | * |
| 4 | * This is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; either version 2 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This software is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this software; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
| 17 | * USA. |
| 18 | */ |
| 19 | |
Peter Åstrand | c359f36 | 2011-08-23 12:04:46 +0000 | [diff] [blame] | 20 | #ifdef HAVE_CONFIG_H |
| 21 | #include <config.h> |
| 22 | #endif |
| 23 | |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 24 | #include <assert.h> |
| 25 | #include <stdio.h> |
| 26 | #include <string.h> |
| 27 | |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 28 | #include <rfb/LogWriter.h> |
| 29 | |
| 30 | #include "DesktopWindow.h" |
Pierre Ossman | 407a5c3 | 2011-05-26 14:48:29 +0000 | [diff] [blame] | 31 | #include "OptionsDialog.h" |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 32 | #include "i18n.h" |
Pierre Ossman | 407a5c3 | 2011-05-26 14:48:29 +0000 | [diff] [blame] | 33 | #include "parameters.h" |
Pierre Ossman | 39ceb50 | 2011-07-12 15:54:25 +0000 | [diff] [blame] | 34 | #include "vncviewer.h" |
Pierre Ossman | 407a5c3 | 2011-05-26 14:48:29 +0000 | [diff] [blame] | 35 | |
DRC | b65bb93 | 2011-06-24 03:17:00 +0000 | [diff] [blame] | 36 | #include <FL/Fl_Scroll.H> |
| 37 | #include <FL/x.H> |
| 38 | |
Pierre Ossman | 407a5c3 | 2011-05-26 14:48:29 +0000 | [diff] [blame] | 39 | #ifdef WIN32 |
| 40 | #include "win32.h" |
| 41 | #endif |
| 42 | |
| 43 | #ifdef __APPLE__ |
| 44 | #include "cocoa.h" |
| 45 | #endif |
Pierre Ossman | 89f868a | 2011-04-11 11:59:31 +0000 | [diff] [blame] | 46 | |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 47 | using namespace rfb; |
| 48 | |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 49 | static rfb::LogWriter vlog("DesktopWindow"); |
| 50 | |
| 51 | DesktopWindow::DesktopWindow(int w, int h, const char *name, |
| 52 | const rfb::PixelFormat& serverPF, |
| 53 | CConn* cc_) |
Pierre Ossman | d50b3d1 | 2011-04-15 07:46:56 +0000 | [diff] [blame] | 54 | : Fl_Window(w, h) |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 55 | { |
Pierre Ossman | 4ae229f | 2011-04-15 12:58:31 +0000 | [diff] [blame] | 56 | // Allow resize |
Pierre Ossman | 343e2e0 | 2011-04-15 13:00:12 +0000 | [diff] [blame] | 57 | size_range(100, 100, w, h); |
Pierre Ossman | 4ae229f | 2011-04-15 12:58:31 +0000 | [diff] [blame] | 58 | |
| 59 | Fl_Scroll *scroll = new Fl_Scroll(0, 0, w, h); |
| 60 | scroll->color(FL_BLACK); |
| 61 | |
| 62 | // Automatically adjust the scroll box to the window |
| 63 | resizable(scroll); |
| 64 | |
Pierre Ossman | d50b3d1 | 2011-04-15 07:46:56 +0000 | [diff] [blame] | 65 | viewport = new Viewport(w, h, serverPF, cc_); |
| 66 | |
Pierre Ossman | 4ae229f | 2011-04-15 12:58:31 +0000 | [diff] [blame] | 67 | scroll->end(); |
| 68 | |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 69 | callback(handleClose, this); |
| 70 | |
| 71 | setName(name); |
| 72 | |
Pierre Ossman | 407a5c3 | 2011-05-26 14:48:29 +0000 | [diff] [blame] | 73 | OptionsDialog::addCallback(handleOptions, this); |
| 74 | |
Pierre Ossman | a4f0f18 | 2011-06-14 13:36:57 +0000 | [diff] [blame] | 75 | // Hack. See below... |
| 76 | Fl::event_dispatch(&fltkHandle); |
| 77 | |
Pierre Ossman | 63ca58e | 2011-05-26 14:59:32 +0000 | [diff] [blame] | 78 | #ifdef HAVE_FLTK_FULLSCREEN |
Peter Åstrand | 17067b1 | 2011-07-18 07:45:14 +0000 | [diff] [blame] | 79 | if (fullScreen) { |
| 80 | // See comment in DesktopWindow::handleOptions |
| 81 | size_range(100, 100, 0, 0); |
Pierre Ossman | 63ca58e | 2011-05-26 14:59:32 +0000 | [diff] [blame] | 82 | fullscreen(); |
Peter Åstrand | d62482e | 2011-08-02 08:33:27 +0000 | [diff] [blame] | 83 | } else |
Pierre Ossman | 63ca58e | 2011-05-26 14:59:32 +0000 | [diff] [blame] | 84 | #endif |
Peter Åstrand | d62482e | 2011-08-02 08:33:27 +0000 | [diff] [blame] | 85 | { |
| 86 | // If we are creating a window which is equal to the size on the |
| 87 | // screen on X11, many WMs will treat this as a legacy fullscreen |
| 88 | // request. This is not what we want. Besides, it doesn't really |
| 89 | // make sense to try to create a window which is larger than the |
| 90 | // available work space. |
| 91 | size(__rfbmin(w, Fl::w()), __rfbmin(h, Fl::h())); |
| 92 | } |
Pierre Ossman | 63ca58e | 2011-05-26 14:59:32 +0000 | [diff] [blame] | 93 | |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 94 | show(); |
Pierre Ossman | 3f6c4d0 | 2011-04-15 14:09:09 +0000 | [diff] [blame] | 95 | |
| 96 | // The window manager might give us an initial window size that is different |
| 97 | // than the one we requested, and in those cases we need to manually adjust |
| 98 | // the scroll widget for things to behave sanely. |
| 99 | if ((w != this->w()) || (h != this->h())) |
| 100 | scroll->size(this->w(), this->h()); |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | |
| 104 | DesktopWindow::~DesktopWindow() |
| 105 | { |
Pierre Ossman | 407a5c3 | 2011-05-26 14:48:29 +0000 | [diff] [blame] | 106 | // Unregister all timeouts in case they get a change tro trigger |
| 107 | // again later when this object is already gone. |
| 108 | Fl::remove_timeout(handleGrab, this); |
| 109 | |
| 110 | OptionsDialog::removeCallback(handleOptions); |
| 111 | |
Pierre Ossman | d50b3d1 | 2011-04-15 07:46:56 +0000 | [diff] [blame] | 112 | // FLTK automatically deletes all child widgets, so we shouldn't touch |
| 113 | // them ourselves here |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | |
| 117 | void DesktopWindow::setServerPF(const rfb::PixelFormat& pf) |
| 118 | { |
Pierre Ossman | d50b3d1 | 2011-04-15 07:46:56 +0000 | [diff] [blame] | 119 | viewport->setServerPF(pf); |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 120 | } |
| 121 | |
| 122 | |
| 123 | const rfb::PixelFormat &DesktopWindow::getPreferredPF() |
| 124 | { |
Pierre Ossman | d50b3d1 | 2011-04-15 07:46:56 +0000 | [diff] [blame] | 125 | return viewport->getPreferredPF(); |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 126 | } |
| 127 | |
| 128 | |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 129 | void DesktopWindow::setName(const char *name) |
| 130 | { |
| 131 | CharArray windowNameStr; |
| 132 | windowNameStr.replaceBuf(new char[256]); |
| 133 | |
Pierre Ossman | 27820ba | 2011-09-30 12:54:24 +0000 | [diff] [blame^] | 134 | snprintf(windowNameStr.buf, 256, "%.240s - TigerVNC", name); |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 135 | |
| 136 | copy_label(windowNameStr.buf); |
| 137 | } |
| 138 | |
Pierre Ossman | d50b3d1 | 2011-04-15 07:46:56 +0000 | [diff] [blame] | 139 | |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 140 | void DesktopWindow::setColourMapEntries(int firstColour, int nColours, |
| 141 | rdr::U16* rgbs) |
| 142 | { |
Pierre Ossman | d50b3d1 | 2011-04-15 07:46:56 +0000 | [diff] [blame] | 143 | viewport->setColourMapEntries(firstColour, nColours, rgbs); |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | |
| 147 | // Copy the areas of the framebuffer that have been changed (damaged) |
| 148 | // to the displayed window. |
| 149 | |
| 150 | void DesktopWindow::updateWindow() |
| 151 | { |
Pierre Ossman | d50b3d1 | 2011-04-15 07:46:56 +0000 | [diff] [blame] | 152 | viewport->updateWindow(); |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | |
Pierre Ossman | 6455d85 | 2011-06-01 09:33:00 +0000 | [diff] [blame] | 156 | void DesktopWindow::resizeFramebuffer(int new_w, int new_h) |
| 157 | { |
| 158 | if ((new_w == viewport->w()) && (new_h == viewport->h())) |
| 159 | return; |
| 160 | |
| 161 | // Turn off size limitations for a bit while we juggle things around |
| 162 | size_range(100, 100, 0, 0); |
| 163 | |
| 164 | // If we're letting the viewport match the window perfectly, then |
| 165 | // keep things that way for the new size, otherwise just keep things |
| 166 | // like they are. |
Peter Åstrand | 1d03cbc | 2011-08-01 10:34:38 +0000 | [diff] [blame] | 167 | #ifdef HAVE_FLTK_FULLSCREEN |
| 168 | if (!fullscreen_active()) { |
| 169 | #endif |
Pierre Ossman | 6455d85 | 2011-06-01 09:33:00 +0000 | [diff] [blame] | 170 | if ((w() == viewport->w()) && (h() == viewport->h())) |
| 171 | size(new_w, new_h); |
| 172 | else { |
Pierre Ossman | 6455d85 | 2011-06-01 09:33:00 +0000 | [diff] [blame] | 173 | // Make sure the window isn't too big |
| 174 | if ((w() > new_w) || (h() > new_h)) |
| 175 | size(__rfbmin(w(), new_w), __rfbmin(h(), new_h)); |
Pierre Ossman | 6455d85 | 2011-06-01 09:33:00 +0000 | [diff] [blame] | 176 | } |
Peter Åstrand | 1d03cbc | 2011-08-01 10:34:38 +0000 | [diff] [blame] | 177 | #ifdef HAVE_FLTK_FULLSCREEN |
| 178 | } |
| 179 | #endif |
Pierre Ossman | 6455d85 | 2011-06-01 09:33:00 +0000 | [diff] [blame] | 180 | |
| 181 | viewport->size(new_w, new_h); |
| 182 | |
| 183 | // We might not resize the main window, so we need to manually call this |
| 184 | // to make sure the viewport is centered. |
| 185 | repositionViewport(); |
| 186 | |
| 187 | // Update allowed resize range |
Peter Åstrand | adf5e25 | 2011-07-19 09:28:39 +0000 | [diff] [blame] | 188 | #ifdef HAVE_FLTK_FULLSCREEN |
| 189 | if (!fullscreen_active()) |
| 190 | #endif |
Pierre Ossman | 6455d85 | 2011-06-01 09:33:00 +0000 | [diff] [blame] | 191 | size_range(100, 100, new_w, new_h); |
| 192 | |
| 193 | // repositionViewport() makes sure the scroll widget notices any changes |
| 194 | // in position, but it might be just the size that changes so we also |
| 195 | // need a poke here as well. |
| 196 | redraw(); |
| 197 | } |
| 198 | |
| 199 | |
Pierre Ossman | 835b4ef | 2011-06-08 17:02:36 +0000 | [diff] [blame] | 200 | void DesktopWindow::setCursor(int width, int height, const Point& hotspot, |
| 201 | void* data, void* mask) |
| 202 | { |
| 203 | viewport->setCursor(width, height, hotspot, data, mask); |
| 204 | } |
| 205 | |
| 206 | |
Pierre Ossman | 4ae229f | 2011-04-15 12:58:31 +0000 | [diff] [blame] | 207 | void DesktopWindow::resize(int x, int y, int w, int h) |
| 208 | { |
Pierre Ossman | 4ae229f | 2011-04-15 12:58:31 +0000 | [diff] [blame] | 209 | Fl_Window::resize(x, y, w, h); |
Pierre Ossman | 6455d85 | 2011-06-01 09:33:00 +0000 | [diff] [blame] | 210 | |
| 211 | // Deal with some scrolling corner cases |
| 212 | repositionViewport(); |
Pierre Ossman | 4ae229f | 2011-04-15 12:58:31 +0000 | [diff] [blame] | 213 | } |
| 214 | |
| 215 | |
Pierre Ossman | 407a5c3 | 2011-05-26 14:48:29 +0000 | [diff] [blame] | 216 | int DesktopWindow::handle(int event) |
| 217 | { |
| 218 | switch (event) { |
| 219 | #ifdef HAVE_FLTK_FULLSCREEN |
Pierre Ossman | 407a5c3 | 2011-05-26 14:48:29 +0000 | [diff] [blame] | 220 | case FL_FULLSCREEN: |
Peter Åstrand | 17067b1 | 2011-07-18 07:45:14 +0000 | [diff] [blame] | 221 | if (event == FL_FULLSCREEN) { |
Pierre Ossman | 105738c | 2011-05-26 14:57:25 +0000 | [diff] [blame] | 222 | fullScreen.setParam(fullscreen_active()); |
Peter Åstrand | 17067b1 | 2011-07-18 07:45:14 +0000 | [diff] [blame] | 223 | if (!fullscreen_active()) { |
| 224 | size_range(100, 100, viewport->w(), viewport->h()); |
Peter Åstrand | 1d03cbc | 2011-08-01 10:34:38 +0000 | [diff] [blame] | 225 | size(viewport->w(), viewport->h()); |
Peter Åstrand | 17067b1 | 2011-07-18 07:45:14 +0000 | [diff] [blame] | 226 | } else { |
| 227 | // We need to turn off the size limitations for proper |
| 228 | // fullscreen support, but in case fullscreen is activated via |
| 229 | // the WM, this is a bit of a problem. In practice, it seems to |
| 230 | // work to change the size limits after we have recieved the |
| 231 | // FL_FULLSCREEN event, at least with my Metacity. |
| 232 | size_range(100, 100, 0, 0); |
| 233 | } |
| 234 | } |
Pierre Ossman | 1870ab1 | 2011-05-26 14:53:49 +0000 | [diff] [blame] | 235 | |
Pierre Ossman | 407a5c3 | 2011-05-26 14:48:29 +0000 | [diff] [blame] | 236 | if (!fullscreenSystemKeys) |
| 237 | break; |
| 238 | |
| 239 | if (fullscreen_active()) |
| 240 | grabKeyboard(); |
| 241 | else |
| 242 | ungrabKeyboard(); |
| 243 | |
| 244 | break; |
Pierre Ossman | 407a5c3 | 2011-05-26 14:48:29 +0000 | [diff] [blame] | 245 | #endif |
| 246 | case FL_SHORTCUT: |
| 247 | // Sometimes the focus gets out of whack and we fall through to the |
| 248 | // shortcut dispatching. Try to make things sane again... |
| 249 | if (Fl::focus() == NULL) { |
| 250 | take_focus(); |
| 251 | Fl::handle(FL_KEYDOWN, this); |
| 252 | } |
| 253 | return 1; |
| 254 | } |
| 255 | |
| 256 | return Fl_Window::handle(event); |
| 257 | } |
| 258 | |
| 259 | |
Pierre Ossman | a4f0f18 | 2011-06-14 13:36:57 +0000 | [diff] [blame] | 260 | int DesktopWindow::fltkHandle(int event, Fl_Window *win) |
| 261 | { |
| 262 | int ret; |
| 263 | |
| 264 | ret = Fl::handle_(event, win); |
| 265 | |
| 266 | #ifdef HAVE_FLTK_FULLSCREEN |
| 267 | // This is hackish and the result of the dodgy focus handling in FLTK. |
| 268 | // The basic problem is that FLTK's view of focus and the system's tend |
| 269 | // to differ, and as a result we do not see all the FL_FOCUS events we |
| 270 | // need. Fortunately we can grab them here... |
| 271 | |
| 272 | DesktopWindow *dw = dynamic_cast<DesktopWindow*>(win); |
| 273 | |
| 274 | if (dw && fullscreenSystemKeys) { |
| 275 | switch (event) { |
| 276 | case FL_FOCUS: |
| 277 | // FIXME: We reassert the keyboard grabbing on focus as FLTK there are |
| 278 | // some issues we need to work around: |
| 279 | // a) Fl::grab(0) on X11 will release the keyboard grab for us. |
| 280 | // b) Gaining focus on the system level causes FLTK to switch |
| 281 | // window level on OS X. |
| 282 | if (dw->fullscreen_active()) |
| 283 | dw->grabKeyboard(); |
| 284 | break; |
| 285 | |
| 286 | case FL_UNFOCUS: |
| 287 | // FIXME: We need to relinquish control when the entire window loses |
| 288 | // focus as it is very tied to this specific window on some |
| 289 | // platforms and we want to be able to open subwindows. |
| 290 | dw->ungrabKeyboard(); |
| 291 | break; |
| 292 | } |
| 293 | } |
| 294 | #endif |
| 295 | |
| 296 | return ret; |
| 297 | } |
| 298 | |
| 299 | |
Pierre Ossman | 407a5c3 | 2011-05-26 14:48:29 +0000 | [diff] [blame] | 300 | void DesktopWindow::grabKeyboard() |
| 301 | { |
| 302 | // Grabbing the keyboard is fairly safe as FLTK reroutes events to the |
| 303 | // correct widget regardless of which low level window got the system |
| 304 | // event. |
| 305 | |
| 306 | // FIXME: Push this stuff into FLTK. |
| 307 | |
| 308 | #if defined(WIN32) |
| 309 | int ret; |
| 310 | |
| 311 | ret = win32_enable_lowlevel_keyboard(fl_xid(this)); |
| 312 | if (ret != 0) |
| 313 | vlog.error(_("Failure grabbing keyboard")); |
| 314 | #elif defined(__APPLE__) |
| 315 | int ret; |
| 316 | |
| 317 | ret = cocoa_capture_display(this); |
| 318 | if (ret != 0) |
| 319 | vlog.error(_("Failure grabbing keyboard")); |
| 320 | #else |
| 321 | int ret; |
| 322 | |
| 323 | ret = XGrabKeyboard(fl_display, fl_xid(this), True, |
Peter Åstrand | f52860b | 2011-07-18 07:42:16 +0000 | [diff] [blame] | 324 | GrabModeAsync, GrabModeAsync, CurrentTime); |
Pierre Ossman | 407a5c3 | 2011-05-26 14:48:29 +0000 | [diff] [blame] | 325 | if (ret) { |
| 326 | if (ret == AlreadyGrabbed) { |
| 327 | // It seems like we can race with the WM in some cases. |
| 328 | // Try again in a bit. |
| 329 | if (!Fl::has_timeout(handleGrab, this)) |
| 330 | Fl::add_timeout(0.500, handleGrab, this); |
| 331 | } else { |
| 332 | vlog.error(_("Failure grabbing keyboard")); |
| 333 | } |
| 334 | } |
| 335 | #endif |
| 336 | } |
| 337 | |
| 338 | |
| 339 | void DesktopWindow::ungrabKeyboard() |
| 340 | { |
| 341 | Fl::remove_timeout(handleGrab, this); |
| 342 | |
| 343 | #if defined(WIN32) |
| 344 | win32_disable_lowlevel_keyboard(fl_xid(this)); |
| 345 | #elif defined(__APPLE__) |
| 346 | cocoa_release_display(this); |
| 347 | #else |
| 348 | // FLTK has a grab so lets not mess with it |
| 349 | if (Fl::grab()) |
| 350 | return; |
| 351 | |
| 352 | XUngrabKeyboard(fl_display, fl_event_time); |
| 353 | #endif |
| 354 | } |
| 355 | |
| 356 | |
| 357 | void DesktopWindow::handleGrab(void *data) |
| 358 | { |
| 359 | DesktopWindow *self = (DesktopWindow*)data; |
| 360 | |
| 361 | assert(self); |
| 362 | |
| 363 | #ifdef HAVE_FLTK_FULLSCREEN |
| 364 | if (!fullscreenSystemKeys) |
| 365 | return; |
| 366 | if (!self->fullscreen_active()) |
| 367 | return; |
| 368 | |
| 369 | self->grabKeyboard(); |
| 370 | #endif |
| 371 | } |
| 372 | |
| 373 | |
Pierre Ossman | 6455d85 | 2011-06-01 09:33:00 +0000 | [diff] [blame] | 374 | void DesktopWindow::repositionViewport() |
| 375 | { |
| 376 | int new_x, new_y; |
| 377 | |
| 378 | // Deal with some scrolling corner cases: |
| 379 | // |
| 380 | // a) If the window is larger then the viewport, center the viewport. |
| 381 | // b) If the window is smaller than the viewport, make sure there is |
| 382 | // no wasted space on the sides. |
| 383 | // |
| 384 | // FIXME: Doesn't compensate for scroll widget size properly. |
| 385 | |
| 386 | new_x = viewport->x(); |
| 387 | new_y = viewport->y(); |
| 388 | |
| 389 | if (w() > viewport->w()) |
| 390 | new_x = (w() - viewport->w()) / 2; |
| 391 | else { |
| 392 | if (viewport->x() > 0) |
| 393 | new_x = 0; |
| 394 | else if (w() > (viewport->x() + viewport->w())) |
| 395 | new_x = w() - viewport->w(); |
| 396 | } |
| 397 | |
| 398 | // Same thing for y axis |
| 399 | if (h() > viewport->h()) |
| 400 | new_y = (h() - viewport->h()) / 2; |
| 401 | else { |
| 402 | if (viewport->y() > 0) |
| 403 | new_y = 0; |
| 404 | else if (h() > (viewport->y() + viewport->h())) |
| 405 | new_y = h() - viewport->h(); |
| 406 | } |
| 407 | |
| 408 | if ((new_x != viewport->x()) || (new_y != viewport->y())) { |
| 409 | viewport->position(new_x, new_y); |
| 410 | |
| 411 | // The scroll widget does not notice when you move around child widgets, |
| 412 | // so redraw everything to make sure things update. |
| 413 | redraw(); |
| 414 | } |
| 415 | } |
| 416 | |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 417 | void DesktopWindow::handleClose(Fl_Widget *wnd, void *data) |
| 418 | { |
| 419 | exit_vncviewer(); |
| 420 | } |
Pierre Ossman | 407a5c3 | 2011-05-26 14:48:29 +0000 | [diff] [blame] | 421 | |
| 422 | |
| 423 | void DesktopWindow::handleOptions(void *data) |
| 424 | { |
| 425 | DesktopWindow *self = (DesktopWindow*)data; |
| 426 | |
| 427 | #ifdef HAVE_FLTK_FULLSCREEN |
| 428 | if (self->fullscreen_active() && fullscreenSystemKeys) |
| 429 | self->grabKeyboard(); |
| 430 | else |
| 431 | self->ungrabKeyboard(); |
Pierre Ossman | 9191164 | 2011-05-26 14:57:51 +0000 | [diff] [blame] | 432 | |
Peter Åstrand | 17067b1 | 2011-07-18 07:45:14 +0000 | [diff] [blame] | 433 | if (fullScreen && !self->fullscreen_active()) { |
| 434 | // Some WMs (Metacity) apparently requires that the size limits |
| 435 | // are removed before fullscreen |
| 436 | self->size_range(100, 100, 0, 0); |
Pierre Ossman | 9191164 | 2011-05-26 14:57:51 +0000 | [diff] [blame] | 437 | self->fullscreen(); |
Peter Åstrand | 17067b1 | 2011-07-18 07:45:14 +0000 | [diff] [blame] | 438 | } else if (!fullScreen && self->fullscreen_active()) |
Pierre Ossman | 9191164 | 2011-05-26 14:57:51 +0000 | [diff] [blame] | 439 | self->fullscreen_off(); |
Pierre Ossman | 407a5c3 | 2011-05-26 14:48:29 +0000 | [diff] [blame] | 440 | #endif |
| 441 | } |