Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1302 int result = XSendEvent(GetXDisplay(), GetX11RootWindow(), False, | 1302 int result = XSendEvent(GetXDisplay(), GetX11RootWindow(), False, |
| 1303 SubstructureNotifyMask, &event); | 1303 SubstructureNotifyMask, &event); |
| 1304 return result == Success; | 1304 return result == Success; |
| 1305 } | 1305 } |
| 1306 | 1306 |
| 1307 void SetDefaultX11ErrorHandlers() { | 1307 void SetDefaultX11ErrorHandlers() { |
| 1308 SetX11ErrorHandlers(NULL, NULL); | 1308 SetX11ErrorHandlers(NULL, NULL); |
| 1309 } | 1309 } |
| 1310 | 1310 |
| 1311 bool IsX11WindowFullScreen(XID window) { | 1311 bool IsX11WindowFullScreen(XID window) { |
| 1312 // First check if _NET_WM_STATE property contains _NET_WM_STATE_FULLSCREEN. | 1312 // If _NET_WM_STATE_FULLSCREEN is in _NET_SUPPORTED, use the presence or |
| 1313 static Atom atom = GetAtom("_NET_WM_STATE_FULLSCREEN"); | 1313 // absence of _NET_WM_STATE_FULLSCREEN in _NET_WM_STATE to determine |
| 1314 // whether we're fullscreen. | |
| 1315 std::vector<Atom> supported_atoms; | |
| 1316 if (GetAtomArrayProperty(GetX11RootWindow(), | |
| 1317 "_NET_SUPPORTED", | |
| 1318 &supported_atoms)) { | |
| 1319 Atom atom = GetAtom("_NET_WM_STATE_FULLSCREEN"); | |
| 1314 | 1320 |
| 1315 std::vector<Atom> atom_properties; | 1321 if (std::find(supported_atoms.begin(), supported_atoms.end(), atom) |
| 1316 if (GetAtomArrayProperty(window, | 1322 != supported_atoms.end()) { |
| 1317 "_NET_WM_STATE", | 1323 |
|
Daniel Erat
2013/06/03 18:34:39
nit: delete extra blank line
| |
| 1318 &atom_properties) && | 1324 std::vector<Atom> atom_properties; |
| 1319 std::find(atom_properties.begin(), atom_properties.end(), atom) | 1325 if (GetAtomArrayProperty(window, |
| 1320 != atom_properties.end()) | 1326 "_NET_WM_STATE", |
| 1321 return true; | 1327 &atom_properties)) { |
| 1328 return std::find(atom_properties.begin(), atom_properties.end(), atom) | |
| 1329 != atom_properties.end(); | |
| 1330 } | |
| 1331 } | |
| 1332 } | |
| 1333 | |
| 1334 gfx::Rect window_rect; | |
| 1335 if (!ui::GetWindowRect(window, &window_rect)) | |
| 1336 return false; | |
| 1322 | 1337 |
| 1323 #if defined(TOOLKIT_GTK) | 1338 #if defined(TOOLKIT_GTK) |
| 1324 // As the last resort, check if the window size is as large as the main | 1339 // As the last resort, check if the window size is as large as the main |
| 1325 // screen. | 1340 // screen. |
| 1326 GdkRectangle monitor_rect; | 1341 GdkRectangle monitor_rect; |
| 1327 gdk_screen_get_monitor_geometry(gdk_screen_get_default(), 0, &monitor_rect); | 1342 gdk_screen_get_monitor_geometry(gdk_screen_get_default(), 0, &monitor_rect); |
| 1328 | 1343 |
| 1329 gfx::Rect window_rect; | |
| 1330 if (!ui::GetWindowRect(window, &window_rect)) | |
| 1331 return false; | |
| 1332 | |
| 1333 return monitor_rect.x == window_rect.x() && | 1344 return monitor_rect.x == window_rect.x() && |
| 1334 monitor_rect.y == window_rect.y() && | 1345 monitor_rect.y == window_rect.y() && |
| 1335 monitor_rect.width == window_rect.width() && | 1346 monitor_rect.width == window_rect.width() && |
| 1336 monitor_rect.height == window_rect.height(); | 1347 monitor_rect.height == window_rect.height(); |
| 1337 #else | 1348 #else |
| 1338 NOTIMPLEMENTED(); | 1349 // We can't use gfx::Screen here because we don't have an aura::Window. So |
| 1339 return false; | 1350 // instead just look at the size of the default display. |
| 1351 // | |
| 1352 // TODO(erg): Actually doing this correctly would require pulling out xrandr, | |
| 1353 // which we don't even do in the desktop screen yet. | |
| 1354 ::Display* display = ui::GetXDisplay(); | |
| 1355 ::Screen* screen = DefaultScreenOfDisplay(display); | |
| 1356 int width = WidthOfScreen(screen); | |
| 1357 int height = HeightOfScreen(screen); | |
| 1358 return window_rect.size() == gfx::Size(width, height); | |
| 1340 #endif | 1359 #endif |
| 1341 } | 1360 } |
| 1342 | 1361 |
| 1343 bool IsMotionEvent(XEvent* event) { | 1362 bool IsMotionEvent(XEvent* event) { |
| 1344 int type = event->type; | 1363 int type = event->type; |
| 1345 if (type == GenericEvent) | 1364 if (type == GenericEvent) |
| 1346 type = event->xgeneric.evtype; | 1365 type = event->xgeneric.evtype; |
| 1347 return type == MotionNotify; | 1366 return type == MotionNotify; |
| 1348 } | 1367 } |
| 1349 | 1368 |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1540 << "request_code " << static_cast<int>(error_event.request_code) << ", " | 1559 << "request_code " << static_cast<int>(error_event.request_code) << ", " |
| 1541 << "minor_code " << static_cast<int>(error_event.minor_code) | 1560 << "minor_code " << static_cast<int>(error_event.minor_code) |
| 1542 << " (" << request_str << ")"; | 1561 << " (" << request_str << ")"; |
| 1543 } | 1562 } |
| 1544 | 1563 |
| 1545 // ---------------------------------------------------------------------------- | 1564 // ---------------------------------------------------------------------------- |
| 1546 // End of x11_util_internal.h | 1565 // End of x11_util_internal.h |
| 1547 | 1566 |
| 1548 | 1567 |
| 1549 } // namespace ui | 1568 } // namespace ui |
| OLD | NEW |