From 32d5382f9d6cf9e6b26b0194ee3c2b8c102f35cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20=C3=85strand?= Date: Mon, 26 Aug 2002 17:14:04 +0000 Subject: [PATCH] Alt modifier for fullscreen toggle git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/trunk/rdesktop@101 423420c4-83ab-492f-b58f-81f9feb106b5 --- proto.h | 5 ++++- xwin.c | 46 ++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/proto.h b/proto.h index d37594b..2711350 100644 --- a/proto.h +++ b/proto.h @@ -80,8 +80,11 @@ void ensure_remote_modifiers(uint32 ev_time, key_translation tr); void rdp_send_scancode(uint32 time, uint16 flags, uint16 scancode); /* xwin.c */ BOOL ui_init(void); -BOOL ui_create_window(); +void ui_create_window_obj(int xpos, int ypos, int width, int height, int valuemask); +BOOL ui_create_window(void); void ui_destroy_window(void); +void reset_keys(void); +void toggle_fullscreen(void); void ui_select(int rdp_socket); void ui_move_pointer(int x, int y); HBITMAP ui_create_bitmap(int width, int height, uint8 * data); diff --git a/xwin.c b/xwin.c index 0f631e8..659e0f5 100644 --- a/xwin.c +++ b/xwin.c @@ -247,6 +247,41 @@ close_inputmethod(void) } } +static BOOL +get_key_state(int keysym) +{ + int keysymMask = 0, modifierpos, key; + Window wDummy1, wDummy2; + int iDummy3, iDummy4, iDummy5, iDummy6; + unsigned int current_state; + int offset; + + XModifierKeymap *map = XGetModifierMapping(display); + KeyCode keycode = XKeysymToKeycode(display, keysym); + + if (keycode == NoSymbol) + return False; + + for (modifierpos = 0; modifierpos < 8; modifierpos++) + { + offset = map->max_keypermod * modifierpos; + + for (key = 0; key < map->max_keypermod; key++) + { + if (map->modifiermap[offset + key] == keycode) + keysymMask = 1 << modifierpos; + } + } + + XQueryPointer(display, DefaultRootWindow(display), &wDummy1, + &wDummy2, &iDummy3, &iDummy4, &iDummy5, &iDummy6, ¤t_state); + + XFreeModifiermap(map); + + return (current_state & keysymMask) ? True : False; +} + + BOOL ui_init() { @@ -266,7 +301,7 @@ ui_init() return True; } -BOOL +void ui_create_window_obj(int xpos, int ypos, int width, int height, int valuemask) { XClassHint *classhints; @@ -542,12 +577,15 @@ xwin_process_events() str, sizeof(str), &keysym, NULL); } - /* FIXME needs alt modifier */ if (keysym == XK_Break) /* toggle full screen */ { - toggle_fullscreen(); - break; + if (get_key_state(XK_Alt_L) || get_key_state(XK_Alt_R)) + { + toggle_fullscreen(); + break; + } } + ksname = get_ksname(keysym); DEBUG_KBD(("\nKeyPress for (keysym 0x%lx, %s)\n", keysym, ksname));