blob: 08a6652229347d990694a8d7fcfeb4cc9c2787f5 [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
Pierre Ossman947b48d2014-01-27 16:52:35 +010053 void fillRect(const rfb::Rect& r, rfb::Pixel pix);
54 void imageRect(const rfb::Rect& r, void* pixels);
55 void copyRect(const rfb::Rect& r, int srcX, int srcY);
Pierre Ossman5156d5e2011-03-09 09:42:34 +000056
Pierre Ossman947b48d2014-01-27 16:52:35 +010057 rdr::U8* getBufferRW(const rfb::Rect& r, int* stride);
58 void damageRect(const rfb::Rect& r);
DRC33c15e32011-11-03 18:49:21 +000059
Pierre Ossman6455d852011-06-01 09:33:00 +000060 void resizeFramebuffer(int new_w, int new_h);
61
Pierre Ossman835b4ef2011-06-08 17:02:36 +000062 void setCursor(int width, int height, const rfb::Point& hotspot,
63 void* data, void* mask);
64
Pierre Ossman4ae229f2011-04-15 12:58:31 +000065 // Fl_Window callback methods
66 void resize(int x, int y, int w, int h);
67
Pierre Ossman407a5c32011-05-26 14:48:29 +000068 int handle(int event);
69
Pierre Ossmanaae38912012-07-13 11:22:55 +000070 void fullscreen_on();
71
Pierre Ossman5156d5e2011-03-09 09:42:34 +000072private:
Pierre Ossmana4f0f182011-06-14 13:36:57 +000073 static int fltkHandle(int event, Fl_Window *win);
74
Pierre Ossman407a5c32011-05-26 14:48:29 +000075 void grabKeyboard();
76 void ungrabKeyboard();
77
78 static void handleGrab(void *data);
79
Peter Åstrand49b11572012-08-01 08:09:09 +000080 void maximizeWindow();
81
Pierre Ossman4c4b66f2012-08-23 14:53:36 +000082 void handleDesktopSize();
Pierre Ossmanff473402012-07-04 11:27:47 +000083 static void handleResizeTimeout(void *data);
Pierre Ossman4c4b66f2012-08-23 14:53:36 +000084 void remoteResize(int width, int height);
Pierre Ossmanff473402012-07-04 11:27:47 +000085
Pierre Ossman6455d852011-06-01 09:33:00 +000086 void repositionViewport();
87
Pierre Ossman5156d5e2011-03-09 09:42:34 +000088 static void handleClose(Fl_Widget *wnd, void *data);
89
Pierre Ossman407a5c32011-05-26 14:48:29 +000090 static void handleOptions(void *data);
91
Pierre Ossman4c4b66f2012-08-23 14:53:36 +000092 static void handleFullscreenTimeout(void *data);
93
Pierre Ossman1d867b62012-09-03 09:25:07 +000094 static void handleEdgeScroll(void *data);
95
Pierre Ossman5156d5e2011-03-09 09:42:34 +000096private:
Pierre Ossmanff473402012-07-04 11:27:47 +000097 CConn* cc;
Pierre Ossman1d867b62012-09-03 09:25:07 +000098 Fl_Scroll *scroll;
Pierre Ossmand50b3d12011-04-15 07:46:56 +000099 Viewport *viewport;
Pierre Ossmanff473402012-07-04 11:27:47 +0000100
101 bool firstUpdate;
Pierre Ossman4c4b66f2012-08-23 14:53:36 +0000102 bool delayedFullscreen;
103 bool delayedDesktopSize;
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000104};
105
106#endif