blob: fbb5f954b0182823d26cfd69be08b44024bdaca5 [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 Ossmand50b3d12011-04-15 07:46:56 +000026
27#include "Viewport.h"
Pierre Ossman5156d5e2011-03-09 09:42:34 +000028
DRCb65bb932011-06-24 03:17:00 +000029#include <FL/Fl.H>
30#include <FL/Fl_Window.H>
31
Pierre Ossman5156d5e2011-03-09 09:42:34 +000032class 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
DRC33c15e32011-11-03 18:49:21 +000064 rdr::U8* getPixelsRW(const rfb::Rect& r, int* stride) {
65 return viewport->getPixelsRW(r, stride);
66 }
67 void damageRect(const rfb::Rect& r) {
68 viewport->damageRect(r);
69 }
70
Pierre Ossman6455d852011-06-01 09:33:00 +000071 void resizeFramebuffer(int new_w, int new_h);
72
Pierre Ossman835b4ef2011-06-08 17:02:36 +000073 void setCursor(int width, int height, const rfb::Point& hotspot,
74 void* data, void* mask);
75
Pierre Ossman4ae229f2011-04-15 12:58:31 +000076 // Fl_Window callback methods
77 void resize(int x, int y, int w, int h);
78
Pierre Ossman407a5c32011-05-26 14:48:29 +000079 int handle(int event);
80
Pierre Ossman5156d5e2011-03-09 09:42:34 +000081private:
Pierre Ossmana4f0f182011-06-14 13:36:57 +000082 static int fltkHandle(int event, Fl_Window *win);
83
Pierre Ossman407a5c32011-05-26 14:48:29 +000084 void grabKeyboard();
85 void ungrabKeyboard();
86
87 static void handleGrab(void *data);
88
Pierre Ossman6455d852011-06-01 09:33:00 +000089 void repositionViewport();
90
Pierre Ossman5156d5e2011-03-09 09:42:34 +000091 static void handleClose(Fl_Widget *wnd, void *data);
92
Pierre Ossman407a5c32011-05-26 14:48:29 +000093 static void handleOptions(void *data);
94
Pierre Ossman5156d5e2011-03-09 09:42:34 +000095private:
Pierre Ossmand50b3d12011-04-15 07:46:56 +000096 Viewport *viewport;
Pierre Ossman5156d5e2011-03-09 09:42:34 +000097};
98
99#endif