diff options
author | Arnon Gilboa <agilboa@redhat.com> | 2009-12-30 13:41:58 +0200 |
---|---|---|
committer | Yaniv Kamay <ykamay@redhat.com> | 2009-12-30 22:15:02 +0200 |
commit | ea9af22e62fdae7fc0bd707ef60bcf82ec3c4551 (patch) | |
tree | 2de4eb88b9b71c49515b0deb8b2be82bfb992546 /client/windows | |
parent | 02a07b2c067e629749cbe8a9f9cfbfb487a512d7 (diff) | |
download | spice-ea9af22e62fdae7fc0bd707ef60bcf82ec3c4551.tar.gz spice-ea9af22e62fdae7fc0bd707ef60bcf82ec3c4551.tar.xz spice-ea9af22e62fdae7fc0bd707ef60bcf82ec3c4551.zip |
spice: position mouse in primary monitor center after full screen toggle
-move _focused & _pointer_in_window from RedWindow to RedWindow_p's
-move shadow focus & cursor handling to sync()
-add reset_cursor_pos() to Platform
-Monitor set_mode()/restore() use virtual do_set_mode()/do_restore()
Diffstat (limited to 'client/windows')
-rw-r--r-- | client/windows/platform.cpp | 33 | ||||
-rw-r--r-- | client/windows/red_window.cpp | 4 | ||||
-rw-r--r-- | client/windows/red_window_p.h | 2 |
3 files changed, 29 insertions, 10 deletions
diff --git a/client/windows/platform.cpp b/client/windows/platform.cpp index 11f13266..3400811f 100644 --- a/client/windows/platform.cpp +++ b/client/windows/platform.cpp @@ -227,8 +227,6 @@ class WinMonitor: public Monitor { public: WinMonitor(int id, const wchar_t* name, const wchar_t* string); - virtual void set_mode(int width, int height); - virtual void restore(); virtual int get_depth() { return _depth;} virtual Point get_position(); virtual Point get_size() const { Point size = {_width, _height}; return size;} @@ -237,6 +235,8 @@ public: protected: virtual ~WinMonitor(); + virtual void do_set_mode(int width, int height); + virtual void do_restore(); private: void update_position(); @@ -266,7 +266,7 @@ WinMonitor::WinMonitor(int id, const wchar_t* name, const wchar_t* string) WinMonitor::~WinMonitor() { - restore(); + do_restore(); } void WinMonitor::update_position() @@ -362,7 +362,7 @@ bool WinMonitor::best_display_setting(uint32_t width, uint32_t height, uint32_t == DISP_CHANGE_SUCCESSFUL; } -void WinMonitor::set_mode(int width, int height) +void WinMonitor::do_set_mode(int width, int height) { update_position(); if (width == _width && height == _height) { @@ -380,31 +380,37 @@ void WinMonitor::set_mode(int width, int height) update_position(); } -void WinMonitor::restore() +void WinMonitor::do_restore() { if (_active) { _active = false; self_monitors_change++; ChangeDisplaySettingsEx(_dev_name.c_str(), NULL, NULL, 0, NULL); self_monitors_change--; + update_position(); } } static MonitorsList monitors; +static Monitor* primary_monitor = NULL; const MonitorsList& Platform::init_monitors() { ASSERT(monitors.empty()); int id = 0; + Monitor* mon; DISPLAY_DEVICE device_info; DWORD device_id = 0; device_info.cb = sizeof(device_info); while (EnumDisplayDevices(NULL, device_id, &device_info, 0)) { if ((device_info.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) && - !(device_info.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER)) { - monitors.push_back(new WinMonitor(id++, device_info.DeviceName, - device_info.DeviceString)); + !(device_info.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER)) { + mon = new WinMonitor(id++, device_info.DeviceName, device_info.DeviceString); + monitors.push_back(mon); + if (device_info.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) { + primary_monitor = mon; + } } device_id++; } @@ -413,6 +419,7 @@ const MonitorsList& Platform::init_monitors() void Platform::destroy_monitors() { + primary_monitor = NULL; while (!monitors.empty()) { Monitor* monitor = monitors.front(); monitors.pop_front(); @@ -507,6 +514,16 @@ uint32_t Platform::get_keyboard_modifiers() KEY_BIT(keymap, VK_RMENU, R_ALT_MODIFIER); } +void Platform::reset_cursor_pos() +{ + if (!primary_monitor) { + return; + } + Point pos = primary_monitor->get_position(); + Point size = primary_monitor->get_size(); + SetCursorPos(pos.x + size.x / 2, pos.y + size.y / 2); +} + class WinBaseLocalCursor: public LocalCursor { public: WinBaseLocalCursor() : _handle (0) {} diff --git a/client/windows/red_window.cpp b/client/windows/red_window.cpp index 14a7d291..47467194 100644 --- a/client/windows/red_window.cpp +++ b/client/windows/red_window.cpp @@ -327,6 +327,8 @@ RedWindow_p::RedWindow_p() , _modal_refs (0) , _no_taskmgr_dll (NULL) , _no_taskmgr_hook (NULL) + , _focused (false) + , _pointer_in_window (false) , _minimized (false) , _valid_pos (false) , _sys_menu (NULL) @@ -406,8 +408,6 @@ RedWindow::RedWindow(RedWindow::Listener& listener, int screen_id) , _type (TYPE_NORMAL) , _local_cursor (NULL) , _cursor_visible (true) - , _focused (false) - , _pointer_in_window (false) , _trace_key_interception (false) , _key_interception_on (false) , _menu (NULL) diff --git a/client/windows/red_window_p.h b/client/windows/red_window_p.h index 4b5655ec..b35de571 100644 --- a/client/windows/red_window_p.h +++ b/client/windows/red_window_p.h @@ -56,6 +56,8 @@ protected: uint32_t _modal_refs; HMODULE _no_taskmgr_dll; HHOOK _no_taskmgr_hook; + bool _focused; + bool _pointer_in_window; bool _minimized; bool _valid_pos; int _x; |