blob: 2be07680b69af5b768dbe1a60a4866bedacdae2d [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 <FL/Fl.H>
26#include <FL/Fl_Window.H>
27
28#include <rfb/Rect.h>
Pierre Ossmand50b3d12011-04-15 07:46:56 +000029
30#include "Viewport.h"
Pierre Ossman5156d5e2011-03-09 09:42:34 +000031
32class CConn;
33
34class DesktopWindow : public Fl_Window {
35public:
36
37 DesktopWindow(int w, int h, const char *name,
38 const rfb::PixelFormat& serverPF, CConn* cc_);
39 ~DesktopWindow();
40
41 // PixelFormat of incoming write operations
42 void setServerPF(const rfb::PixelFormat& pf);
43 // Most efficient format (from DesktopWindow's point of view)
44 const rfb::PixelFormat &getPreferredPF();
45
Pierre Ossman5156d5e2011-03-09 09:42:34 +000046 // Flush updates to screen
47 void updateWindow();
48
49 // Methods forwarded from CConn
50 void setName(const char *name);
51
52 void setColourMapEntries(int firstColour, int nColours, rdr::U16* rgbs);
53
54 void fillRect(const rfb::Rect& r, rfb::Pixel pix) {
Pierre Ossmand50b3d12011-04-15 07:46:56 +000055 viewport->fillRect(r, pix);
Pierre Ossman5156d5e2011-03-09 09:42:34 +000056 }
57 void imageRect(const rfb::Rect& r, void* pixels) {
Pierre Ossmand50b3d12011-04-15 07:46:56 +000058 viewport->imageRect(r, pixels);
Pierre Ossman5156d5e2011-03-09 09:42:34 +000059 }
60 void copyRect(const rfb::Rect& r, int srcX, int srcY) {
Pierre Ossmand50b3d12011-04-15 07:46:56 +000061 viewport->copyRect(r, srcX, srcY);
Pierre Ossman5156d5e2011-03-09 09:42:34 +000062 }
63
Pierre Ossman6455d852011-06-01 09:33:00 +000064 void resizeFramebuffer(int new_w, int new_h);
65
Pierre Ossman835b4ef2011-06-08 17:02:36 +000066 void setCursor(int width, int height, const rfb::Point& hotspot,
67 void* data, void* mask);
68
Pierre Ossman4ae229f2011-04-15 12:58:31 +000069 // Fl_Window callback methods
70 void resize(int x, int y, int w, int h);
71
Pierre Ossman407a5c32011-05-26 14:48:29 +000072 int handle(int event);
73
Pierre Ossman5156d5e2011-03-09 09:42:34 +000074private:
Pierre Ossman407a5c32011-05-26 14:48:29 +000075 void grabKeyboard();
76 void ungrabKeyboard();
77
78 static void handleGrab(void *data);
79
Pierre Ossman6455d852011-06-01 09:33:00 +000080 void repositionViewport();
81
Pierre Ossman5156d5e2011-03-09 09:42:34 +000082 static void handleClose(Fl_Widget *wnd, void *data);
83
Pierre Ossman407a5c32011-05-26 14:48:29 +000084 static void handleOptions(void *data);
85
Pierre Ossman5156d5e2011-03-09 09:42:34 +000086private:
Pierre Ossmand50b3d12011-04-15 07:46:56 +000087 Viewport *viewport;
Pierre Ossman5156d5e2011-03-09 09:42:34 +000088};
89
90#endif