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

Side by Side Diff: ui/aura/root_window_host_linux.cc

Issue 8907005: Add support for new scroll valuators coming from CMT (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review nits Created 9 years 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
« no previous file with comments | « ui/aura/root_window.cc ('k') | ui/base/events.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "ui/aura/root_window_host.h" 5 #include "ui/aura/root_window_host.h"
6 6
7 #include <X11/cursorfont.h> 7 #include <X11/cursorfont.h>
8 #include <X11/Xlib.h> 8 #include <X11/Xlib.h>
9 9
10 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class. 10 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class.
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 // with one from the master and one from the slave so there will 190 // with one from the master and one from the slave so there will
191 // always be at least one pending. 191 // always be at least one pending.
192 if (!ui::TouchFactory::GetInstance()->ShouldProcessXI2Event(&next_event)) { 192 if (!ui::TouchFactory::GetInstance()->ShouldProcessXI2Event(&next_event)) {
193 CheckXEventForConsistency(&next_event); 193 CheckXEventForConsistency(&next_event);
194 XFreeEventData(display, &next_event.xcookie); 194 XFreeEventData(display, &next_event.xcookie);
195 XNextEvent(display, &next_event); 195 XNextEvent(display, &next_event);
196 continue; 196 continue;
197 } 197 }
198 198
199 if (next_event.type == GenericEvent && 199 if (next_event.type == GenericEvent &&
200 next_event.xgeneric.evtype == XI_Motion) { 200 next_event.xgeneric.evtype == XI_Motion &&
201 !ui::GetScrollOffsets(&next_event, NULL, NULL)) {
201 XIDeviceEvent* next_xievent = 202 XIDeviceEvent* next_xievent =
202 static_cast<XIDeviceEvent*>(next_event.xcookie.data); 203 static_cast<XIDeviceEvent*>(next_event.xcookie.data);
203 // Confirm that the motion event is targeted at the same window 204 // Confirm that the motion event is targeted at the same window
204 // and that no buttons or modifiers have changed. 205 // and that no buttons or modifiers have changed.
205 if (xievent->event == next_xievent->event && 206 if (xievent->event == next_xievent->event &&
206 xievent->child == next_xievent->child && 207 xievent->child == next_xievent->child &&
207 xievent->buttons.mask_len == next_xievent->buttons.mask_len && 208 xievent->buttons.mask_len == next_xievent->buttons.mask_len &&
208 (memcmp(xievent->buttons.mask, 209 (memcmp(xievent->buttons.mask,
209 next_xievent->buttons.mask, 210 next_xievent->buttons.mask,
210 xievent->buttons.mask_len) == 0) && 211 xievent->buttons.mask_len) == 0) &&
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 long event_mask = ButtonPressMask | ButtonReleaseMask | 337 long event_mask = ButtonPressMask | ButtonReleaseMask |
337 KeyPressMask | KeyReleaseMask | 338 KeyPressMask | KeyReleaseMask |
338 EnterWindowMask | LeaveWindowMask | 339 EnterWindowMask | LeaveWindowMask |
339 ExposureMask | VisibilityChangeMask | 340 ExposureMask | VisibilityChangeMask |
340 StructureNotifyMask | PropertyChangeMask | 341 StructureNotifyMask | PropertyChangeMask |
341 PointerMotionMask; 342 PointerMotionMask;
342 XSelectInput(xdisplay_, xwindow_, event_mask); 343 XSelectInput(xdisplay_, xwindow_, event_mask);
343 XSelectInput(xdisplay_, x_root_window_, StructureNotifyMask); 344 XSelectInput(xdisplay_, x_root_window_, StructureNotifyMask);
344 XFlush(xdisplay_); 345 XFlush(xdisplay_);
345 346
346 // TODO(sad): Re-enable once crbug.com/106516 is fixed.
347 #if 0
348 if (base::MessagePumpForUI::HasXInput2()) 347 if (base::MessagePumpForUI::HasXInput2())
349 ui::TouchFactory::GetInstance()->SetupXI2ForXWindow(xwindow_); 348 ui::TouchFactory::GetInstance()->SetupXI2ForXWindow(xwindow_);
350 #endif
351 349
352 base::MessagePumpX::SetDefaultDispatcher(this); 350 base::MessagePumpX::SetDefaultDispatcher(this);
353 MessageLoopForUI::current()->AddDestructionObserver(this); 351 MessageLoopForUI::current()->AddDestructionObserver(this);
354 } 352 }
355 353
356 RootWindowHostLinux::~RootWindowHostLinux() { 354 RootWindowHostLinux::~RootWindowHostLinux() {
357 XDestroyWindow(xdisplay_, xwindow_); 355 XDestroyWindow(xdisplay_, xwindow_);
358 356
359 // Clears XCursorCache. 357 // Clears XCursorCache.
360 ui::GetXCursor(ui::kCursorClearXCursorCache); 358 ui::GetXCursor(ui::kCursorClearXCursorCache);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 if (size_changed) 413 if (size_changed)
416 root_window_->OnHostResized(bounds.size()); 414 root_window_->OnHostResized(bounds.size());
417 handled = true; 415 handled = true;
418 break; 416 break;
419 } 417 }
420 case GenericEvent: { 418 case GenericEvent: {
421 ui::TouchFactory* factory = ui::TouchFactory::GetInstance(); 419 ui::TouchFactory* factory = ui::TouchFactory::GetInstance();
422 if (!factory->ShouldProcessXI2Event(xev)) 420 if (!factory->ShouldProcessXI2Event(xev))
423 break; 421 break;
424 422
423 // Update the device list if necessary.
424 if (xev->xgeneric.evtype == XI_HierarchyChanged) {
425 ui::UpdateDeviceList();
426 handled = true;
427 break;
428 }
429
430 ui::EventType type = ui::EventTypeFromNative(xev);
425 // If this is a motion event we want to coalesce all pending motion 431 // If this is a motion event we want to coalesce all pending motion
426 // events that are at the top of the queue. 432 // events that are at the top of the queue.
427 XEvent last_event; 433 XEvent last_event;
428 int num_coalesced = 0; 434 int num_coalesced = 0;
429 if (xev->xgeneric.evtype == XI_Motion) {
430 num_coalesced = CoalescePendingXIMotionEvents(xev, &last_event);
431 if (num_coalesced > 0)
432 xev = &last_event;
433 }
434 435
435 ui::EventType type = ui::EventTypeFromNative(xev);
436 switch (type) { 436 switch (type) {
437 case ui::ET_TOUCH_PRESSED: 437 case ui::ET_TOUCH_PRESSED:
438 case ui::ET_TOUCH_RELEASED: 438 case ui::ET_TOUCH_RELEASED:
439 case ui::ET_TOUCH_MOVED: { 439 case ui::ET_TOUCH_MOVED: {
440 TouchEvent touchev(xev); 440 TouchEvent touchev(xev);
441 handled = root_window_->DispatchTouchEvent(&touchev); 441 handled = root_window_->DispatchTouchEvent(&touchev);
442 break; 442 break;
443 } 443 }
444 case ui::ET_MOUSE_MOVED:
445 case ui::ET_MOUSE_DRAGGED: {
446 // If this is a motion event we want to coalesce all pending motion
447 // events that are at the top of the queue.
448 num_coalesced = CoalescePendingXIMotionEvents(xev, &last_event);
449 if (num_coalesced > 0)
450 xev = &last_event;
451 }
444 case ui::ET_MOUSE_PRESSED: 452 case ui::ET_MOUSE_PRESSED:
445 case ui::ET_MOUSE_RELEASED: 453 case ui::ET_MOUSE_RELEASED:
446 case ui::ET_MOUSE_MOVED:
447 case ui::ET_MOUSE_DRAGGED:
448 case ui::ET_MOUSEWHEEL: 454 case ui::ET_MOUSEWHEEL:
449 case ui::ET_MOUSE_ENTERED: 455 case ui::ET_MOUSE_ENTERED:
450 case ui::ET_MOUSE_EXITED: { 456 case ui::ET_MOUSE_EXITED: {
451 MouseEvent mouseev(xev); 457 MouseEvent mouseev(xev);
452 handled = root_window_->DispatchMouseEvent(&mouseev); 458 handled = root_window_->DispatchMouseEvent(&mouseev);
453 break; 459 break;
454 } 460 }
461 case ui::ET_SCROLL: {
462 ScrollEvent scrollev(xev);
463 handled = root_window_->DispatchScrollEvent(&scrollev);
464 break;
465 }
455 case ui::ET_UNKNOWN: 466 case ui::ET_UNKNOWN:
456 handled = false; 467 handled = false;
457 break; 468 break;
458 default: 469 default:
459 NOTREACHED(); 470 NOTREACHED();
460 } 471 }
461 472
462 // If we coalesced an event we need to free its cookie. 473 // If we coalesced an event we need to free its cookie.
463 if (num_coalesced > 0) 474 if (num_coalesced > 0)
464 XFreeEventData(xev->xgeneric.display, &last_event.xcookie); 475 XFreeEventData(xev->xgeneric.display, &last_event.xcookie);
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 return new RootWindowHostLinux(bounds); 641 return new RootWindowHostLinux(bounds);
631 } 642 }
632 643
633 // static 644 // static
634 gfx::Size RootWindowHost::GetNativeScreenSize() { 645 gfx::Size RootWindowHost::GetNativeScreenSize() {
635 ::Display* xdisplay = base::MessagePumpX::GetDefaultXDisplay(); 646 ::Display* xdisplay = base::MessagePumpX::GetDefaultXDisplay();
636 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0)); 647 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0));
637 } 648 }
638 649
639 } // namespace aura 650 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/root_window.cc ('k') | ui/base/events.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698