01: ///////////////////////////////////////////////////////////////////////////////
02: //
03: // This program is free software; you can redistribute it and/or modify
04: // it under the terms of the GNU General Public License and GNU Library
05: // General Public License as published by the Free Software Foundation;
06: // either version 2, or (at your option) any later version.
07: //
08: // This program is distributed in the hope that it will be useful,
09: // 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 and GNU Library General Public License
12: // for more details.
13: //
14: // You should have received a copy of the GNU General Public License
15: // and GNU Library General Public License along with this program; if
16: // not, write to the Free Software Foundation, 675 Mass Ave, Cambridge,
17: // MA 02139, USA.
18: //
19: ///////////////////////////////////////////////////////////////////////////////
20:
21: package org.rdesktop.server.rdp;
22:
23: import java.io.*;
24: import java.awt.*;
25: import java.awt.image.*;
26:
27: import javax.imageio.ImageIO;
28:
29: public class RdpDesktopCanvas extends RdpAbstractDesktopCanvas {
30: private Robot m_robot = null;
31:
32: protected RdpDesktopCanvas(int width, int height) {
33: super (width, height);
34: }
35:
36: protected Cursor createCustomCursor(Image wincursor, Point p,
37: String s, int cache_idx) {
38: return Toolkit.getDefaultToolkit().createCustomCursor(
39: wincursor, p, "");
40: }
41:
42: public void movePointer(int x, int y) {
43: Point p = this .getLocationOnScreen();
44: x = x + p.x;
45: y = y + p.y;
46: m_robot.mouseMove(x, y);
47: }
48:
49: public void addNotify() {
50: super .addNotify();
51:
52: if (m_robot == null) {
53: try {
54: m_robot = new Robot();
55: } catch (AWTException e) {
56: e.printStackTrace();
57: }
58: }
59: }
60:
61: public void update(Graphics g) {
62: Rectangle r = g.getClipBounds();
63:
64: int width = r.width;
65: if (width > m_width) {
66: width = m_width;
67: }
68:
69: int height = r.height;
70: if (height > m_height) {
71: height = m_height;
72: }
73:
74: g.drawImage(m_backstore.getSubimage(r.x, r.y, width, height),
75: r.x, r.y, null);
76: }
77: }
|