Package: rdesktop / 1.8.6-2~deb9u1

01_paging.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
Description: <short summary of the patch>
 .
Author: Laszlo Boszormenyi (GCS) <gcs@debian.org>
Last-Update: 2014-08-31

---

--- rdesktop-1.8.2.orig/proto.h
+++ rdesktop-1.8.2/proto.h
@@ -267,7 +267,7 @@ RD_BOOL get_key_state(unsigned int state
 RD_BOOL ui_init(void);
 void ui_init_connection(void);
 void ui_deinit(void);
-RD_BOOL ui_create_window(void);
+RD_BOOL ui_create_window(RD_BOOL ToggleFullscreen);
 void ui_resize_window(void);
 void ui_destroy_window(void);
 RD_BOOL ui_have_window(void);
--- rdesktop-1.8.2.orig/rdesktop.c
+++ rdesktop-1.8.2/rdesktop.c
@@ -136,6 +136,13 @@ RD_BOOL g_reconnect_loop = False;
 uint8 g_client_random[SEC_RANDOM_SIZE];
 RD_BOOL g_pending_resize = False;
 
+/* For viewport mode */
+int xo = 0;
+int yo = 0;
+int perm_xo = 0; // Safe to keep in 0 for now
+int perm_yo = 0;
+RD_BOOL viewport_mode = False;
+
 #ifdef WITH_RDPSND
 RD_BOOL g_rdpsnd = False;
 #endif
@@ -160,6 +167,7 @@ void
 rdp2vnc_connect(char *server, uint32 flags, char *domain, char *password,
 		char *shell, char *directory);
 #endif
+
 /* Display usage information */
 static void
 usage(char *program)
@@ -692,6 +700,8 @@ main(int argc, char *argv[])
 					g_pos |= (*p == '-') ? 4 : 1;
 					g_ypos = strtol(p, NULL, 10);
 				}
+				perm_xo = xo;
+				perm_yo = yo;
 
 				break;
 
@@ -1763,7 +1773,7 @@ rd_create_ui()
 	/* only create a window if we dont have one intialized */
 	if (!ui_have_window())
 	{
-		if (!ui_create_window())
+		if (!ui_create_window(False))
 			exit(EX_OSERR);
 	}
 }
--- rdesktop-1.8.2.orig/xwin.c
+++ rdesktop-1.8.2/xwin.c
@@ -57,7 +57,11 @@ Time g_last_gesturetime;
 static int g_x_socket;
 static Screen *g_screen;
 Window g_wnd;
-
+extern BOOL viewport_mode;
+BOOL viewport_keys_enabled = False;
+BOOL viewport_mode_locked = False;
+Window g_viewport_wnd = 0;
+uint32 g_embed_wnd;
 /* SeamlessRDP support */
 typedef struct _seamless_group
 {
@@ -142,6 +146,27 @@ static RD_BOOL g_compatible_arch;
    ('host' is the machine running rdesktop; the host simply memcpy's
     so its endianess doesn't matter)
  */
+static Cursor viewportCursor;
+static int viewportLastX;
+static int viewportLastY;
+int g_viewport_width;
+int g_viewport_height;
+int g_saved_viewport_width = 0;
+int g_saved_viewport_height= 0;
+int g_saved_viewport_x= 0;
+int g_saved_viewport_y= 0;
+int g_saved_wnd_x = 0;
+int g_saved_wnd_y = 0;
+int g_wnd_x;
+int g_wnd_y;
+int viewport_x1;
+int viewport_y1;
+int xo;
+int yo;
+extern int perm_xo;
+extern int perm_yo;
+
+void MoveViewport(int hShift, int vShift);
 static RD_BOOL g_no_translate_image = False;
 
 /* endianness */
@@ -532,7 +557,7 @@ mwm_hide_decorations(Window wnd)
 		return;
 	}
 
-	XChangeProperty(g_display, wnd, hintsatom, hintsatom, 32, PropModeReplace,
+	XChangeProperty(g_display, g_viewport_wnd ? g_viewport_wnd : g_wnd, hintsatom, hintsatom, 32, PropModeReplace,
 			(unsigned char *) &motif_hints, PROP_MOTIF_WM_HINTS_ELEMENTS);
 
 }
@@ -2003,7 +2028,7 @@ get_input_mask(long *input_mask)
 }
 
 RD_BOOL
