Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 1 | /* 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 Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 24 | #include <rfb/LogWriter.h> |
| 25 | |
| 26 | #include "DesktopWindow.h" |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 27 | #include "i18n.h" |
Pierre Ossman | 89f868a | 2011-04-11 11:59:31 +0000 | [diff] [blame] | 28 | |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 29 | using namespace rfb; |
| 30 | |
| 31 | extern void exit_vncviewer(); |
| 32 | |
| 33 | static rfb::LogWriter vlog("DesktopWindow"); |
| 34 | |
| 35 | DesktopWindow::DesktopWindow(int w, int h, const char *name, |
| 36 | const rfb::PixelFormat& serverPF, |
| 37 | CConn* cc_) |
Pierre Ossman | d50b3d1 | 2011-04-15 07:46:56 +0000 | [diff] [blame^] | 38 | : Fl_Window(w, h) |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 39 | { |
Pierre Ossman | d50b3d1 | 2011-04-15 07:46:56 +0000 | [diff] [blame^] | 40 | viewport = new Viewport(w, h, serverPF, cc_); |
| 41 | |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 42 | callback(handleClose, this); |
| 43 | |
| 44 | setName(name); |
| 45 | |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 46 | show(); |
| 47 | } |
| 48 | |
| 49 | |
| 50 | DesktopWindow::~DesktopWindow() |
| 51 | { |
Pierre Ossman | d50b3d1 | 2011-04-15 07:46:56 +0000 | [diff] [blame^] | 52 | // FLTK automatically deletes all child widgets, so we shouldn't touch |
| 53 | // them ourselves here |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | |
| 57 | void DesktopWindow::setServerPF(const rfb::PixelFormat& pf) |
| 58 | { |
Pierre Ossman | d50b3d1 | 2011-04-15 07:46:56 +0000 | [diff] [blame^] | 59 | viewport->setServerPF(pf); |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | |
| 63 | const rfb::PixelFormat &DesktopWindow::getPreferredPF() |
| 64 | { |
Pierre Ossman | d50b3d1 | 2011-04-15 07:46:56 +0000 | [diff] [blame^] | 65 | return viewport->getPreferredPF(); |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | |
| 69 | // Cursor stuff |
| 70 | |
| 71 | void DesktopWindow::setCursor(int width, int height, const Point& hotspot, |
| 72 | void* data, void* mask) |
| 73 | { |
| 74 | } |
| 75 | |
| 76 | |
| 77 | void 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 Ossman | d50b3d1 | 2011-04-15 07:46:56 +0000 | [diff] [blame^] | 87 | |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 88 | void DesktopWindow::setColourMapEntries(int firstColour, int nColours, |
| 89 | rdr::U16* rgbs) |
| 90 | { |
Pierre Ossman | d50b3d1 | 2011-04-15 07:46:56 +0000 | [diff] [blame^] | 91 | viewport->setColourMapEntries(firstColour, nColours, rgbs); |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | |
| 95 | // Copy the areas of the framebuffer that have been changed (damaged) |
| 96 | // to the displayed window. |
| 97 | |
| 98 | void DesktopWindow::updateWindow() |
| 99 | { |
Pierre Ossman | d50b3d1 | 2011-04-15 07:46:56 +0000 | [diff] [blame^] | 100 | viewport->updateWindow(); |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 104 | void DesktopWindow::handleClose(Fl_Widget *wnd, void *data) |
| 105 | { |
| 106 | exit_vncviewer(); |
| 107 | } |