blob: deae16ec99c19814e2dbe14c6fb22c372a3f4269 [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#include <assert.h>
21#include <stdio.h>
22#include <string.h>
23
Pierre Ossman5156d5e2011-03-09 09:42:34 +000024#include <rfb/LogWriter.h>
25
26#include "DesktopWindow.h"
Pierre Ossman5156d5e2011-03-09 09:42:34 +000027#include "i18n.h"
Pierre Ossman89f868a2011-04-11 11:59:31 +000028
Pierre Ossman5156d5e2011-03-09 09:42:34 +000029using namespace rfb;
30
31extern void exit_vncviewer();
32
33static rfb::LogWriter vlog("DesktopWindow");
34
35DesktopWindow::DesktopWindow(int w, int h, const char *name,
36 const rfb::PixelFormat& serverPF,
37 CConn* cc_)
Pierre Ossmand50b3d12011-04-15 07:46:56 +000038 : Fl_Window(w, h)
Pierre Ossman5156d5e2011-03-09 09:42:34 +000039{
Pierre Ossmand50b3d12011-04-15 07:46:56 +000040 viewport = new Viewport(w, h, serverPF, cc_);
41
Pierre Ossman5156d5e2011-03-09 09:42:34 +000042 callback(handleClose, this);
43
44 setName(name);
45
Pierre Ossman5156d5e2011-03-09 09:42:34 +000046 show();
47}
48
49
50DesktopWindow::~DesktopWindow()
51{
Pierre Ossmand50b3d12011-04-15 07:46:56 +000052 // FLTK automatically deletes all child widgets, so we shouldn't touch
53 // them ourselves here
Pierre Ossman5156d5e2011-03-09 09:42:34 +000054}
55
56
57void DesktopWindow::setServerPF(const rfb::PixelFormat& pf)
58{
Pierre Ossmand50b3d12011-04-15 07:46:56 +000059 viewport->setServerPF(pf);
Pierre Ossman5156d5e2011-03-09 09:42:34 +000060}
61
62
63const rfb::PixelFormat &DesktopWindow::getPreferredPF()
64{
Pierre Ossmand50b3d12011-04-15 07:46:56 +000065 return viewport->getPreferredPF();
Pierre Ossman5156d5e2011-03-09 09:42:34 +000066}
67
68
69// Cursor stuff
70
71void DesktopWindow::setCursor(int width, int height, const Point& hotspot,
72 void* data, void* mask)
73{
74}
75
76
77void DesktopWindow::setName(const char *name)
78{
79 CharArray windowNameStr;
80 windowNameStr.replaceBuf(new char[256]);
81
82 snprintf(windowNameStr.buf, 256, _("TigerVNC: %.240s"), name);
83
84 copy_label(windowNameStr.buf);
85}
86
Pierre Ossmand50b3d12011-04-15 07:46:56 +000087
Pierre Ossman5156d5e2011-03-09 09:42:34 +000088void DesktopWindow::setColourMapEntries(int firstColour, int nColours,
89 rdr::U16* rgbs)
90{
Pierre Ossmand50b3d12011-04-15 07:46:56 +000091 viewport->setColourMapEntries(firstColour, nColours, rgbs);
Pierre Ossman5156d5e2011-03-09 09:42:34 +000092}
93
94
95// Copy the areas of the framebuffer that have been changed (damaged)
96// to the displayed window.
97
98void DesktopWindow::updateWindow()
99{
Pierre Ossmand50b3d12011-04-15 07:46:56 +0000100 viewport->updateWindow();
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000101}
102
103
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000104void DesktopWindow::handleClose(Fl_Widget *wnd, void *data)
105{
106 exit_vncviewer();
107}