blob: ec30a826b63c4cc618ccffc4a79c51ab77bd3e7d [file] [log] [blame]
Constantin Kaplinsky2844fd52008-04-14 08:02:25 +00001/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
2 *
3 * This is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This software is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this software; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 * USA.
17 */
18
DRCc5dc0382011-05-13 21:42:14 +000019package com.tigervnc.rfb;
Constantin Kaplinsky90d8a502008-04-14 09:45:50 +000020
DRCc5dc0382011-05-13 21:42:14 +000021import com.tigervnc.rdr.*;
Brian Hinze7681412011-05-17 21:00:34 +000022import java.util.*;
Constantin Kaplinsky2844fd52008-04-14 08:02:25 +000023
DRCc5dc0382011-05-13 21:42:14 +000024public class CMsgWriterV3 extends CMsgWriter {
25
26 public CMsgWriterV3(ConnParams cp_, OutStream os_) { super(cp_, os_); }
27
28 public void writeClientInit(boolean shared) {
29 os.writeU8(shared?1:0);
30 endMsg();
Constantin Kaplinsky2844fd52008-04-14 08:02:25 +000031 }
32
DRCc5dc0382011-05-13 21:42:14 +000033 public void startMsg(int type) {
34 os.writeU8(type);
35 }
Constantin Kaplinsky2844fd52008-04-14 08:02:25 +000036
DRCc5dc0382011-05-13 21:42:14 +000037 public void endMsg() {
38 os.flush();
Constantin Kaplinsky2844fd52008-04-14 08:02:25 +000039 }
Brian Hinze7681412011-05-17 21:00:34 +000040
41 public void writeSetDesktopSize(int width, int height,
42 ScreenSet layout)
43 {
44 if (!cp.supportsSetDesktopSize)
45 throw new Exception("Server does not support SetDesktopSize");
46
47 startMsg(MsgTypes.msgTypeSetDesktopSize);
48 os.pad(1);
49
50 os.writeU16(width);
51 os.writeU16(height);
52
53 os.writeU8(layout.num_screens());
54 os.pad(1);
55
56 for (Iterator iter = layout.screens.iterator(); iter.hasNext(); ) {
57 Screen refScreen = (Screen)iter.next();
58 os.writeU32(refScreen.id);
59 os.writeU16(refScreen.dimensions.tl.x);
60 os.writeU16(refScreen.dimensions.tl.y);
61 os.writeU16(refScreen.dimensions.width());
62 os.writeU16(refScreen.dimensions.height());
63 os.writeU32(refScreen.flags);
64 }
65
66 endMsg();
67 }
Constantin Kaplinsky2844fd52008-04-14 08:02:25 +000068}