summaryrefslogtreecommitdiffstats
path: root/remoting/host
diff options
context:
space:
mode:
authorwez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-23 17:38:27 +0000
committerwez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-23 17:38:27 +0000
commit50e9dcf831492784c434b95c56808402c6de6295 (patch)
treeb8232101b10a33a50d40ea48cdfecac8bcb40efc /remoting/host
parent45499256db8cd1796deca460a0ebef69368fa841 (diff)
downloadchromium_src-50e9dcf831492784c434b95c56808402c6de6295.zip
chromium_src-50e9dcf831492784c434b95c56808402c6de6295.tar.gz
chromium_src-50e9dcf831492784c434b95c56808402c6de6295.tar.bz2
Add support for high-DPI hosts under Mac OS X.
- Moves enumeration of display configuration(s) to helper classes, which fetch each display's logical and device-native resolutions. - Updates VideoFrameCapturerMac and EventExecutorMac to use the helper. BUG=135081 Review URL: https://chromiumcodereview.appspot.com/11665012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@178318 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host')
-rw-r--r--remoting/host/event_executor_mac.cc52
1 files changed, 22 insertions, 30 deletions
diff --git a/remoting/host/event_executor_mac.cc b/remoting/host/event_executor_mac.cc
index d3cdc1e..ab636ff 100644
--- a/remoting/host/event_executor_mac.cc
+++ b/remoting/host/event_executor_mac.cc
@@ -14,9 +14,11 @@
#include "base/mac/scoped_cftyperef.h"
#include "base/memory/ref_counted.h"
#include "base/single_thread_task_runner.h"
+#include "remoting/capturer/mac/desktop_configuration.h"
#include "remoting/host/clipboard.h"
#include "remoting/proto/internal.pb.h"
#include "remoting/protocol/message_decoder.h"
+#include "skia/ext/skia_utils_mac.h"
#include "third_party/skia/include/core/SkPoint.h"
#include "third_party/skia/include/core/SkRect.h"
@@ -35,13 +37,9 @@ using protocol::MouseEvent;
// skia/ext/skia_utils_mac.h only defines CGRectToSkRect().
SkIRect CGRectToSkIRect(const CGRect& rect) {
- SkIRect sk_rect = {
- SkScalarRound(rect.origin.x),
- SkScalarRound(rect.origin.y),
- SkScalarRound(rect.origin.x + rect.size.width),
- SkScalarRound(rect.origin.y + rect.size.height)
- };
- return sk_rect;
+ SkIRect result;
+ gfx::CGRectToSkRect(rect).round(&result);
+ return result;
}
// A class to generate events on Mac.
@@ -190,30 +188,24 @@ void EventExecutorMac::Core::InjectMouseEvent(const MouseEvent& event) {
// Set the mouse position assuming single-monitor.
mouse_pos_ = SkIPoint::Make(event.x(), event.y());
- // Determine how many active displays there are.
- CGDisplayCount display_count;
- CGError error = CGGetActiveDisplayList(0, NULL, &display_count);
- CHECK_EQ(error, CGDisplayNoErr);
-
- if (display_count > 1) {
- // Determine the bounding box of the displays, to get the top-left origin.
- std::vector<CGDirectDisplayID> display_ids(display_count);
- error = CGGetActiveDisplayList(display_count, &display_ids[0],
- &display_count);
- CHECK_EQ(error, CGDisplayNoErr);
- CHECK_EQ(display_count, display_ids.size());
-
- SkIRect desktop_bounds = SkIRect::MakeEmpty();
- for (unsigned int d = 0; d < display_count; ++d) {
- CGRect display_bounds = CGDisplayBounds(display_ids[d]);
- desktop_bounds.join(CGRectToSkIRect(display_bounds));
- }
-
- // Adjust the injected mouse event position.
- mouse_pos_ += SkIPoint::Make(desktop_bounds.left(), desktop_bounds.top());
- }
+ // Fetch the desktop configuration.
+ // TODO(wez): Optimize this out, or at least only enumerate displays in
+ // response to display-changed events. VideoFrameCapturer's VideoFrames
+ // could be augmented to include native cursor coordinates for use by
+ // MouseClampingFilter, removing the need for translation here.
+ MacDesktopConfiguration desktop_config
+ = MacDesktopConfiguration::GetCurrent();
+
+ // Translate the mouse position into desktop coordinates.
+ mouse_pos_ += SkIPoint::Make(desktop_config.pixel_bounds.left(),
+ desktop_config.pixel_bounds.top());
+
+ // Convert from pixel to logical coordinates.
+ mouse_pos_ = SkIPoint::Make(
+ SkScalarRound(mouse_pos_.x() / desktop_config.logical_to_pixel_scale),
+ SkScalarRound(mouse_pos_.y() / desktop_config.logical_to_pixel_scale));
- VLOG(3) << "Moving mouse to " << event.x() << "," << event.y();
+ VLOG(3) << "Moving mouse to " << mouse_pos_.x() << "," << mouse_pos_.y();
}
if (event.has_button() && event.has_button_down()) {
if (event.button() >= 1 && event.button() <= 3) {