blob: 391c023e544c28d0ebb673372434458b81d1b4f1 [file] [log] [blame]
Pierre Ossman5156d5e2011-03-09 09:42:34 +00001/* 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 Åstrandc359f362011-08-23 12:04:46 +000020#ifdef HAVE_CONFIG_H
21#include <config.h>
22#endif
23
Pierre Ossman5156d5e2011-03-09 09:42:34 +000024#include <assert.h>
25#include <stdio.h>
26#include <string.h>
27
Pierre Ossman5156d5e2011-03-09 09:42:34 +000028#include <rfb/LogWriter.h>
Pierre Ossmanff473402012-07-04 11:27:47 +000029#include <rfb/CMsgWriter.h>
Pierre Ossman5156d5e2011-03-09 09:42:34 +000030
31#include "DesktopWindow.h"
Pierre Ossman407a5c32011-05-26 14:48:29 +000032#include "OptionsDialog.h"
Pierre Ossman5156d5e2011-03-09 09:42:34 +000033#include "i18n.h"
Pierre Ossman407a5c32011-05-26 14:48:29 +000034#include "parameters.h"
Pierre Ossman39ceb502011-07-12 15:54:25 +000035#include "vncviewer.h"
Pierre Ossmanff473402012-07-04 11:27:47 +000036#include "CConn.h"
Pierre Ossman407a5c32011-05-26 14:48:29 +000037
DRCb65bb932011-06-24 03:17:00 +000038#include <FL/Fl_Scroll.H>
39#include <FL/x.H>
40
Pierre Ossman407a5c32011-05-26 14:48:29 +000041#ifdef WIN32
42#include "win32.h"
43#endif
44
45#ifdef __APPLE__
46#include "cocoa.h"
47#endif
Pierre Ossman89f868a2011-04-11 11:59:31 +000048
Pierre Ossman5156d5e2011-03-09 09:42:34 +000049using namespace rfb;
50
Pierre Ossman5156d5e2011-03-09 09:42:34 +000051static rfb::LogWriter vlog("DesktopWindow");
52
53DesktopWindow::DesktopWindow(int w, int h, const char *name,
54 const rfb::PixelFormat& serverPF,
55 CConn* cc_)
Pierre Ossmanff473402012-07-04 11:27:47 +000056 : Fl_Window(w, h), cc(cc_), firstUpdate(true)
Pierre Ossman5156d5e2011-03-09 09:42:34 +000057{
Pierre Ossman4ae229f2011-04-15 12:58:31 +000058 Fl_Scroll *scroll = new Fl_Scroll(0, 0, w, h);
59 scroll->color(FL_BLACK);
60
61 // Automatically adjust the scroll box to the window
62 resizable(scroll);
63
Pierre Ossmanff473402012-07-04 11:27:47 +000064 viewport = new Viewport(w, h, serverPF, cc);
Pierre Ossmand50b3d12011-04-15 07:46:56 +000065
Pierre Ossman4ae229f2011-04-15 12:58:31 +000066 scroll->end();
67
Pierre Ossman5156d5e2011-03-09 09:42:34 +000068 callback(handleClose, this);
69
70 setName(name);
71
Pierre Ossman407a5c32011-05-26 14:48:29 +000072 OptionsDialog::addCallback(handleOptions, this);
73
Pierre Ossmana4f0f182011-06-14 13:36:57 +000074 // Hack. See below...
75 Fl::event_dispatch(&fltkHandle);
76
Pierre Ossman63ca58e2011-05-26 14:59:32 +000077#ifdef HAVE_FLTK_FULLSCREEN
Pierre Ossmanff473402012-07-04 11:27:47 +000078 if (fullScreen)
Pierre Ossmanaae38912012-07-13 11:22:55 +000079 fullscreen_on();
Pierre Ossmanff473402012-07-04 11:27:47 +000080 else
Pierre Ossman63ca58e2011-05-26 14:59:32 +000081#endif
Peter Åstrandd62482e2011-08-02 08:33:27 +000082 {
83 // If we are creating a window which is equal to the size on the
84 // screen on X11, many WMs will treat this as a legacy fullscreen
85 // request. This is not what we want. Besides, it doesn't really
86 // make sense to try to create a window which is larger than the
87 // available work space.
88 size(__rfbmin(w, Fl::w()), __rfbmin(h, Fl::h()));
89 }
Pierre Ossman63ca58e2011-05-26 14:59:32 +000090
Pierre Ossman5156d5e2011-03-09 09:42:34 +000091 show();
Pierre Ossman3f6c4d02011-04-15 14:09:09 +000092
93 // The window manager might give us an initial window size that is different
94 // than the one we requested, and in those cases we need to manually adjust
95 // the scroll widget for things to behave sanely.
96 if ((w != this->w()) || (h != this->h()))
97 scroll->size(this->w(), this->h());
Pierre Ossman5156d5e2011-03-09 09:42:34 +000098}
99
100
101DesktopWindow::~DesktopWindow()
102{
Pierre Ossman407a5c32011-05-26 14:48:29 +0000103 // Unregister all timeouts in case they get a change tro trigger
104 // again later when this object is already gone.
105 Fl::remove_timeout(handleGrab, this);
Pierre Ossmanff473402012-07-04 11:27:47 +0000106 Fl::remove_timeout(handleResizeTimeout, this);
Pierre Ossman407a5c32011-05-26 14:48:29 +0000107
108 OptionsDialog::removeCallback(handleOptions);
109
Pierre Ossmand50b3d12011-04-15 07:46:56 +0000110 // FLTK automatically deletes all child widgets, so we shouldn't touch
111 // them ourselves here
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000112}
113
114
115void DesktopWindow::setServerPF(const rfb::PixelFormat& pf)
116{
Pierre Ossmand50b3d12011-04-15 07:46:56 +0000117 viewport->setServerPF(pf);
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000118}
119
120
121const rfb::PixelFormat &DesktopWindow::getPreferredPF()
122{
Pierre Ossmand50b3d12011-04-15 07:46:56 +0000123 return viewport->getPreferredPF();
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000124}
125
126
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000127void DesktopWindow::setName(const char *name)
128{
129 CharArray windowNameStr;
130 windowNameStr.replaceBuf(new char[256]);
131
Pierre Ossman27820ba2011-09-30 12:54:24 +0000132 snprintf(windowNameStr.buf, 256, "%.240s - TigerVNC", name);
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000133
134 copy_label(windowNameStr.buf);
135}
136
Pierre Ossmand50b3d12011-04-15 07:46:56 +0000137
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000138void DesktopWindow::setColourMapEntries(int firstColour, int nColours,
139 rdr::U16* rgbs)
140{
Pierre Ossmand50b3d12011-04-15 07:46:56 +0000141 viewport->setColourMapEntries(firstColour, nColours, rgbs);
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000142}
143
144
145// Copy the areas of the framebuffer that have been changed (damaged)
146// to the displayed window.
147
148void DesktopWindow::updateWindow()
149{
Pierre Ossmanff473402012-07-04 11:27:47 +0000150 if (firstUpdate) {
151 if (cc->cp.supportsSetDesktopSize)
152 remoteResize();
153 firstUpdate = false;
154 }
155
Pierre Ossmand50b3d12011-04-15 07:46:56 +0000156 viewport->updateWindow();
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000157}
158
159
Pierre Ossman6455d852011-06-01 09:33:00 +0000160void DesktopWindow::resizeFramebuffer(int new_w, int new_h)
161{
162 if ((new_w == viewport->w()) && (new_h == viewport->h()))
163 return;
164
Pierre Ossman6455d852011-06-01 09:33:00 +0000165 // If we're letting the viewport match the window perfectly, then
166 // keep things that way for the new size, otherwise just keep things
167 // like they are.
Peter Åstrand1d03cbc2011-08-01 10:34:38 +0000168#ifdef HAVE_FLTK_FULLSCREEN
169 if (!fullscreen_active()) {
170#endif
Pierre Ossman29e4a162011-11-21 14:03:31 +0000171 if ((w() == viewport->w()) && (h() == viewport->h()))
172 size(new_w, new_h);
173 else {
174 // Make sure the window isn't too big. We do this manually because
175 // we have to disable the window size restriction (and it isn't
176 // entirely trustworthy to begin with).
Pierre Ossman6455d852011-06-01 09:33:00 +0000177 if ((w() > new_w) || (h() > new_h))
178 size(__rfbmin(w(), new_w), __rfbmin(h(), new_h));
Pierre Ossman29e4a162011-11-21 14:03:31 +0000179 }
Peter Åstrand1d03cbc2011-08-01 10:34:38 +0000180#ifdef HAVE_FLTK_FULLSCREEN
181 }
182#endif
Pierre Ossman6455d852011-06-01 09:33:00 +0000183
184 viewport->size(new_w, new_h);
185
186 // We might not resize the main window, so we need to manually call this
187 // to make sure the viewport is centered.
188 repositionViewport();
189
Pierre Ossman6455d852011-06-01 09:33:00 +0000190 // repositionViewport() makes sure the scroll widget notices any changes
191 // in position, but it might be just the size that changes so we also
192 // need a poke here as well.
193 redraw();
194}
195
196
Pierre Ossman835b4ef2011-06-08 17:02:36 +0000197void DesktopWindow::setCursor(int width, int height, const Point& hotspot,
198 void* data, void* mask)
199{
200 viewport->setCursor(width, height, hotspot, data, mask);
201}
202
203
Pierre Ossman4ae229f2011-04-15 12:58:31 +0000204void DesktopWindow::resize(int x, int y, int w, int h)
205{
Pierre Ossman4ae229f2011-04-15 12:58:31 +0000206 Fl_Window::resize(x, y, w, h);
Pierre Ossman6455d852011-06-01 09:33:00 +0000207
Pierre Ossmanff473402012-07-04 11:27:47 +0000208 // Try to get the remote size to match our window size, provided
209 // the following conditions are true:
210 //
211 // a) The user has this feature turned on
212 // b) The server supports it
213 // c) We're not still waiting for a chance to handle DesktopSize
214 //
215 if (not firstUpdate and ::remoteResize and cc->cp.supportsSetDesktopSize) {
216 // We delay updating the remote desktop as we tend to get a flood
217 // of resize events as the user is dragging the window.
218 Fl::remove_timeout(handleResizeTimeout, this);
219 Fl::add_timeout(0.5, handleResizeTimeout, this);
220 }
221
Pierre Ossman6455d852011-06-01 09:33:00 +0000222 // Deal with some scrolling corner cases
223 repositionViewport();
Pierre Ossman4ae229f2011-04-15 12:58:31 +0000224}
225
226
Pierre Ossman407a5c32011-05-26 14:48:29 +0000227int DesktopWindow::handle(int event)
228{
229 switch (event) {
230#ifdef HAVE_FLTK_FULLSCREEN
Pierre Ossman407a5c32011-05-26 14:48:29 +0000231 case FL_FULLSCREEN:
Pierre Ossman29e4a162011-11-21 14:03:31 +0000232 fullScreen.setParam(fullscreen_active());
233
Pierre Ossman407a5c32011-05-26 14:48:29 +0000234 if (!fullscreenSystemKeys)
235 break;
236
237 if (fullscreen_active())
238 grabKeyboard();
239 else
240 ungrabKeyboard();
241
242 break;
Pierre Ossman407a5c32011-05-26 14:48:29 +0000243#endif
244 case FL_SHORTCUT:
245 // Sometimes the focus gets out of whack and we fall through to the
246 // shortcut dispatching. Try to make things sane again...
247 if (Fl::focus() == NULL) {
248 take_focus();
249 Fl::handle(FL_KEYDOWN, this);
250 }
251 return 1;
252 }
253
254 return Fl_Window::handle(event);
255}
256
257
Pierre Ossmana4f0f182011-06-14 13:36:57 +0000258int DesktopWindow::fltkHandle(int event, Fl_Window *win)
259{
260 int ret;
261
262 ret = Fl::handle_(event, win);
263
264#ifdef HAVE_FLTK_FULLSCREEN
265 // This is hackish and the result of the dodgy focus handling in FLTK.
266 // The basic problem is that FLTK's view of focus and the system's tend
267 // to differ, and as a result we do not see all the FL_FOCUS events we
268 // need. Fortunately we can grab them here...
269
270 DesktopWindow *dw = dynamic_cast<DesktopWindow*>(win);
271
272 if (dw && fullscreenSystemKeys) {
273 switch (event) {
274 case FL_FOCUS:
275 // FIXME: We reassert the keyboard grabbing on focus as FLTK there are
276 // some issues we need to work around:
277 // a) Fl::grab(0) on X11 will release the keyboard grab for us.
278 // b) Gaining focus on the system level causes FLTK to switch
279 // window level on OS X.
280 if (dw->fullscreen_active())
281 dw->grabKeyboard();
282 break;
283
284 case FL_UNFOCUS:
285 // FIXME: We need to relinquish control when the entire window loses
286 // focus as it is very tied to this specific window on some
287 // platforms and we want to be able to open subwindows.
288 dw->ungrabKeyboard();
289 break;
290 }
291 }
292#endif
293
294 return ret;
295}
296
297
Pierre Ossmanaae38912012-07-13 11:22:55 +0000298void DesktopWindow::fullscreen_on()
299{
300#ifdef HAVE_FLTK_FULLSCREEN
301#ifdef HAVE_FLTK_FULLSCREEN_SCREENS
302 if (not fullScreenAllMonitors)
303 fullscreen_screens(-1, -1, -1, -1);
304 else {
305 int top, bottom, left, right;
306 int top_y, bottom_y, left_x, right_x;
307
308 int sx, sy, sw, sh;
309
310 top = bottom = left = right = 0;
311
312 Fl::screen_xywh(sx, sy, sw, sh, 0);
313 top_y = sy;
314 bottom_y = sy + sh;
315 left_x = sx;
316 right_x = sx + sw;
317
318 for (int i = 1;i < Fl::screen_count();i++) {
319 Fl::screen_xywh(sx, sy, sw, sh, i);
320 if (sy < top_y) {
321 top = i;
322 top_y = sy;
323 }
324 if ((sy + sh) > bottom_y) {
325 bottom = i;
326 bottom_y = sy + sh;
327 }
328 if (sx < left_x) {
329 left = i;
330 left_x = sx;
331 }
332 if ((sx + sw) > right_x) {
333 right = i;
334 right_x = sx + sw;
335 }
336 }
337
338 fullscreen_screens(top, bottom, left, right);
339 }
340#endif // HAVE_FLTK_FULLSCREEN_SCREENS
341
342 fullscreen();
343#endif // HAVE_FLTK_FULLSCREEN
344}
345
Pierre Ossman407a5c32011-05-26 14:48:29 +0000346void DesktopWindow::grabKeyboard()
347{
348 // Grabbing the keyboard is fairly safe as FLTK reroutes events to the
349 // correct widget regardless of which low level window got the system
350 // event.
351
352 // FIXME: Push this stuff into FLTK.
353
354#if defined(WIN32)
355 int ret;
356
357 ret = win32_enable_lowlevel_keyboard(fl_xid(this));
358 if (ret != 0)
359 vlog.error(_("Failure grabbing keyboard"));
360#elif defined(__APPLE__)
361 int ret;
362
363 ret = cocoa_capture_display(this);
364 if (ret != 0)
365 vlog.error(_("Failure grabbing keyboard"));
366#else
367 int ret;
368
369 ret = XGrabKeyboard(fl_display, fl_xid(this), True,
Peter Åstrandf52860b2011-07-18 07:42:16 +0000370 GrabModeAsync, GrabModeAsync, CurrentTime);
Pierre Ossman407a5c32011-05-26 14:48:29 +0000371 if (ret) {
372 if (ret == AlreadyGrabbed) {
373 // It seems like we can race with the WM in some cases.
374 // Try again in a bit.
375 if (!Fl::has_timeout(handleGrab, this))
376 Fl::add_timeout(0.500, handleGrab, this);
377 } else {
378 vlog.error(_("Failure grabbing keyboard"));
379 }
380 }
Pierre Ossman53fd5442011-11-17 10:19:19 +0000381
382 // We also need to grab the pointer as some WMs like to grab buttons
383 // combined with modifies (e.g. Alt+Button0 in metacity).
384 ret = XGrabPointer(fl_display, fl_xid(this), True,
385 ButtonPressMask|ButtonReleaseMask|
386 ButtonMotionMask|PointerMotionMask,
387 GrabModeAsync, GrabModeAsync,
388 None, None, CurrentTime);
389 if (ret)
390 vlog.error(_("Failure grabbing mouse"));
Pierre Ossman407a5c32011-05-26 14:48:29 +0000391#endif
392}
393
394
395void DesktopWindow::ungrabKeyboard()
396{
397 Fl::remove_timeout(handleGrab, this);
398
399#if defined(WIN32)
400 win32_disable_lowlevel_keyboard(fl_xid(this));
401#elif defined(__APPLE__)
402 cocoa_release_display(this);
403#else
404 // FLTK has a grab so lets not mess with it
405 if (Fl::grab())
406 return;
407
Pierre Ossman53fd5442011-11-17 10:19:19 +0000408 XUngrabPointer(fl_display, fl_event_time);
Pierre Ossman407a5c32011-05-26 14:48:29 +0000409 XUngrabKeyboard(fl_display, fl_event_time);
410#endif
411}
412
413
414void DesktopWindow::handleGrab(void *data)
415{
416 DesktopWindow *self = (DesktopWindow*)data;
417
418 assert(self);
419
420#ifdef HAVE_FLTK_FULLSCREEN
421 if (!fullscreenSystemKeys)
422 return;
423 if (!self->fullscreen_active())
424 return;
425
426 self->grabKeyboard();
427#endif
428}
429
430
Pierre Ossmanff473402012-07-04 11:27:47 +0000431void DesktopWindow::handleResizeTimeout(void *data)
432{
433 DesktopWindow *self = (DesktopWindow *)data;
434
435 assert(self);
436
437 self->remoteResize();
438}
439
440
441void DesktopWindow::remoteResize()
442{
443 int width, height;
444 ScreenSet layout;
Pierre Ossmanaae38912012-07-13 11:22:55 +0000445 ScreenSet::iterator iter;
Pierre Ossmanff473402012-07-04 11:27:47 +0000446
447 if (firstUpdate) {
448 if (sscanf(desktopSize.getValueStr(), "%dx%d", &width, &height) != 2)
449 return;
450 } else {
451 width = w();
452 height = h();
453 }
454
Pierre Ossmanaae38912012-07-13 11:22:55 +0000455#ifdef HAVE_FLTK_FULLSCREEN
456 if (!fullscreen_active()) {
457#endif
458 // In windowed mode we just report a single virtual screen that
459 // covers the entire framebuffer.
Pierre Ossmanff473402012-07-04 11:27:47 +0000460
Pierre Ossmanaae38912012-07-13 11:22:55 +0000461 layout = cc->cp.screenLayout;
Pierre Ossmanff473402012-07-04 11:27:47 +0000462
Pierre Ossmanaae38912012-07-13 11:22:55 +0000463 // Not sure why we have no screens, but adding a new one should be
464 // safe as there is nothing to conflict with...
465 if (layout.num_screens() == 0)
466 layout.add_screen(rfb::Screen());
467 else if (layout.num_screens() != 1) {
468 // More than one screen. Remove all but the first (which we
469 // assume is the "primary").
Pierre Ossmanff473402012-07-04 11:27:47 +0000470
Pierre Ossmanaae38912012-07-13 11:22:55 +0000471 while (true) {
472 iter = layout.begin();
473 ++iter;
Pierre Ossmanff473402012-07-04 11:27:47 +0000474
Pierre Ossmanaae38912012-07-13 11:22:55 +0000475 if (iter == layout.end())
476 break;
477
478 layout.remove_screen(iter->id);
479 }
480 }
481
482 // Resize the remaining single screen to the complete framebuffer
483 layout.begin()->dimensions.tl.x = 0;
484 layout.begin()->dimensions.tl.y = 0;
485 layout.begin()->dimensions.br.x = width;
486 layout.begin()->dimensions.br.y = height;
487#ifdef HAVE_FLTK_FULLSCREEN
488 } else {
489 int i;
490 rdr::U32 id;
491 int sx, sy, sw, sh;
492
493 // In full screen we report all screens that are fully covered.
494
495 // If we can find a matching screen in the existing set, we use
496 // that, otherwise we create a brand new screen.
497 //
498 // FIXME: We should really track screens better so we can handle
499 // a resized one.
500 //
501 for (i = 0;i < Fl::screen_count();i++) {
502 Fl::screen_xywh(sx, sy, sw, sh, i);
503
504 // Look for perfectly matching existing screen...
505 for (iter = cc->cp.screenLayout.begin();
506 iter != cc->cp.screenLayout.end(); ++iter) {
507 if ((iter->dimensions.tl.x == sx) &&
508 (iter->dimensions.tl.y == sy) &&
509 (iter->dimensions.width() == sw) &&
510 (iter->dimensions.height() == sh))
511 break;
512 }
513
514 // Found it?
515 if (iter != cc->cp.screenLayout.end()) {
516 layout.add_screen(*iter);
517 continue;
518 }
519
520 // Need to add a new one, which means we need to find an unused id
521 while (true) {
522 id = rand();
523 for (iter = cc->cp.screenLayout.begin();
524 iter != cc->cp.screenLayout.end(); ++iter) {
525 if (iter->id == id)
526 break;
527 }
528
529 if (iter == cc->cp.screenLayout.end())
530 break;
531 }
532
533 layout.add_screen(rfb::Screen(id, sx, sy, sw, sh, 0));
Pierre Ossmanff473402012-07-04 11:27:47 +0000534 }
535 }
Pierre Ossmanaae38912012-07-13 11:22:55 +0000536#endif
Pierre Ossmanff473402012-07-04 11:27:47 +0000537
538 // Do we actually change anything?
539 if ((width == cc->cp.width) &&
540 (height == cc->cp.height) &&
541 (layout == cc->cp.screenLayout))
542 return;
543
Pierre Ossmanaae38912012-07-13 11:22:55 +0000544 vlog.debug("Requesting framebuffer resize from %dx%d to %dx%d (%d screens)",
545 cc->cp.width, cc->cp.height, width, height, layout.num_screens());
546
547 if (!layout.validate(width, height)) {
548 vlog.error("Invalid screen layout computed for resize request!");
Pierre Ossmanaae38912012-07-13 11:22:55 +0000549 return;
550 }
Pierre Ossmanff473402012-07-04 11:27:47 +0000551
552 cc->writer()->writeSetDesktopSize(width, height, layout);
553}
554
555
Pierre Ossman6455d852011-06-01 09:33:00 +0000556void DesktopWindow::repositionViewport()
557{
558 int new_x, new_y;
559
560 // Deal with some scrolling corner cases:
561 //
562 // a) If the window is larger then the viewport, center the viewport.
563 // b) If the window is smaller than the viewport, make sure there is
564 // no wasted space on the sides.
565 //
566 // FIXME: Doesn't compensate for scroll widget size properly.
567
568 new_x = viewport->x();
569 new_y = viewport->y();
570
571 if (w() > viewport->w())
572 new_x = (w() - viewport->w()) / 2;
573 else {
574 if (viewport->x() > 0)
575 new_x = 0;
576 else if (w() > (viewport->x() + viewport->w()))
577 new_x = w() - viewport->w();
578 }
579
580 // Same thing for y axis
581 if (h() > viewport->h())
582 new_y = (h() - viewport->h()) / 2;
583 else {
584 if (viewport->y() > 0)
585 new_y = 0;
586 else if (h() > (viewport->y() + viewport->h()))
587 new_y = h() - viewport->h();
588 }
589
590 if ((new_x != viewport->x()) || (new_y != viewport->y())) {
591 viewport->position(new_x, new_y);
592
593 // The scroll widget does not notice when you move around child widgets,
594 // so redraw everything to make sure things update.
595 redraw();
596 }
597}
598
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000599void DesktopWindow::handleClose(Fl_Widget *wnd, void *data)
600{
601 exit_vncviewer();
602}
Pierre Ossman407a5c32011-05-26 14:48:29 +0000603
604
605void DesktopWindow::handleOptions(void *data)
606{
607 DesktopWindow *self = (DesktopWindow*)data;
608
609#ifdef HAVE_FLTK_FULLSCREEN
610 if (self->fullscreen_active() && fullscreenSystemKeys)
611 self->grabKeyboard();
612 else
613 self->ungrabKeyboard();
Pierre Ossman91911642011-05-26 14:57:51 +0000614
Pierre Ossmanff473402012-07-04 11:27:47 +0000615 if (fullScreen && !self->fullscreen_active())
Pierre Ossmanaae38912012-07-13 11:22:55 +0000616 self->fullscreen_on();
Pierre Ossmanff473402012-07-04 11:27:47 +0000617 else if (!fullScreen && self->fullscreen_active())
Pierre Ossman91911642011-05-26 14:57:51 +0000618 self->fullscreen_off();
Pierre Ossman407a5c32011-05-26 14:48:29 +0000619#endif
620}