-ui_create_window(void)
+ui_create_window(RD_BOOL ToggleFullscreen)
 {
 	uint8 null_pointer_mask[1] = { 0x80 };
 	uint8 null_pointer_data[24] = { 0x00 };
@@ -2014,6 +2039,7 @@ ui_create_window(void)
 	int wndwidth, wndheight;
 	long input_mask, ic_input_mask;
 	XEvent xevent;
+	int x1, y1;
 
 	wndwidth = g_fullscreen ? WidthOfScreen(g_screen) : g_width;
 	wndheight = g_fullscreen ? HeightOfScreen(g_screen) : g_height;
@@ -2048,7 +2074,75 @@ ui_create_window(void)
 		XSetForeground(g_display, g_gc, BlackPixelOfScreen(g_screen));
 		XFillRectangle(g_display, g_backstore, g_gc, 0, 0, g_width, g_height);
 	}
-
+	if ((((g_width >= WidthOfScreen(g_screen)*1.05)) || 
+	    (g_height >= (HeightOfScreen(g_screen)*1.1))) && (ToggleFullscreen))
+	{
+	    viewport_mode_locked = True;
+	    viewport_keys_enabled = True;
+	}
+	
+        if ((!g_embed_wnd) && (viewport_mode))
+	{
+	    if (g_fullscreen)
+	    {
+        	x1 = (WidthOfScreen(g_screen) - g_width)/2;
+        	y1 = (HeightOfScreen(g_screen) - g_height)/2;
+        	g_viewport_width = (WidthOfScreen(g_screen));
+        	g_viewport_height= (HeightOfScreen(g_screen));
+	    }
+            else
+	    {
+		if (!ToggleFullscreen)
+		{
+		    xo = g_saved_viewport_x;
+        	    yo = g_saved_viewport_y;
+		}
+		if (g_saved_wnd_x == 0 && g_saved_wnd_y == 0)
+        	{
+        	    x1 = y1 = 0;
+        	}
+        	else
+        	{
+            	    x1 = g_saved_wnd_x;
+        	    y1 = g_saved_wnd_y;
+        	}
+
+        	if (g_saved_viewport_width && g_saved_viewport_height)
+        	{
+            	    g_viewport_width = g_saved_viewport_width;
+            	    g_viewport_height = g_saved_viewport_height;
+        	}
+        	else
+        	{
+    		    g_viewport_width = wndwidth < (WidthOfScreen(g_screen)*1.05) ? wndwidth : WidthOfScreen(g_screen)*3/4;
+    		    g_viewport_height= wndheight< (HeightOfScreen(g_screen)*1.1) ? wndheight: HeightOfScreen(g_screen)*3/4;
+		    g_viewport_width = g_viewport_width  & ~3;
+		}
+    	    }
+	    
+	    attribs.override_redirect = g_fullscreen;
+	    
+	    if (viewport_mode)
+	    {
+		if ((xo == 0) && (yo == 0))
+		{
+		    xo = (WidthOfScreen(g_screen) - g_viewport_width)/2;
+        	    yo = (HeightOfScreen(g_screen) - g_viewport_height)/2;
+		}
+		g_viewport_wnd = XCreateWindow (g_display, RootWindowOfScreen(g_screen), xo, yo, g_viewport_width, g_viewport_height, 
+						0, g_depth, InputOutput, g_visual, CWBackPixel | CWBackingStore | CWOverrideRedirect | CWColormap | CWBorderPixel, &attribs);
+						
+    		XSelectInput(g_display, g_viewport_wnd, ButtonPressMask | KeyPressMask |
+                		StructureNotifyMask | (g_fullscreen ? EnterWindowMask : 0) |
+                    		    (g_grab_keyboard ? (EnterWindowMask | LeaveWindowMask) : 0));
+				    
+		XReparentWindow (g_display, g_wnd, g_viewport_wnd, (ToggleFullscreen && g_fullscreen) ? perm_xo : 0, (ToggleFullscreen && g_fullscreen) ? perm_yo : 0);
+	    }
+	}
+
+	/* Check XStoreName consistency */
+		
+	XStoreName(g_display, g_viewport_wnd ? g_viewport_wnd : g_wnd, g_title);
 	XStoreName(g_display, g_wnd, g_title);
 	ewmh_set_wm_name(g_wnd, g_title);
 
@@ -2059,7 +2153,7 @@ ui_create_window(void)
 	if (classhints != NULL)
 	{
 		classhints->res_name = classhints->res_class = "rdesktop";
-		XSetClassHint(g_display, g_wnd, classhints);
+		XSetClassHint(g_display, g_viewport_wnd ? g_viewport_wnd : g_wnd, classhints);
 		XFree(classhints);
 	}
 
