Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: chrome/browser/ui/ash/event_rewriter.cc

Issue 144423006: Rewrite release event only if press event was rewritten for a given device. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/browser/ui/ash/event_rewriter.h" 5 #include "chrome/browser/ui/ash/event_rewriter.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 return; 996 return;
997 997
998 // First, remap modifier masks. 998 // First, remap modifier masks.
999 int remapped_flags = 0; 999 int remapped_flags = 0;
1000 unsigned int remapped_native_modifiers = 0U; 1000 unsigned int remapped_native_modifiers = 0U;
1001 GetRemappedModifierMasks(event->flags(), xievent->mods.effective, 1001 GetRemappedModifierMasks(event->flags(), xievent->mods.effective,
1002 &remapped_flags, &remapped_native_modifiers); 1002 &remapped_flags, &remapped_native_modifiers);
1003 xievent->mods.effective = remapped_native_modifiers; 1003 xievent->mods.effective = remapped_native_modifiers;
1004 1004
1005 // Then, remap Alt+Button1 to Button3. 1005 // Then, remap Alt+Button1 to Button3.
1006 if ((xievent->mods.effective & Mod1Mask) && xievent->detail == 1) { 1006 if ((xievent->evtype == XI_ButtonPress ||
1007 pressed_device_ids_.count(xievent->sourceid)) &&
1008 (xievent->mods.effective & Mod1Mask) && xievent->detail == Button1) {
1007 xievent->mods.effective &= ~Mod1Mask; 1009 xievent->mods.effective &= ~Mod1Mask;
1008 xievent->detail = 3; 1010 xievent->detail = Button3;
1009 if (xievent->evtype == XI_ButtonRelease) { 1011 if (xievent->evtype == XI_ButtonRelease) {
1010 // On the release clear the left button from the existing state and the 1012 // On the release clear the left button from the existing state and the
1011 // mods, and set the right button. 1013 // mods, and set the right button.
1012 XISetMask(xievent->buttons.mask, 3); 1014 XISetMask(xievent->buttons.mask, Button3);
1013 XIClearMask(xievent->buttons.mask, 1); 1015 XIClearMask(xievent->buttons.mask, Button1);
1014 xievent->mods.effective &= ~Button1Mask; 1016 xievent->mods.effective &= ~Button1Mask;
1017 pressed_device_ids_.erase(xievent->sourceid);
1018 } else {
1019 pressed_device_ids_.insert(xievent->sourceid);
1015 } 1020 }
1016 } 1021 }
1017 1022
1018 const int mouse_event_flags = event->flags() & 1023 const int mouse_event_flags = event->flags() &
1019 (ui::EF_IS_DOUBLE_CLICK | ui::EF_IS_TRIPLE_CLICK | ui::EF_IS_NON_CLIENT | 1024 (ui::EF_IS_DOUBLE_CLICK | ui::EF_IS_TRIPLE_CLICK | ui::EF_IS_NON_CLIENT |
1020 ui::EF_IS_SYNTHESIZED | ui::EF_FROM_TOUCH); 1025 ui::EF_IS_SYNTHESIZED | ui::EF_FROM_TOUCH);
1021 event->set_flags(mouse_event_flags | ui::EventFlagsFromNative(xevent)); 1026 event->set_flags(mouse_event_flags | ui::EventFlagsFromNative(xevent));
1022 #else 1027 #else
1023 // TODO(yusukes): Support Ash on other platforms if needed. 1028 // TODO(yusukes): Support Ash on other platforms if needed.
1024 #endif 1029 #endif
(...skipping 25 matching lines...) Expand all
1050 const DeviceType type = EventRewriter::GetDeviceType(device_name); 1055 const DeviceType type = EventRewriter::GetDeviceType(device_name);
1051 if (type == kDeviceAppleKeyboard) { 1056 if (type == kDeviceAppleKeyboard) {
1052 VLOG(1) << "Apple keyboard '" << device_name << "' connected: " 1057 VLOG(1) << "Apple keyboard '" << device_name << "' connected: "
1053 << "id=" << device_id; 1058 << "id=" << device_id;
1054 } 1059 }
1055 // Always overwrite the existing device_id since the X server may reuse a 1060 // Always overwrite the existing device_id since the X server may reuse a
1056 // device id for an unattached device. 1061 // device id for an unattached device.
1057 device_id_to_type_[device_id] = type; 1062 device_id_to_type_[device_id] = type;
1058 return type; 1063 return type;
1059 } 1064 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/event_rewriter.h ('k') | chrome/browser/ui/ash/event_rewriter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698