blob: 06f25f557d69cf72eb3a0b520855484632a5f43f [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 Ossman5156d5e2011-03-09 09:42:34 +000030class CConn;
Pierre Ossman947b48d2014-01-27 16:52:35 +010031class Viewport;
32
Pierre Ossman1d867b62012-09-03 09:25:07 +000033class Fl_Scroll;
Pierre Ossman5156d5e2011-03-09 09:42:34 +000034
35class DesktopWindow : public Fl_Window {
36public:
37
38 DesktopWindow(int w, int h, const char *name,
39 const rfb::PixelFormat& serverPF, CConn* cc_);
40 ~DesktopWindow();
41
42 // PixelFormat of incoming write operations
43 void setServerPF(const rfb::PixelFormat& pf);
44 // 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
50 // Methods forwarded from CConn
51 void setName(const char *name);
52
53 void setColourMapEntries(int firstColour, int nColours, rdr::U16* rgbs);
54
Pierre Ossman947b48d2014-01-27 16:52:35 +010055 void fillRect(const rfb::Rect& r, rfb::Pixel pix);
56 void imageRect(const rfb::Rect& r, void* pixels);
57 void copyRect(const rfb::Rect& r, int srcX, int srcY);
Pierre Ossman5156d5e2011-03-09 09:42:34 +000058
Pierre Ossman947b48d2014-01-27 16:52:35 +010059 rdr::U8* getBufferRW(const rfb::Rect& r, int* stride);
60 void damageRect(const rfb::Rect& r);
DRC33c15e32011-11-03 18:49:21 +000061
Pierre Ossman6455d852011-06-01 09:33:00 +000062 void resizeFramebuffer(int new_w, int new_h);
63
Pierre Ossman835b4ef2011-06-08 17:02:36 +000064 void setCursor(int width, int height, const rfb::Point& hotspot,
65 void* data, void* mask);
66
Pierre Ossman4ae229f2011-04-15 12:58:31 +000067 // Fl_Window callback methods
68 void resize(int x, int y, int w, int h);
69
Pierre Ossman407a5c32011-05-26 14:48:29 +000070 int handle(int event);
71
Pierre Ossmanaae38912012-07-13 11:22:55 +000072 void fullscreen_on();
73
Pierre Ossman5156d5e2011-03-09 09:42:34 +000074private:
Pierre Ossmana4f0f182011-06-14 13:36:57 +000075 static int fltkHandle(int event, Fl_Window *win);
76
Pierre Ossman407a5c32011-05-26 14:48:29 +000077 void grabKeyboard();
78 void ungrabKeyboard();
79
80 static void handleGrab(void *data);
81
Peter Åstrand49b11572012-08-01 08:09:09 +000082 void maximizeWindow();
83
Pierre Ossman4c4b66f2012-08-23 14:53:36 +000084 void handleDesktopSize();
Pierre Ossmanff473402012-07-04 11:27:47 +000085 static void handleResizeTimeout(void *data);
Pierre Ossman4c4b66f2012-08-23 14:53:36 +000086 void remoteResize(int width, int height);
Pierre Ossmanff473402012-07-04 11:27:47 +000087
Pierre Ossman6455d852011-06-01 09:33:00 +000088 void repositionViewport();
89
Pierre Ossman5156d5e2011-03-09 09:42:34 +000090 static void handleClose(Fl_Widget *wnd, void *data);
91
Pierre Ossman407a5c32011-05-26 14:48:29 +000092 static void handleOptions(void *data);
93
Pierre Ossman4c4b66f2012-08-23 14:53:36 +000094 static void handleFullscreenTimeout(void *data);
95
Pierre Ossman1d867b62012-09-03 09:25:07 +000096 static void handleEdgeScroll(void *data);
97
Pierre Ossman5156d5e2011-03-09 09:42:34 +000098private:
Pierre Ossmanff473402012-07-04 11:27:47 +000099 CConn* cc;
Pierre Ossman1d867b62012-09-03 09:25:07 +0000100 Fl_Scroll *scroll;
Pierre Ossmand50b3d12011-04-15 07:46:56 +0000101 Viewport *viewport;
Pierre Ossmanff473402012-07-04 11:27:47 +0000102
103 bool firstUpdate;
Pierre Ossman4c4b66f2012-08-23 14:53:36 +0000104 bool delayedFullscreen;
105 bool delayedDesktopSize;
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000106};
107
108#endif