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

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

Issue 9564023: Revert 124461 - Remove the singleton instance get/delete methods from RootWindow (yay) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 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
« no previous file with comments | « ui/aura/root_window_host_linux.h ('k') | ui/aura/test/aura_test_base.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) 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 "ui/aura/root_window_host_linux.h" 5 #include "ui/aura/root_window_host_linux.h"
6 6
7 #include <X11/cursorfont.h> 7 #include <X11/cursorfont.h>
8 #include <X11/extensions/XInput2.h> 8 #include <X11/extensions/XInput2.h>
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 ExposureMask | VisibilityChangeMask | 298 ExposureMask | VisibilityChangeMask |
299 StructureNotifyMask | PropertyChangeMask | 299 StructureNotifyMask | PropertyChangeMask |
300 PointerMotionMask; 300 PointerMotionMask;
301 XSelectInput(xdisplay_, xwindow_, event_mask); 301 XSelectInput(xdisplay_, xwindow_, event_mask);
302 XSelectInput(xdisplay_, x_root_window_, StructureNotifyMask); 302 XSelectInput(xdisplay_, x_root_window_, StructureNotifyMask);
303 XFlush(xdisplay_); 303 XFlush(xdisplay_);
304 304
305 if (base::MessagePumpForUI::HasXInput2()) 305 if (base::MessagePumpForUI::HasXInput2())
306 ui::TouchFactory::GetInstance()->SetupXI2ForXWindow(xwindow_); 306 ui::TouchFactory::GetInstance()->SetupXI2ForXWindow(xwindow_);
307 307
308 MessageLoopForUI::current()->AddDestructionObserver(this);
309
308 // Initialize invisible cursor. 310 // Initialize invisible cursor.
309 char nodata[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; 311 char nodata[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
310 XColor black; 312 XColor black;
311 black.red = black.green = black.blue = 0; 313 black.red = black.green = black.blue = 0;
312 Pixmap blank = XCreateBitmapFromData(xdisplay_, xwindow_, 314 Pixmap blank = XCreateBitmapFromData(xdisplay_, xwindow_,
313 nodata, 8, 8); 315 nodata, 8, 8);
314 invisible_cursor_ = XCreatePixmapCursor(xdisplay_, blank, blank, 316 invisible_cursor_ = XCreatePixmapCursor(xdisplay_, blank, blank,
315 &black, &black, 0, 0); 317 &black, &black, 0, 0);
316 if (RootWindow::hide_host_cursor()) 318 if (RootWindow::hide_host_cursor())
317 XDefineCursor(xdisplay_, x_root_window_, invisible_cursor_); 319 XDefineCursor(xdisplay_, x_root_window_, invisible_cursor_);
318 } 320 }
319 321
320 RootWindowHostLinux::~RootWindowHostLinux() { 322 RootWindowHostLinux::~RootWindowHostLinux() {
321 static_cast<DispatcherLinux*>(Env::GetInstance()->GetDispatcher())-> 323 static_cast<DispatcherLinux*>(Env::GetInstance()->GetDispatcher())->
322 RootWindowHostDestroying(xwindow_, x_root_window_); 324 RootWindowHostDestroying(xwindow_, x_root_window_);
323 XDestroyWindow(xdisplay_, xwindow_); 325 XDestroyWindow(xdisplay_, xwindow_);
324 326
325 // Clears XCursorCache. 327 // Clears XCursorCache.
326 ui::GetXCursor(ui::kCursorClearXCursorCache); 328 ui::GetXCursor(ui::kCursorClearXCursorCache);
327 329
328 XFreeCursor(xdisplay_, invisible_cursor_); 330 XFreeCursor(xdisplay_, invisible_cursor_);
331
332 MessageLoopForUI::current()->RemoveDestructionObserver(this);
329 } 333 }
330 334
331 base::MessagePumpDispatcher::DispatchStatus RootWindowHostLinux::Dispatch( 335 base::MessagePumpDispatcher::DispatchStatus RootWindowHostLinux::Dispatch(
332 XEvent* xev) { 336 XEvent* xev) {
333 bool handled = false; 337 bool handled = false;
334 338
335 // See crbug.com/109884. 339 // See crbug.com/109884.
336 // CheckXEventForConsistency(xev); 340 // CheckXEventForConsistency(xev);
337 341
338 switch (xev->type) { 342 switch (xev->type) {
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 root_window_->ConvertPointToNativeScreen(&point); 617 root_window_->ConvertPointToNativeScreen(&point);
614 xevent.xmotion.x_root = point.x(); 618 xevent.xmotion.x_root = point.x();
615 xevent.xmotion.y_root = point.y(); 619 xevent.xmotion.y_root = point.y();
616 } 620 }
617 default: 621 default:
618 break; 622 break;
619 } 623 }
620 XSendEvent(xdisplay_, xwindow_, False, 0, &xevent); 624 XSendEvent(xdisplay_, xwindow_, False, 0, &xevent);
621 } 625 }
622 626
627 void RootWindowHostLinux::WillDestroyCurrentMessageLoop() {
628 aura::RootWindow::DeleteInstance();
629 }
630
623 bool RootWindowHostLinux::IsWindowManagerPresent() { 631 bool RootWindowHostLinux::IsWindowManagerPresent() {
624 // Per ICCCM 2.8, "Manager Selections", window managers should take ownership 632 // Per ICCCM 2.8, "Manager Selections", window managers should take ownership
625 // of WM_Sn selections (where n is a screen number). 633 // of WM_Sn selections (where n is a screen number).
626 ::Atom wm_s0_atom = XInternAtom(xdisplay_, "WM_S0", False); 634 ::Atom wm_s0_atom = XInternAtom(xdisplay_, "WM_S0", False);
627 return XGetSelectionOwner(xdisplay_, wm_s0_atom) != None; 635 return XGetSelectionOwner(xdisplay_, wm_s0_atom) != None;
628 } 636 }
629 637
630 void RootWindowHostLinux::SetCursorInternal(gfx::NativeCursor cursor) { 638 void RootWindowHostLinux::SetCursorInternal(gfx::NativeCursor cursor) {
631 ::Cursor xcursor = 639 ::Cursor xcursor =
632 cursor == kCursorNone ? 640 cursor == kCursorNone ?
633 invisible_cursor_ : 641 invisible_cursor_ :
634 ui::GetXCursor(CursorShapeFromNative(cursor)); 642 ui::GetXCursor(CursorShapeFromNative(cursor));
635 XDefineCursor(xdisplay_, xwindow_, xcursor); 643 XDefineCursor(xdisplay_, xwindow_, xcursor);
636 } 644 }
637 645
638 // static 646 // static
639 RootWindowHost* RootWindowHost::Create(const gfx::Rect& bounds) { 647 RootWindowHost* RootWindowHost::Create(const gfx::Rect& bounds) {
640 return new RootWindowHostLinux(bounds); 648 return new RootWindowHostLinux(bounds);
641 } 649 }
642 650
643 // static 651 // static
644 gfx::Size RootWindowHost::GetNativeScreenSize() { 652 gfx::Size RootWindowHost::GetNativeScreenSize() {
645 ::Display* xdisplay = base::MessagePumpX::GetDefaultXDisplay(); 653 ::Display* xdisplay = base::MessagePumpX::GetDefaultXDisplay();
646 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0)); 654 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0));
647 } 655 }
648 656
649 } // namespace aura 657 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/root_window_host_linux.h ('k') | ui/aura/test/aura_test_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698