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

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

Issue 10828133: Desktop Aura: Allow tab drags out of window. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup Created 8 years, 4 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/root_window_host_win.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/Xatom.h> 7 #include <X11/Xatom.h>
8 #include <X11/Xcursor/Xcursor.h> 8 #include <X11/Xcursor/Xcursor.h>
9 #include <X11/Xlib.h> 9 #include <X11/Xlib.h>
10 #include <X11/cursorfont.h> 10 #include <X11/cursorfont.h>
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 DISALLOW_COPY_AND_ASSIGN(ImageCursors); 466 DISALLOW_COPY_AND_ASSIGN(ImageCursors);
467 }; 467 };
468 468
469 RootWindowHostLinux::RootWindowHostLinux(RootWindowHostDelegate* delegate, 469 RootWindowHostLinux::RootWindowHostLinux(RootWindowHostDelegate* delegate,
470 const gfx::Rect& bounds) 470 const gfx::Rect& bounds)
471 : delegate_(delegate), 471 : delegate_(delegate),
472 xdisplay_(base::MessagePumpAuraX11::GetDefaultXDisplay()), 472 xdisplay_(base::MessagePumpAuraX11::GetDefaultXDisplay()),
473 xwindow_(0), 473 xwindow_(0),
474 x_root_window_(DefaultRootWindow(xdisplay_)), 474 x_root_window_(DefaultRootWindow(xdisplay_)),
475 current_cursor_(ui::kCursorNull), 475 current_cursor_(ui::kCursorNull),
476 window_mapped_(false),
476 cursor_shown_(true), 477 cursor_shown_(true),
477 bounds_(bounds), 478 bounds_(bounds),
478 focus_when_shown_(false), 479 focus_when_shown_(false),
479 pointer_barriers_(NULL), 480 pointer_barriers_(NULL),
480 image_cursors_(new ImageCursors), 481 image_cursors_(new ImageCursors),
481 atom_cache_(xdisplay_, kAtomsToCache) { 482 atom_cache_(xdisplay_, kAtomsToCache) {
482 XSetWindowAttributes swa; 483 XSetWindowAttributes swa;
483 memset(&swa, 0, sizeof(swa)); 484 memset(&swa, 0, sizeof(swa));
484 swa.background_pixmap = None; 485 swa.background_pixmap = None;
485 xwindow_ = XCreateWindow( 486 xwindow_ = XCreateWindow(
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 break; 613 break;
613 case ConfigureNotify: { 614 case ConfigureNotify: {
614 DCHECK_EQ(xwindow_, xev->xconfigure.window); 615 DCHECK_EQ(xwindow_, xev->xconfigure.window);
615 DCHECK_EQ(xwindow_, xev->xconfigure.event); 616 DCHECK_EQ(xwindow_, xev->xconfigure.event);
616 // It's possible that the X window may be resized by some other means than 617 // It's possible that the X window may be resized by some other means than
617 // from within aura (e.g. the X window manager can change the size). Make 618 // from within aura (e.g. the X window manager can change the size). Make
618 // sure the root window size is maintained properly. 619 // sure the root window size is maintained properly.
619 gfx::Rect bounds(xev->xconfigure.x, xev->xconfigure.y, 620 gfx::Rect bounds(xev->xconfigure.x, xev->xconfigure.y,
620 xev->xconfigure.width, xev->xconfigure.height); 621 xev->xconfigure.width, xev->xconfigure.height);
621 bool size_changed = bounds_.size() != bounds.size(); 622 bool size_changed = bounds_.size() != bounds.size();
623 bool origin_changed = bounds_.origin() != bounds.origin();
622 bounds_ = bounds; 624 bounds_ = bounds;
623 // Update barrier and mouse location when the root window has 625 // Update barrier and mouse location when the root window has
624 // moved/resized. 626 // moved/resized.
625 if (pointer_barriers_.get()) { 627 if (pointer_barriers_.get()) {
626 UnConfineCursor(); 628 UnConfineCursor();
627 gfx::Point p = gfx::Screen::GetCursorScreenPoint(); 629 gfx::Point p = gfx::Screen::GetCursorScreenPoint();
628 XWarpPointer(xdisplay_, None, xwindow_, 0, 0, 0, 0, p.x(), p.y()); 630 XWarpPointer(xdisplay_, None, xwindow_, 0, 0, 0, 0, p.x(), p.y());
629 ConfineCursorToRootWindow(); 631 ConfineCursorToRootWindow();
630 } 632 }
631 if (size_changed) 633 if (size_changed)
632 delegate_->OnHostResized(bounds.size()); 634 delegate_->OnHostResized(bounds.size());
635 if (origin_changed)
636 delegate_->OnHostMoved(bounds_.origin());
633 break; 637 break;
634 } 638 }
635 case GenericEvent: { 639 case GenericEvent: {
636 ui::TouchFactory* factory = ui::TouchFactory::GetInstance(); 640 ui::TouchFactory* factory = ui::TouchFactory::GetInstance();
637 if (!factory->ShouldProcessXI2Event(xev)) 641 if (!factory->ShouldProcessXI2Event(xev))
638 break; 642 break;
639 643
640 ui::EventType type = ui::EventTypeFromNative(xev); 644 ui::EventType type = ui::EventTypeFromNative(xev);
641 XEvent last_event; 645 XEvent last_event;
642 int num_coalesced = 0; 646 int num_coalesced = 0;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 } 778 }
775 779
776 gfx::AcceleratedWidget RootWindowHostLinux::GetAcceleratedWidget() { 780 gfx::AcceleratedWidget RootWindowHostLinux::GetAcceleratedWidget() {
777 return xwindow_; 781 return xwindow_;
778 } 782 }
779 783
780 void RootWindowHostLinux::Show() { 784 void RootWindowHostLinux::Show() {
781 // The device scale factor is now accessible, so load cursors now. 785 // The device scale factor is now accessible, so load cursors now.
782 image_cursors_->Reload(delegate_->GetDeviceScaleFactor()); 786 image_cursors_->Reload(delegate_->GetDeviceScaleFactor());
783 787
784 // Before we map the window, set size hints. Otherwise, some window managers 788 if (!window_mapped_) {
785 // will ignore toplevel XMoveWindow commands. 789 // Before we map the window, set size hints. Otherwise, some window managers
786 XSizeHints size_hints; 790 // will ignore toplevel XMoveWindow commands.
787 size_hints.flags = PPosition; 791 XSizeHints size_hints;
788 size_hints.x = bounds_.x(); 792 size_hints.flags = PPosition;
789 size_hints.y = bounds_.y(); 793 size_hints.x = bounds_.x();
790 XSetWMNormalHints(xdisplay_, xwindow_, &size_hints); 794 size_hints.y = bounds_.y();
795 XSetWMNormalHints(xdisplay_, xwindow_, &size_hints);
791 796
792 XMapWindow(xdisplay_, xwindow_); 797 XMapWindow(xdisplay_, xwindow_);
798
799 // We now block until our window is mapped. Some X11 APIs will crash and
800 // burn if passed |xwindow_| before the window is mapped, and XMapWindow is
801 // asynchronous.
802 base::MessagePumpAuraX11::Current()->BlockUntilWindowMapped(xwindow_);
803 window_mapped_ = true;
804 }
805 }
806
807 void RootWindowHostLinux::Hide() {
808 if (window_mapped_) {
809 XWithdrawWindow(xdisplay_, xwindow_, 0);
810 window_mapped_ = false;
811 }
793 } 812 }
794 813
795 void RootWindowHostLinux::ToggleFullScreen() { 814 void RootWindowHostLinux::ToggleFullScreen() {
796 NOTIMPLEMENTED(); 815 NOTIMPLEMENTED();
797 } 816 }
798 817
799 gfx::Rect RootWindowHostLinux::GetBounds() const { 818 gfx::Rect RootWindowHostLinux::GetBounds() const {
800 return bounds_; 819 return bounds_;
801 } 820 }
802 821
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 ui::ViewProp::GetValue(accelerated_widget, kRootWindowHostLinuxKey)); 1073 ui::ViewProp::GetValue(accelerated_widget, kRootWindowHostLinuxKey));
1055 } 1074 }
1056 1075
1057 // static 1076 // static
1058 gfx::Size RootWindowHost::GetNativeScreenSize() { 1077 gfx::Size RootWindowHost::GetNativeScreenSize() {
1059 ::Display* xdisplay = base::MessagePumpAuraX11::GetDefaultXDisplay(); 1078 ::Display* xdisplay = base::MessagePumpAuraX11::GetDefaultXDisplay();
1060 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0)); 1079 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0));
1061 } 1080 }
1062 1081
1063 } // namespace aura 1082 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/root_window_host_linux.h ('k') | ui/aura/root_window_host_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698