blob: 8b91450fc460acf961708b758080bf136c7cc988 [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
20#ifndef __DESKTOPWINDOW_H__
21#define __DESKTOPWINDOW_H__
22
Pierre Ossmand7c5b042011-04-14 14:05:13 +000023#include <map>
24
Pierre Ossman5156d5e2011-03-09 09:42:34 +000025#include <rfb/Rect.h>
Pierre Ossman947b48d2014-01-27 16:52:35 +010026#include <rfb/Pixel.h>
Pierre Ossmand50b3d12011-04-15 07:46:56 +000027
DRCb65bb932011-06-24 03:17:00 +000028#include <FL/Fl_Window.H>
29
Pierre Ossman0c9bd4b2014-07-09 16:44:11 +020030namespace rfb { class ModifiablePixelBuffer; }
31
Pierre Ossman5156d5e2011-03-09 09:42:34 +000032class CConn;
Pierre Ossman947b48d2014-01-27 16:52:35 +010033class Viewport;
34
Pierre Ossman1d867b62012-09-03 09:25:07 +000035class Fl_Scroll;
Pierre Ossman5156d5e2011-03-09 09:42:34 +000036
37class DesktopWindow : public Fl_Window {
38public:
39
40 DesktopWindow(int w, int h, const char *name,
41 const rfb::PixelFormat& serverPF, CConn* cc_);
42 ~DesktopWindow();
43
Pierre Ossman5156d5e2011-03-09 09:42:34 +000044 // Most efficient format (from DesktopWindow's point of view)
45 const rfb::PixelFormat &getPreferredPF();
46
Pierre Ossman5156d5e2011-03-09 09:42:34 +000047 // Flush updates to screen
48 void updateWindow();
49
Pierre Ossman0c9bd4b2014-07-09 16:44:11 +020050 // Updated session title
Pierre Ossman5156d5e2011-03-09 09:42:34 +000051 void setName(const char *name);
52
Pierre Ossman0c9bd4b2014-07-09 16:44:11 +020053 // Return a pointer to the framebuffer for decoders to write into
54 rfb::ModifiablePixelBuffer* getFramebuffer(void);
Pierre Ossman5156d5e2011-03-09 09:42:34 +000055
Pierre Ossman0c9bd4b2014-07-09 16:44:11 +020056 // Resize the current framebuffer, but retain the contents
Pierre Ossman6455d852011-06-01 09:33:00 +000057 void resizeFramebuffer(int new_w, int new_h);
58
Pierre Ossman0c9bd4b2014-07-09 16:44:11 +020059 // New image for the locally rendered cursor
Pierre Ossman835b4ef2011-06-08 17:02:36 +000060 void setCursor(int width, int height, const rfb::Point& hotspot,
61 void* data, void* mask);
62
Pierre Ossman4ae229f2011-04-15 12:58:31 +000063 // Fl_Window callback methods
64 void resize(int x, int y, int w, int h);
65
Pierre Ossman407a5c32011-05-26 14:48:29 +000066 int handle(int event);
67
Pierre Ossmanaae38912012-07-13 11:22:55 +000068 void fullscreen_on();
69
Pierre Ossman5156d5e2011-03-09 09:42:34 +000070private:
Pierre Ossmana4f0f182011-06-14 13:36:57 +000071 static int fltkHandle(int event, Fl_Window *win);
72
Pierre Ossman407a5c32011-05-26 14:48:29 +000073 void grabKeyboard();
74 void ungrabKeyboard();
75
76 static void handleGrab(void *data);
77
Peter Åstrand49b11572012-08-01 08:09:09 +000078 void maximizeWindow();
79
Pierre Ossman4c4b66f2012-08-23 14:53:36 +000080 void handleDesktopSize();
Pierre Ossmanff473402012-07-04 11:27:47 +000081 static void handleResizeTimeout(void *data);
Pierre Ossman4c4b66f2012-08-23 14:53:36 +000082 void remoteResize(int width, int height);
Pierre Ossmanff473402012-07-04 11:27:47 +000083
Pierre Ossman6455d852011-06-01 09:33:00 +000084 void repositionViewport();
85
Pierre Ossman5156d5e2011-03-09 09:42:34 +000086 static void handleClose(Fl_Widget *wnd, void *data);
87
Pierre Ossman407a5c32011-05-26 14:48:29 +000088 static void handleOptions(void *data);
89
Pierre Ossman4c4b66f2012-08-23 14:53:36 +000090 static void handleFullscreenTimeout(void *data);
91
Pierre Ossman1d867b62012-09-03 09:25:07 +000092 static void handleEdgeScroll(void *data);
93
Pierre Ossman5156d5e2011-03-09 09:42:34 +000094private:
Pierre Ossmanff473402012-07-04 11:27:47 +000095 CConn* cc;
Pierre Ossman1d867b62012-09-03 09:25:07 +000096 Fl_Scroll *scroll;
Pierre Ossmand50b3d12011-04-15 07:46:56 +000097 Viewport *viewport;
Pierre Ossmanff473402012-07-04 11:27:47 +000098
99 bool firstUpdate;
Pierre Ossman4c4b66f2012-08-23 14:53:36 +0000100 bool delayedFullscreen;
101 bool delayedDesktopSize;
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000102};
103
104#endif