[Message Prev][Message Next][Thread Prev][Thread Next][Message Index][Thread Index]

Re: escape from full-screen mode?



> I find no obvious way to "pause" or "iconize" rdesktop in order to do this.
> Is there such a mechanism available?  I tried various variants of [Esc],
> [Alt]+various keys, etc.

There was a patch that I remade against version 1.1.0 that allows you to
exit fullscreen via Ctrl+Alt+Esc or hitting on the lower right of the screen
(ifdef MAGIC_PIXEL) I'm attaching it.

Regards...
--- rdesktop-1.1.0.orig/rdesktop.c
+++ rdesktop-1.1.0/rdesktop.c
@@ -40,6 +40,7 @@
 BOOL encryption = True;
 BOOL desktop_save = True;
 BOOL fullscreen = False;
+BOOL magickey = True;
 
 /* Display usage information */
 static void
@@ -58,7 +59,8 @@
 	printf("   -b: force bitmap updates\n");
 	printf("   -e: disable encryption (French TS)\n");
 	printf("   -m: do not send motion events\n");
-	printf("   -l: do not request licence\n\n");
+	printf("   -l: do not request licence\n");
+	printf("   -M: disable the \"Ctrl-Alt-Esc\" magic key\n\n");
 }
 
 /* Client program */
@@ -152,7 +154,9 @@
 			case 'l':
 				licence = False;
 				break;
-
+			case 'M':
+				magickey = False;
+				break;
 			case 'h':
 			case '?':
 			default:
--- rdesktop-1.1.0.orig/xwin.c
+++ rdesktop-1.1.0/xwin.c
@@ -23,15 +23,18 @@
 #include <time.h>
 #include <errno.h>
 #include "rdesktop.h"
+#include <signal.h>
 
 extern int width;
 extern int height;
 extern BOOL sendmotion;
 extern BOOL fullscreen;
+extern BOOL magickey;
 
 static Display *display;
 static int x_socket;
 static Window wnd;
+static Window wnd2; /* Helper window, used only in fullscreen mode */
 static GC gc;
 static Visual *visual;
 static int depth;
@@ -178,6 +181,28 @@
 	return colour;
 }
 
+void
+sigusr_func (int s)
+{
+  switch (s)
+
+  {
+  case SIGUSR1:
+    DEBUG (("Received SIGUSR1, unmapping window.\n"));
+    XUnmapWindow (display, wnd);
+    break;
+  case SIGUSR2:
+    DEBUG (("Received SIGUSR2, mapping window.\n"));
+    XMapRaised (display, wnd);
+    XIconifyWindow (display, wnd2, DefaultScreen(display));
+    break;
+  default:
+    break;
+  }
+
+  XFlush (display);
+}
+
 BOOL
 ui_create_window(char *title)
 {
@@ -189,6 +214,8 @@
 	Screen *screen;
 	uint16 test;
 	int i;
+	XWMHints wmhints;
+	static struct sigaction sigusr_act;
 
 	display = XOpenDisplay(NULL);
 	if (display == NULL)
@@ -246,12 +273,27 @@
 		attribs.override_redirect = True;
 		width = WidthOfScreen(screen);
 		height = HeightOfScreen(screen);
+   wnd2 =
+     XCreateWindow (display, DefaultRootWindow (display), 0, 0, 1, 1,
+                 0, CopyFromParent, InputOutput, CopyFromParent,
+                 CWBackingStore | CWBackPixel , &attribs);
+
+   /* Prepare signal handler for SIGUSR1 and SIGUSR2 */
+   sigusr_act.sa_handler = sigusr_func;
+
 	}
 	else
 	{
 		attribs.override_redirect = False;
+   /* Prepare signal handler for SIGUSR1 and SIGUSR2 */
+   sigusr_act.sa_handler = SIG_IGN;
 	}
 
+  /* Install signal handler for SIGUSR1 and SIGUSR2 */
+  sigfillset(&(sigusr_act.sa_mask));
+  sigaction(SIGUSR1, &sigusr_act, NULL);
+  sigaction(SIGUSR2, &sigusr_act, NULL);
+
 	width = (width + 3) & ~3; /* make width a multiple of 32 bits */
 
 	wnd = XCreateWindow(display, RootWindowOfScreen(screen),
@@ -262,6 +304,9 @@
 
 	XStoreName(display, wnd, title);
 
+   if (fullscreen)
+   XStoreName (display, wnd2, title);
+
 	classhints = XAllocClassHint();
 	if (classhints != NULL)
 	{
@@ -291,8 +336,19 @@
 		input_mask |= ExposureMask;
 
 	XSelectInput(display, wnd, input_mask);
+	if (fullscreen)
+	  XSelectInput (display, wnd2, input_mask | StructureNotifyMask & ~(KeyPressMask | KeyReleaseMask));
 	gc = XCreateGC(display, wnd, 0, NULL);
 
+  if (fullscreen)
+  {
+    /* Start helper window in iconified state */
+    wmhints.flags = StateHint;
+    wmhints.initial_state = IconicState;
+    XSetWMHints (display, wnd2, &wmhints);
+    XMapWindow( display, wnd2 );
+  }
+
 	if (ownbackstore)
 		backstore = XCreatePixmap(display, wnd, width, height, depth);
 
@@ -308,6 +364,8 @@
 
 	XFreeGC(display, gc);
 	XDestroyWindow(display, wnd);
+	if (fullscreen)
+	  XDestroyWindow (display, wnd2);      
 	XCloseDisplay(display);
 	display = NULL;
 }
@@ -392,7 +450,19 @@
 	if (display == NULL)
 		return;
 
-	while (XCheckWindowEvent(display, wnd, ~0, &event))
+  if (fullscreen)
+    while (XCheckWindowEvent (display, wnd2, ~0, &event))
+    {
+      switch (event.type)
+
+      {
+      case MapNotify:
+          sigusr_func(SIGUSR2);
+          break;
+      }
+    }
+
+	while (XCheckMaskEvent (display, ~0, &event))
 	{
 		ev_time = time(NULL);
 
@@ -403,6 +473,15 @@
 				if (scancode == 0)
 					break;
 
+          /* When in fullscreen, unmap window on Ctrl-Alt-Escape */
+        if (magickey && fullscreen && (scancode == 0x01) &&
+            (event.xkey.state & (ControlMask | Mod1Mask )) ==
+              (ControlMask|Mod1Mask)  )
+        {
+            DEBUG (("Ctrl-Alt-ESC pressed\n"));
+            sigusr_func(SIGUSR1);
+        }
+
 				rdp_send_input(ev_time, RDP_INPUT_SCANCODE, 0,
 					       scancode, 0);
 				break;
@@ -419,6 +498,15 @@
 
 			case ButtonPress:
 				button = xwin_translate_mouse(event.xbutton.button);
+#ifdef MAGIC_PIXEL
+        /* Iconify rdesktop when left-clicking in lower right corner */
+        if (fullscreen && (event.xbutton.button == 1) &&
+              (event.xbutton.x+1 == width) && (event.xbutton.y+1 == height))
+          {
+              sigusr_func(SIGUSR1);
+              break;
+          }
+#endif
 				if (button == 0)
 					break;