@@ -2071,7 +2165,7 @@ ui_create_window(void)
 			sizehints->flags |= PPosition;
 		sizehints->min_width = sizehints->max_width = g_width;
 		sizehints->min_height = sizehints->max_height = g_height;
-		XSetWMNormalHints(g_display, g_wnd, sizehints);
+		XSetWMNormalHints(g_display, g_viewport_wnd ? g_viewport_wnd : g_wnd, sizehints);
 		XFree(sizehints);
 	}
 
@@ -2096,7 +2190,12 @@ ui_create_window(void)
 #ifdef HAVE_XRANDR
 	XSelectInput(g_display, RootWindowOfScreen(g_screen), StructureNotifyMask);
 #endif
-	XMapWindow(g_display, g_wnd);
+	if (viewport_mode)
+	{
+    	    XMapWindow (g_display, g_viewport_wnd);
+    	}
+	
+	XMapWindow(g_display, g_wnd); 
 
 	/* wait for VisibilityNotify */
 	do
@@ -2172,7 +2271,14 @@ ui_destroy_window(void)
 	if (g_IC != NULL)
 		XDestroyIC(g_IC);
 
-	XDestroyWindow(g_display, g_wnd);
+        if (g_viewport_wnd)
+        {
+	    XDestroyWindow (g_display, g_viewport_wnd);
+        }
+        else
+        {
+	    XDestroyWindow(g_display, g_wnd);
+        }
 	g_wnd = 0;
 
 	if (g_backstore)
@@ -2200,7 +2306,7 @@ xwin_toggle_fullscreen(void)
 
 	ui_destroy_window();
 	g_fullscreen = !g_fullscreen;
-	ui_create_window();
+	ui_create_window(True);
 
 	XDefineCursor(g_display, g_wnd, g_current_cursor);
 
@@ -2431,6 +2537,21 @@ xwin_process_events(void)
 						    xevent.xmotion.y_root - g_move_y_offset);
 					break;
 				}
+				
+                             if (viewportCursor)
+                                {
+                                  /*
+                                   * Pointer is in viewport navigation mode.
+                                   */
+				   
+                                  MoveViewport(viewportLastX - xevent.xmotion.x_root,
+                                                            viewportLastY - xevent.xmotion.y_root);
+
+                                  viewportLastX = xevent.xmotion.x_root;
+                                  viewportLastY = xevent.xmotion.y_root;
+
+                                  break;
+                                }
 
 				if (g_fullscreen && !g_focused)
 					XSetInputFocus(g_display, g_wnd, RevertToPointerRoot,
@@ -3792,6 +3913,83 @@ ui_desktop_restore(uint32 offset, int x,
 
 	XFree(image);
 }
+void MoveViewport(int hShift, int vShift)
+{
+    int newX;
+    int newY;
+    Bool do_move = False;
+    int viewportXSpan = g_viewport_width - g_width;
+    int viewportYSpan = g_viewport_height - g_height;
+
+    if (!g_viewport_wnd)
+    {
+	return;
+    }
+
+  /*
+   * We must keep x coordinate between viewportXSpan and zero, if viewportXSpan
+   * is less then zero. If viewportXSpan is greater or equal to zero, it means
+   * the agent root window has a size smaller than the agent default window.
+   * In this case we keep the old coordinate.
+   */
+
+    if (viewportXSpan < 0)
+    {
+	newX = g_wnd_x - hShift;
+
+	if (newX > 0)
+	{
+	    newX = 0;
+	}
+	else if (newX < viewportXSpan)
+	{
+	    newX = viewportXSpan;
+	}
+    }
+    else if (viewportXSpan == 0)
+    {
+	newX = 0;
+    }
+    else
+    {
+	newX = g_wnd_x;
+    }
+
+    if (viewportYSpan < 0)
+    {
+	newY = g_wnd_y - vShift;
+	if (newY > 0)
+	{
+	    newY = 0;
+	}
+	else if (newY < viewportYSpan)
+	{
+	    newY = viewportYSpan;
+	}
+    }
+    else if (viewportYSpan == 0)
+    {
+	newY = 0;
+    }
+    else
+    {
+	newY = g_wnd_y;
+    }
+    if (newX != g_wnd_x)
+    {
+	g_wnd_x = newX;
+	do_move = True;
+    }
+    if (newY != g_wnd_y)
+    {
+	g_wnd_y = newY;
+	do_move = True;
+    }
+
+    if (do_move)
+	XMoveWindow(g_display, g_wnd, g_wnd_x, g_wnd_y);
+}
+
 
 /* these do nothing here but are used in uiports */
 void