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

Side by Side Diff: ui/base/x/x11_util.cc

Issue 268673017: Fix X11TopmostWindowFinder (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 // This file defines utility functions for X11 (Linux only). This code has been 5 // This file defines utility functions for X11 (Linux only). This code has been
6 // ported from XCB since we can't use XCB on Ubuntu while its 32-bit support 6 // ported from XCB since we can't use XCB on Ubuntu while its 32-bit support
7 // remains woefully incomplete. 7 // remains woefully incomplete.
8 8
9 #include "ui/base/x/x11_util.h" 9 #include "ui/base/x/x11_util.h"
10 10
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 209
210 XCustomCursorCache() {} 210 XCustomCursorCache() {}
211 ~XCustomCursorCache() { 211 ~XCustomCursorCache() {
212 Clear(); 212 Clear();
213 } 213 }
214 214
215 std::map< ::Cursor, XCustomCursor*> cache_; 215 std::map< ::Cursor, XCustomCursor*> cache_;
216 DISALLOW_COPY_AND_ASSIGN(XCustomCursorCache); 216 DISALLOW_COPY_AND_ASSIGN(XCustomCursorCache);
217 }; 217 };
218 218
219 bool IsShapeAvailable() {
220 int dummy;
221 static bool is_shape_available =
222 XShapeQueryExtension(gfx::GetXDisplay(), &dummy, &dummy);
223 return is_shape_available;
224
225 }
226
227 } // namespace 219 } // namespace
228 220
229 bool IsXInput2Available() { 221 bool IsXInput2Available() {
230 return DeviceDataManager::GetInstance()->IsXInput2Available(); 222 return DeviceDataManager::GetInstance()->IsXInput2Available();
231 } 223 }
232 224
233 static SharedMemorySupport DoQuerySharedMemorySupport(XDisplay* dpy) { 225 static SharedMemorySupport DoQuerySharedMemorySupport(XDisplay* dpy) {
234 int dummy; 226 int dummy;
235 Bool pixmaps_supported; 227 Bool pixmaps_supported;
236 // Query the server's support for XSHM. 228 // Query the server's support for XSHM.
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 black.red = black.green = black.blue = 0; 453 black.red = black.green = black.blue = 0;
462 Pixmap blank = XCreateBitmapFromData(xdisplay, 454 Pixmap blank = XCreateBitmapFromData(xdisplay,
463 DefaultRootWindow(xdisplay), 455 DefaultRootWindow(xdisplay),
464 nodata, 8, 8); 456 nodata, 8, 8);
465 invisible_cursor = XCreatePixmapCursor(xdisplay, blank, blank, 457 invisible_cursor = XCreatePixmapCursor(xdisplay, blank, blank,
466 &black, &black, 0, 0); 458 &black, &black, 0, 0);
467 XFreePixmap(xdisplay, blank); 459 XFreePixmap(xdisplay, blank);
468 return invisible_cursor; 460 return invisible_cursor;
469 } 461 }
470 462
463 bool IsShapeExtensionAvailable() {
464 int dummy;
465 static bool is_shape_available =
466 XShapeQueryExtension(gfx::GetXDisplay(), &dummy, &dummy);
467 return is_shape_available;
468 }
469
471 XID GetX11RootWindow() { 470 XID GetX11RootWindow() {
472 return DefaultRootWindow(gfx::GetXDisplay()); 471 return DefaultRootWindow(gfx::GetXDisplay());
473 } 472 }
474 473
475 bool GetCurrentDesktop(int* desktop) { 474 bool GetCurrentDesktop(int* desktop) {
476 return GetIntProperty(GetX11RootWindow(), "_NET_CURRENT_DESKTOP", desktop); 475 return GetIntProperty(GetX11RootWindow(), "_NET_CURRENT_DESKTOP", desktop);
477 } 476 }
478 477
479 void SetHideTitlebarWhenMaximizedProperty(XID window, 478 void SetHideTitlebarWhenMaximizedProperty(XID window,
480 HideTitlebarWhenMaximized property) { 479 HideTitlebarWhenMaximized property) {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 bool WindowContainsPoint(XID window, gfx::Point screen_loc) { 568 bool WindowContainsPoint(XID window, gfx::Point screen_loc) {
570 TRACE_EVENT0("ui", "WindowContainsPoint"); 569 TRACE_EVENT0("ui", "WindowContainsPoint");
571 570
572 gfx::Rect window_rect; 571 gfx::Rect window_rect;
573 if (!GetWindowRect(window, &window_rect)) 572 if (!GetWindowRect(window, &window_rect))
574 return false; 573 return false;
575 574
576 if (!window_rect.Contains(screen_loc)) 575 if (!window_rect.Contains(screen_loc))
577 return false; 576 return false;
578 577
579 if (!IsShapeAvailable()) 578 if (!IsShapeExtensionAvailable())
580 return true; 579 return true;
581 580
582 // According to http://www.x.org/releases/X11R7.6/doc/libXext/shapelib.html, 581 // According to http://www.x.org/releases/X11R7.6/doc/libXext/shapelib.html,
583 // if an X display supports the shape extension the bounds of a window are 582 // if an X display supports the shape extension the bounds of a window are
584 // defined as the intersection of the window bounds and the interior 583 // defined as the intersection of the window bounds and the interior
585 // rectangles. This means to determine if a point is inside a window for the 584 // rectangles. This means to determine if a point is inside a window for the
586 // purpose of input handling we have to check the rectangles in the ShapeInput 585 // purpose of input handling we have to check the rectangles in the ShapeInput
587 // list. 586 // list.
588 // According to http://www.x.org/releases/current/doc/xextproto/shape.html, 587 // According to http://www.x.org/releases/current/doc/xextproto/shape.html,
589 // we need to also respect the ShapeBounding rectangles. 588 // we need to also respect the ShapeBounding rectangles.
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after
1357 << "request_code " << static_cast<int>(error_event.request_code) << ", " 1356 << "request_code " << static_cast<int>(error_event.request_code) << ", "
1358 << "minor_code " << static_cast<int>(error_event.minor_code) 1357 << "minor_code " << static_cast<int>(error_event.minor_code)
1359 << " (" << request_str << ")"; 1358 << " (" << request_str << ")";
1360 } 1359 }
1361 1360
1362 // ---------------------------------------------------------------------------- 1361 // ----------------------------------------------------------------------------
1363 // End of x11_util_internal.h 1362 // End of x11_util_internal.h
1364 1363
1365 1364
1366 } // namespace ui 1365 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698