From 0d93ce342c5b063c7cc36fcb7fb31fbecbbad608 Mon Sep 17 00:00:00 2001 From: Yonit Halperin Date: Thu, 12 Nov 2009 19:57:34 +0200 Subject: spice client: sticky Alt activation when holding an Alt key Additional changes that were required for the feature: 1) focusing on the pointed window in full screen mode 2) In X11 - handling events that occur during keyboard ungrabbing 3) In X11 - handling Leave/Enter Notify events that occur during keyboard grabbing/ungrabbing 4) In X11 - fix for focus events that are handled in the wrong order (happens when focus events occur during grabbing the keyboard) 5) In X11 - ignoring key release events during key holding 6) In Windows - synchronizing keyboard release events that occured during a modal loop --- client/application.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'client/application.h') diff --git a/client/application.h b/client/application.h index 91afb54e..c576dba6 100644 --- a/client/application.h +++ b/client/application.h @@ -90,6 +90,25 @@ enum CanvasOption { #endif }; +class StickyKeyTimer: public Timer { +public: + virtual void response(AbstractProcessLoop& events_loop); +}; + +typedef struct StickyInfo { + bool trace_is_on; + bool sticky_mode; + bool key_first_down; // True when (1) a potential sticky key is pressed, + // and none of the other keys are pressed and (2) in the moment + // of pressing, _sticky_mode is false. When the key is up + // for the first time, it is set to false. + bool key_down; // The physical state of the sticky key. Valid only till + // stickiness is removed. + RedKey key; // the key that is currently being traced, or, + // if _sticky mode is on, the sticky key + AutoRef timer; +} StickyInfo; + class Application : public ProcessLoop, public Platform::EventListener, public Platform::DisplayModeListner, @@ -114,6 +133,8 @@ public: void on_key_up(RedKey key); void on_deactivate_screen(RedScreen* screen); void on_activate_screen(RedScreen* screen); + void on_start_screen_key_interception(RedScreen* screen); + void on_stop_screen_key_interception(RedScreen* screen); virtual void on_app_activated(); virtual void on_app_deactivated(); virtual void on_monitors_change(); @@ -180,6 +201,13 @@ private: int get_hotkeys_commnad(); bool is_key_set_pressed(const HotkeySet& key_set); bool is_cad_pressed(); + void do_on_key_up(RedKey key); + + // returns the press value before operation (i.e., if it was already pressed) + bool press_key(RedKey key); + bool unpress_key(RedKey key); + void reset_sticky(); + static bool is_sticky_trace_key(RedKey key); static void init_logger(); static void init_globals(); @@ -188,6 +216,7 @@ private: friend class ConnectionErrorEvent; friend class MonitorsQuery; friend class AutoAbort; + friend class StickyKeyTimer; private: RedClient _client; @@ -201,12 +230,16 @@ private: int _exit_code; RedScreen* _active_screen; KeyInfo _key_table[REDKEY_NUM_KEYS]; + int _num_keys_pressed; HotKeys _hot_keys; CommandsMap _commands_map; std::auto_ptr _gui_layer; InputsHandler* _inputs_handler; const MonitorsList* _monitors; std::wstring _title; + bool _splash_mode; + bool _sys_key_intercept_mode; + StickyInfo _sticky_info; std::vector _canvas_types; AutoRef _app_menu; }; -- cgit