FreeRDP / FreeRDP-old

DEPRECATED VERSION - Check https://github.com/FreeRDP/FreeRDP : FreeRDP is a free remote desktop protocol client

Home Page:http://www.freerdp.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Release keyboard grab with Ctrl-Alt

eduardobeloni opened this issue · comments

+1. This is definitely the most important feature that I need in freerdp.

Please make it possible to bind "release keyboard grab" to some predefined combination of keys, preferably a combination of keys that the user can specify.

Without this feature I cannot switch from rdestop to freerdp.

+1

Maybe it could be bound to the right Ctrl key like in Virtualbox by default.

edit:
Just saw, that this is implemented in Remmina which uses FreeRDP as Backend.

+1 this is the best part of Remmina, the right Ctrl key. #931 is related.
Essentially, while staying fullscreen, you can quickly hit this key, then eg: "Ctrl+Alt+Left" to switch to another workspace, without using a mouse.

+1 Indeed. Switched from Remmina to xfreerdp because of multi-monitor support, and the most needed feature is this one. Interestingly enough, exactly for the same scenario: "Right-Ctrl", "Ctrl+Alt+Up".

I'm trying to implement the feature in xfreerdp. I'm not an expert in XLib, though. I was able to use XUngrabKeyboard successfully, and binded it to different keys trying to find the best. However, I'm facing some problems.
I can't handle the fullscreen mode at all. It seems like I can ungrab the keyboard while in fullscreen xfreerdp session, and I can even switch between workspaces and applications in gnome, but xfreerdp screens are sort of stuck to my position, and are always on top: e.g., I press "Right Ctrl" to ungrab the keyboard, then I switch to another gnome workspace with "Ctrl+Alt+Up" (gnome indicator does not appear) and I can see "Alt+Tab" application switcher on top of my xfreerdp session. However, when I try to switch to another application, it seems like the focus is gone from xfreerdp, but it's still always on top.
So far I came to solution of using "Ctrl+Alt" for temporary ungrabbing in window-mode. Example scenario: I work in fullscreen xfreerdp session, then press "Ctrl+Alt+Enter" to exit fullscreen mode, then hit "Ctrl+Alt+" (yes, I have to release Crtl+Alt keys first) to perform some Gnome stuff (e.g. lock screen with Ctrl+Alt+L, or switch workspace with Ctrl+Alt+ArrowKey).
Does anybody have a better idea of how to handle this, and get rid of this "exit fullscreen" redundant step? I can share my solution as a git patch if anybody is interested.

commented

@khvMX could you share your solution?

Here's a git patch:
https://gist.github.com/khvMX/66e0b14c71a32aca1bc7
What it does is simply ungrabbing the keyboard when not in fullscreen with a "Right Ctrl" key. It has currently at least 2 problems:

  1. The fullscreen mode implementation seems a bit weird for me. Consider a scenario: I have 2 monitors: on the left hand side is a fullscreen-one-monitor-xfreerdp session is running, on the right hand side - usual GNOME 3 environment. In Remmina if I move the mouse to the GNOME environment and switch the workspace, the Remmina's window stays on its workspace as expected. In contrast, xfreerdp window will be stuck to left monitor no matter what workspace you are switching to. For exactly the same reason, if I just ungrab the keyboard, the xfreerdp window will be still stuck on top of everything and will chase me over all workspaces. In principle, if we'd change the way xfreerdp renders in fullscreen mode, we could just ungrab the keyboard like in remmina even in fullscreen, and switch.
  2. In windowed mode it works almost as expected, except that the keyboard is automatically grabbed all the time (e.g. if the mouse cursor is still inside the xfreerdp window, when we ungrab the keyboard, it will be grabbed back after basically any action). It actually suffices for my purposes: hit "Right Ctrl" to ungrab, press "Ctrl+Alt+ArrowKey" to switch the workspace.
    Current workaround for the fullscreen problem is to exit fullscreen mode with "Ctrl+Alt+Enter", then do whatever is needed in windowed mode. Actually, automatic grabbing sometimes helps a bit, e.g. when switching back to the workspace with xfreerdp I just hit "Ctrl+Alt+Enter" to enter fullscreen mode and continue to work via RDP.

