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

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

Issue 23880006: gtk: Allow building both the X11 and Gtk message-pumps for gtk. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tot-merge Created 7 years, 3 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/env.cc ('k') | ui/aura/test/ui_controls_factory_aurax11.cc » ('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_x11.h" 5 #include "ui/aura/root_window_host_x11.h"
6 6
7 #include <strings.h> 7 #include <strings.h>
8 #include <X11/cursorfont.h> 8 #include <X11/cursorfont.h>
9 #include <X11/extensions/Xfixes.h> 9 #include <X11/extensions/Xfixes.h>
10 #include <X11/extensions/XInput2.h> 10 #include <X11/extensions/XInput2.h>
11 #include <X11/extensions/Xrandr.h> 11 #include <X11/extensions/Xrandr.h>
12 #include <X11/Xatom.h> 12 #include <X11/Xatom.h>
13 #include <X11/Xcursor/Xcursor.h> 13 #include <X11/Xcursor/Xcursor.h>
14 #include <X11/Xlib.h> 14 #include <X11/Xlib.h>
15 15
16 #include <algorithm> 16 #include <algorithm>
17 #include <limits> 17 #include <limits>
18 #include <string> 18 #include <string>
19 19
20 #include "base/command_line.h" 20 #include "base/command_line.h"
21 #include "base/debug/trace_event.h" 21 #include "base/debug/trace_event.h"
22 #include "base/message_loop/message_loop.h" 22 #include "base/message_loop/message_loop.h"
23 #include "base/message_loop/message_pump_aurax11.h" 23 #include "base/message_loop/message_pump_x11.h"
24 #include "base/stl_util.h" 24 #include "base/stl_util.h"
25 #include "base/strings/string_number_conversions.h" 25 #include "base/strings/string_number_conversions.h"
26 #include "base/strings/string_util.h" 26 #include "base/strings/string_util.h"
27 #include "base/strings/stringprintf.h" 27 #include "base/strings/stringprintf.h"
28 #include "ui/aura/client/capture_client.h" 28 #include "ui/aura/client/capture_client.h"
29 #include "ui/aura/client/cursor_client.h" 29 #include "ui/aura/client/cursor_client.h"
30 #include "ui/aura/client/screen_position_client.h" 30 #include "ui/aura/client/screen_position_client.h"
31 #include "ui/aura/client/user_action_client.h" 31 #include "ui/aura/client/user_action_client.h"
32 #include "ui/aura/env.h" 32 #include "ui/aura/env.h"
33 #include "ui/aura/root_window.h" 33 #include "ui/aura/root_window.h"
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 size_t insert_index_; 356 size_t insert_index_;
357 357
358 DISALLOW_COPY_AND_ASSIGN(MouseMoveFilter); 358 DISALLOW_COPY_AND_ASSIGN(MouseMoveFilter);
359 }; 359 };
360 360
361 //////////////////////////////////////////////////////////////////////////////// 361 ////////////////////////////////////////////////////////////////////////////////
362 // RootWindowHostX11 362 // RootWindowHostX11
363 363
364 RootWindowHostX11::RootWindowHostX11(const gfx::Rect& bounds) 364 RootWindowHostX11::RootWindowHostX11(const gfx::Rect& bounds)
365 : delegate_(NULL), 365 : delegate_(NULL),
366 xdisplay_(base::MessagePumpAuraX11::GetDefaultXDisplay()), 366 xdisplay_(base::MessagePumpX11::GetDefaultXDisplay()),
367 xwindow_(0), 367 xwindow_(0),
368 x_root_window_(DefaultRootWindow(xdisplay_)), 368 x_root_window_(DefaultRootWindow(xdisplay_)),
369 current_cursor_(ui::kCursorNull), 369 current_cursor_(ui::kCursorNull),
370 window_mapped_(false), 370 window_mapped_(false),
371 bounds_(bounds), 371 bounds_(bounds),
372 is_internal_display_(false), 372 is_internal_display_(false),
373 focus_when_shown_(false), 373 focus_when_shown_(false),
374 touch_calibrate_(new internal::TouchEventCalibrate), 374 touch_calibrate_(new internal::TouchEventCalibrate),
375 mouse_move_filter_(new MouseMoveFilter), 375 mouse_move_filter_(new MouseMoveFilter),
376 atom_cache_(xdisplay_, kAtomsToCache), 376 atom_cache_(xdisplay_, kAtomsToCache),
377 bezel_tracking_ids_(0) { 377 bezel_tracking_ids_(0) {
378 XSetWindowAttributes swa; 378 XSetWindowAttributes swa;
379 memset(&swa, 0, sizeof(swa)); 379 memset(&swa, 0, sizeof(swa));
380 swa.background_pixmap = None; 380 swa.background_pixmap = None;
381 swa.override_redirect = default_override_redirect; 381 swa.override_redirect = default_override_redirect;
382 xwindow_ = XCreateWindow( 382 xwindow_ = XCreateWindow(
383 xdisplay_, x_root_window_, 383 xdisplay_, x_root_window_,
384 bounds.x(), bounds.y(), bounds.width(), bounds.height(), 384 bounds.x(), bounds.y(), bounds.width(), bounds.height(),
385 0, // border width 385 0, // border width
386 CopyFromParent, // depth 386 CopyFromParent, // depth
387 InputOutput, 387 InputOutput,
388 CopyFromParent, // visual 388 CopyFromParent, // visual
389 CWBackPixmap | CWOverrideRedirect, 389 CWBackPixmap | CWOverrideRedirect,
390 &swa); 390 &swa);
391 base::MessagePumpAuraX11::Current()->AddDispatcherForWindow(this, xwindow_); 391 base::MessagePumpX11::Current()->AddDispatcherForWindow(this, xwindow_);
392 base::MessagePumpAuraX11::Current()->AddDispatcherForRootWindow(this); 392 base::MessagePumpX11::Current()->AddDispatcherForRootWindow(this);
393 393
394 long event_mask = ButtonPressMask | ButtonReleaseMask | FocusChangeMask | 394 long event_mask = ButtonPressMask | ButtonReleaseMask | FocusChangeMask |
395 KeyPressMask | KeyReleaseMask | 395 KeyPressMask | KeyReleaseMask |
396 EnterWindowMask | LeaveWindowMask | 396 EnterWindowMask | LeaveWindowMask |
397 ExposureMask | VisibilityChangeMask | 397 ExposureMask | VisibilityChangeMask |
398 StructureNotifyMask | PropertyChangeMask | 398 StructureNotifyMask | PropertyChangeMask |
399 PointerMotionMask; 399 PointerMotionMask;
400 XSelectInput(xdisplay_, xwindow_, event_mask); 400 XSelectInput(xdisplay_, xwindow_, event_mask);
401 XFlush(xdisplay_); 401 XFlush(xdisplay_);
402 402
(...skipping 30 matching lines...) Expand all
433 PropModeReplace, 433 PropModeReplace,
434 reinterpret_cast<unsigned char*>(&pid), 1); 434 reinterpret_cast<unsigned char*>(&pid), 1);
435 435
436 XRRSelectInput(xdisplay_, x_root_window_, 436 XRRSelectInput(xdisplay_, x_root_window_,
437 RRScreenChangeNotifyMask | RROutputChangeNotifyMask); 437 RRScreenChangeNotifyMask | RROutputChangeNotifyMask);
438 Env::GetInstance()->AddObserver(this); 438 Env::GetInstance()->AddObserver(this);
439 } 439 }
440 440
441 RootWindowHostX11::~RootWindowHostX11() { 441 RootWindowHostX11::~RootWindowHostX11() {
442 Env::GetInstance()->RemoveObserver(this); 442 Env::GetInstance()->RemoveObserver(this);
443 base::MessagePumpAuraX11::Current()->RemoveDispatcherForRootWindow(this); 443 base::MessagePumpX11::Current()->RemoveDispatcherForRootWindow(this);
444 base::MessagePumpAuraX11::Current()->RemoveDispatcherForWindow(xwindow_); 444 base::MessagePumpX11::Current()->RemoveDispatcherForWindow(xwindow_);
445 445
446 UnConfineCursor(); 446 UnConfineCursor();
447 447
448 XDestroyWindow(xdisplay_, xwindow_); 448 XDestroyWindow(xdisplay_, xwindow_);
449 } 449 }
450 450
451 bool RootWindowHostX11::Dispatch(const base::NativeEvent& event) { 451 bool RootWindowHostX11::Dispatch(const base::NativeEvent& event) {
452 XEvent* xev = event; 452 XEvent* xev = event;
453 453
454 if (FindEventTarget(event) == x_root_window_) 454 if (FindEventTarget(event) == x_root_window_)
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 // Set StaticGravity so that the window position is not affected by the 623 // Set StaticGravity so that the window position is not affected by the
624 // frame width when running with window manager. 624 // frame width when running with window manager.
625 size_hints.win_gravity = StaticGravity; 625 size_hints.win_gravity = StaticGravity;
626 XSetWMNormalHints(xdisplay_, xwindow_, &size_hints); 626 XSetWMNormalHints(xdisplay_, xwindow_, &size_hints);
627 627
628 XMapWindow(xdisplay_, xwindow_); 628 XMapWindow(xdisplay_, xwindow_);
629 629
630 // We now block until our window is mapped. Some X11 APIs will crash and 630 // We now block until our window is mapped. Some X11 APIs will crash and
631 // burn if passed |xwindow_| before the window is mapped, and XMapWindow is 631 // burn if passed |xwindow_| before the window is mapped, and XMapWindow is
632 // asynchronous. 632 // asynchronous.
633 base::MessagePumpAuraX11::Current()->BlockUntilWindowMapped(xwindow_); 633 base::MessagePumpX11::Current()->BlockUntilWindowMapped(xwindow_);
634 window_mapped_ = true; 634 window_mapped_ = true;
635 } 635 }
636 } 636 }
637 637
638 void RootWindowHostX11::Hide() { 638 void RootWindowHostX11::Hide() {
639 if (window_mapped_) { 639 if (window_mapped_) {
640 XWithdrawWindow(xdisplay_, xwindow_, 0); 640 XWithdrawWindow(xdisplay_, xwindow_, 0);
641 window_mapped_ = false; 641 window_mapped_ = false;
642 } 642 }
643 } 643 }
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 break; 847 break;
848 } 848 }
849 XSendEvent(xdisplay_, xwindow_, False, 0, &xevent); 849 XSendEvent(xdisplay_, xwindow_, False, 0, &xevent);
850 } 850 }
851 851
852 void RootWindowHostX11::OnDeviceScaleFactorChanged( 852 void RootWindowHostX11::OnDeviceScaleFactorChanged(
853 float device_scale_factor) { 853 float device_scale_factor) {
854 } 854 }
855 855
856 void RootWindowHostX11::PrepareForShutdown() { 856 void RootWindowHostX11::PrepareForShutdown() {
857 base::MessagePumpAuraX11::Current()->RemoveDispatcherForWindow(xwindow_); 857 base::MessagePumpX11::Current()->RemoveDispatcherForWindow(xwindow_);
858 } 858 }
859 859
860 void RootWindowHostX11::OnWindowInitialized(Window* window) { 860 void RootWindowHostX11::OnWindowInitialized(Window* window) {
861 } 861 }
862 862
863 void RootWindowHostX11::OnRootWindowInitialized(RootWindow* root_window) { 863 void RootWindowHostX11::OnRootWindowInitialized(RootWindow* root_window) {
864 // UpdateIsInternalDisplay relies on: 864 // UpdateIsInternalDisplay relies on:
865 // 1. delegate_ pointing to RootWindow - available after SetDelegate. 865 // 1. delegate_ pointing to RootWindow - available after SetDelegate.
866 // 2. RootWindow's kDisplayIdKey property set - available by the time 866 // 2. RootWindow's kDisplayIdKey property set - available by the time
867 // RootWindow::Init is called. 867 // RootWindow::Init is called.
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 #endif 1083 #endif
1084 } 1084 }
1085 1085
1086 // static 1086 // static
1087 RootWindowHost* RootWindowHost::Create(const gfx::Rect& bounds) { 1087 RootWindowHost* RootWindowHost::Create(const gfx::Rect& bounds) {
1088 return new RootWindowHostX11(bounds); 1088 return new RootWindowHostX11(bounds);
1089 } 1089 }
1090 1090
1091 // static 1091 // static
1092 gfx::Size RootWindowHost::GetNativeScreenSize() { 1092 gfx::Size RootWindowHost::GetNativeScreenSize() {
1093 ::Display* xdisplay = base::MessagePumpAuraX11::GetDefaultXDisplay(); 1093 ::Display* xdisplay = base::MessagePumpX11::GetDefaultXDisplay();
1094 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0)); 1094 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0));
1095 } 1095 }
1096 1096
1097 namespace test { 1097 namespace test {
1098 1098
1099 void SetUseOverrideRedirectWindowByDefault(bool override_redirect) { 1099 void SetUseOverrideRedirectWindowByDefault(bool override_redirect) {
1100 default_override_redirect = override_redirect; 1100 default_override_redirect = override_redirect;
1101 } 1101 }
1102 1102
1103 } // namespace test 1103 } // namespace test
1104 } // namespace aura 1104 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/env.cc ('k') | ui/aura/test/ui_controls_factory_aurax11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698