| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /* | 5 /* |
| 6 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. | 6 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. |
| 7 * Copyright (C) 2006-2009 Google Inc. | 7 * Copyright (C) 2006-2009 Google Inc. |
| 8 * | 8 * |
| 9 * Redistribution and use in source and binary forms, with or without | 9 * Redistribution and use in source and binary forms, with or without |
| 10 * modification, are permitted provided that the following conditions | 10 * modification, are permitted provided that the following conditions |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 #import <ApplicationServices/ApplicationServices.h> | 33 #import <ApplicationServices/ApplicationServices.h> |
| 34 #import <Cocoa/Cocoa.h> | 34 #import <Cocoa/Cocoa.h> |
| 35 | 35 |
| 36 #include <stdint.h> | 36 #include <stdint.h> |
| 37 | 37 |
| 38 #include "base/mac/sdk_forward_declarations.h" | 38 #include "base/mac/sdk_forward_declarations.h" |
| 39 #include "base/strings/string_util.h" | 39 #include "base/strings/string_util.h" |
| 40 #include "content/browser/renderer_host/input/web_input_event_util.h" | 40 #include "content/browser/renderer_host/input/web_input_event_util.h" |
| 41 #include "third_party/WebKit/public/web/WebInputEvent.h" | 41 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 42 #include "ui/base/cocoa/cocoa_base_utils.h" |
| 42 #include "ui/events/keycodes/keyboard_code_conversion.h" | 43 #include "ui/events/keycodes/keyboard_code_conversion.h" |
| 43 #include "ui/events/keycodes/keyboard_code_conversion_mac.h" | 44 #include "ui/events/keycodes/keyboard_code_conversion_mac.h" |
| 44 | 45 |
| 45 namespace content { | 46 namespace content { |
| 46 | 47 |
| 47 namespace { | 48 namespace { |
| 48 | 49 |
| 49 // Return true if the target modifier key is up. OS X has an "official" flag | 50 // Return true if the target modifier key is up. OS X has an "official" flag |
| 50 // to test whether either left or right versions of a modifier key are held, | 51 // to test whether either left or right versions of a modifier key are held, |
| 51 // and "unofficial" flags for the left and right versions independently. This | 52 // and "unofficial" flags for the left and right versions independently. This |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 modifiers |= blink::WebInputEvent::RightButtonDown; | 510 modifiers |= blink::WebInputEvent::RightButtonDown; |
| 510 if (pressed_buttons & (1 << 2)) | 511 if (pressed_buttons & (1 << 2)) |
| 511 modifiers |= blink::WebInputEvent::MiddleButtonDown; | 512 modifiers |= blink::WebInputEvent::MiddleButtonDown; |
| 512 | 513 |
| 513 return modifiers; | 514 return modifiers; |
| 514 } | 515 } |
| 515 | 516 |
| 516 void SetWebEventLocationFromEventInView(blink::WebMouseEvent* result, | 517 void SetWebEventLocationFromEventInView(blink::WebMouseEvent* result, |
| 517 NSEvent* event, | 518 NSEvent* event, |
| 518 NSView* view) { | 519 NSView* view) { |
| 519 NSPoint window_local = [event locationInWindow]; | 520 NSPoint screen_local = ui::ConvertPointFromWindowToScreen( |
| 520 | 521 [view window], [event locationInWindow]); |
| 521 NSPoint screen_local = [[view window] convertBaseToScreen:window_local]; | |
| 522 result->globalX = screen_local.x; | 522 result->globalX = screen_local.x; |
| 523 // Flip y. | 523 // Flip y. |
| 524 NSScreen* primary_screen = ([[NSScreen screens] count] > 0) | 524 NSScreen* primary_screen = ([[NSScreen screens] count] > 0) |
| 525 ? [[NSScreen screens] firstObject] | 525 ? [[NSScreen screens] firstObject] |
| 526 : nil; | 526 : nil; |
| 527 if (primary_screen) | 527 if (primary_screen) |
| 528 result->globalY = [primary_screen frame].size.height - screen_local.y; | 528 result->globalY = [primary_screen frame].size.height - screen_local.y; |
| 529 else | 529 else |
| 530 result->globalY = screen_local.y; | 530 result->globalY = screen_local.y; |
| 531 | 531 |
| 532 NSPoint content_local = [view convertPoint:window_local fromView:nil]; | 532 NSPoint content_local = |
| 533 [view convertPoint:[event locationInWindow] fromView:nil]; |
| 533 result->x = content_local.x; | 534 result->x = content_local.x; |
| 534 result->y = [view frame].size.height - content_local.y; // Flip y. | 535 result->y = [view frame].size.height - content_local.y; // Flip y. |
| 535 | 536 |
| 536 result->windowX = result->x; | 537 result->windowX = result->x; |
| 537 result->windowY = result->y; | 538 result->windowY = result->y; |
| 538 | 539 |
| 539 result->movementX = [event deltaX]; | 540 result->movementX = [event deltaX]; |
| 540 result->movementY = [event deltaY]; | 541 result->movementY = [event deltaY]; |
| 541 } | 542 } |
| 542 | 543 |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 930 break; | 931 break; |
| 931 default: | 932 default: |
| 932 NOTIMPLEMENTED(); | 933 NOTIMPLEMENTED(); |
| 933 result.type = blink::WebInputEvent::Undefined; | 934 result.type = blink::WebInputEvent::Undefined; |
| 934 } | 935 } |
| 935 | 936 |
| 936 return result; | 937 return result; |
| 937 } | 938 } |
| 938 | 939 |
| 939 } // namespace content | 940 } // namespace content |
| OLD | NEW |