@khvMX Any progress on fullscreen mode? I have the exact same problem as you. I will be implementing your patch, as it is better than nothing! :)

@Rudedog9d Hi. No, didn't touch it, works well for me so far :) There are majorly one thing that still annoys me, namely:
each time you exit fullscreen mode the RDP window moves down to the amount of pixels which is roughly equal to the window title bar, resulting in window coming down with a time :D That is, when I switch back and forth between Gnome Environment and RDP, i have to grab this freaking RDP window with a mouse and push it up every once in a while :D

Ok, cool! I was thinking that would be very frustrating aswell, but still very good piece of technology here! I may look into expanding upon your patch this semester at school, I will keep you updated if I do :)

Thanks for the patch you did create!

@khvMX I have a version that works with fullscreen :) It's not perfect, maybe you can help improve it - I reused code that already existed in the source (although it appears to not have existed in yours). Using ctrl+alt+C releases the keyboard for a single action, such as switching desktops. The fix:
Basically just add your line XUngrabKeyboard(xfc->display, CurrentTime); to this section:

    if ((keysym == XK_c) || (keysym == XK_C))
    {
        if (mod.Ctrl && mod.Alt)
                {
                        /* Ctrl-Alt-C: toggle control */
                        xf_toggle_control(xfc);
+                       XUngrabKeyboard(xfc->display, CurrentTime);
                        return TRUE;
                }
        }
#if 0 /* set to 1 to enable multi touch gesture simulation via keyboard */

That section is just below the bit about toggling fullscreen. Please let me know if you have questions, I fear that was not particularly clear! I don't understand where the 'C' key comes from (the CTRL and ALT key portions are pretty obvious), and so I'm not sure how to change the key binding to something like simply 'Right CTRL'.

commented

@Rudedog9d the first line of the patch "if ((keysym == XK_c) || (keysym == XK_C))" introduced the (lower and uppercase) 'c' via keysyms https://tronche.com/gui/x/xlib/input/keyboard-encoding.html

Hmm, seems like this
xf_toggle_control(xfc);
does the trick of releasing control keys in fullscreen mode. With this line it works with my patch also with Right Ctrl in both fullscreen and windowed mode.
My Full patch for Right Ctrl: https://gist.github.com/khvMX/1519678698b48e6bfbe5dc69dc4eeca6
I still don't have the feeling that this would be enough for a pull request. At least the combination of keys must be somehow configurable by the user. Does anyone here has an overview of the whole thing to create a pull request?

@Rudedog9d
Just found out that in my patch, using
if (mod.Ctrl && mod.Alt)
instead of
if (mod.RightCtrl)
is much much easier in the end. I've been using right ctrl in fullscreen mode for some things (e.g. ctrl+shift+arrow to select another word in IDE), so this patch would break it. Now I can switch between desktops and even lock a screen (Ctrl+Alt+L) without even leaving RDP Window :) Thumbs up for helping me find the solution!

@kevinf28 Thank you, that makes more sense now!
@khvMX No problem, glad I could help! :) And thank YOU for pointing me in the right direction... I think I will end up using 'Super+ESC' or similiar for my escape sequence, as I already use Super for most of my window management keystrokes. I'm not sure how the whole pull thing works, but I noticed we are in the 'FreeRDP-old' repo - Our little hack probably wouldn't make it far anyhow :P

I would love for xfreerdp to send ctrl+alt+up and ctrl+alt+down to my linux host (ubuntu) so I can switch to another workspace. I'm using fullscreen xfreerdp on my 2nd workspace. This works great in the Citrix Receiver.

It's quite cumbersome to have to switch back to windowed mode using ctrl+alt+enter and move the mouse outside the xfreerdp window.

The patch seems to be here, so just merge it? Or am I being to practical :-P