| 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 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1185 } | 1185 } |
| 1186 | 1186 |
| 1187 void SetDefaultX11ErrorHandlers() { | 1187 void SetDefaultX11ErrorHandlers() { |
| 1188 SetX11ErrorHandlers(NULL, NULL); | 1188 SetX11ErrorHandlers(NULL, NULL); |
| 1189 } | 1189 } |
| 1190 | 1190 |
| 1191 bool IsX11WindowFullScreen(XID window) { | 1191 bool IsX11WindowFullScreen(XID window) { |
| 1192 // If _NET_WM_STATE_FULLSCREEN is in _NET_SUPPORTED, use the presence or | 1192 // If _NET_WM_STATE_FULLSCREEN is in _NET_SUPPORTED, use the presence or |
| 1193 // absence of _NET_WM_STATE_FULLSCREEN in _NET_WM_STATE to determine | 1193 // absence of _NET_WM_STATE_FULLSCREEN in _NET_WM_STATE to determine |
| 1194 // whether we're fullscreen. | 1194 // whether we're fullscreen. |
| 1195 std::vector<Atom> supported_atoms; | 1195 Atom fullscreen_atom = GetAtom("_NET_WM_STATE_FULLSCREEN"); |
| 1196 if (GetAtomArrayProperty(GetX11RootWindow(), | 1196 if (WmSupportsHint(fullscreen_atom)) { |
| 1197 "_NET_SUPPORTED", | 1197 std::vector<Atom> atom_properties; |
| 1198 &supported_atoms)) { | 1198 if (GetAtomArrayProperty(window, |
| 1199 Atom atom = GetAtom("_NET_WM_STATE_FULLSCREEN"); | 1199 "_NET_WM_STATE", |
| 1200 | 1200 &atom_properties)) { |
| 1201 if (std::find(supported_atoms.begin(), supported_atoms.end(), atom) | 1201 return std::find(atom_properties.begin(), |
| 1202 != supported_atoms.end()) { | 1202 atom_properties.end(), |
| 1203 std::vector<Atom> atom_properties; | 1203 fullscreen_atom) != |
| 1204 if (GetAtomArrayProperty(window, | 1204 atom_properties.end(); |
| 1205 "_NET_WM_STATE", | |
| 1206 &atom_properties)) { | |
| 1207 return std::find(atom_properties.begin(), atom_properties.end(), atom) | |
| 1208 != atom_properties.end(); | |
| 1209 } | |
| 1210 } | 1205 } |
| 1211 } | 1206 } |
| 1212 | 1207 |
| 1213 gfx::Rect window_rect; | 1208 gfx::Rect window_rect; |
| 1214 if (!ui::GetWindowRect(window, &window_rect)) | 1209 if (!ui::GetWindowRect(window, &window_rect)) |
| 1215 return false; | 1210 return false; |
| 1216 | 1211 |
| 1217 // We can't use gfx::Screen here because we don't have an aura::Window. So | 1212 // We can't use gfx::Screen here because we don't have an aura::Window. So |
| 1218 // instead just look at the size of the default display. | 1213 // instead just look at the size of the default display. |
| 1219 // | 1214 // |
| 1220 // TODO(erg): Actually doing this correctly would require pulling out xrandr, | 1215 // TODO(erg): Actually doing this correctly would require pulling out xrandr, |
| 1221 // which we don't even do in the desktop screen yet. | 1216 // which we don't even do in the desktop screen yet. |
| 1222 ::XDisplay* display = gfx::GetXDisplay(); | 1217 ::XDisplay* display = gfx::GetXDisplay(); |
| 1223 ::Screen* screen = DefaultScreenOfDisplay(display); | 1218 ::Screen* screen = DefaultScreenOfDisplay(display); |
| 1224 int width = WidthOfScreen(screen); | 1219 int width = WidthOfScreen(screen); |
| 1225 int height = HeightOfScreen(screen); | 1220 int height = HeightOfScreen(screen); |
| 1226 return window_rect.size() == gfx::Size(width, height); | 1221 return window_rect.size() == gfx::Size(width, height); |
| 1227 } | 1222 } |
| 1228 | 1223 |
| 1224 bool WmSupportsHint(Atom atom) { |
| 1225 std::vector<Atom> supported_atoms; |
| 1226 if (!GetAtomArrayProperty(GetX11RootWindow(), |
| 1227 "_NET_SUPPORTED", |
| 1228 &supported_atoms)) { |
| 1229 return false; |
| 1230 } |
| 1231 |
| 1232 return std::find(supported_atoms.begin(), supported_atoms.end(), atom) != |
| 1233 supported_atoms.end(); |
| 1234 } |
| 1235 |
| 1229 const unsigned char* XRefcountedMemory::front() const { | 1236 const unsigned char* XRefcountedMemory::front() const { |
| 1230 return x11_data_; | 1237 return x11_data_; |
| 1231 } | 1238 } |
| 1232 | 1239 |
| 1233 size_t XRefcountedMemory::size() const { | 1240 size_t XRefcountedMemory::size() const { |
| 1234 return length_; | 1241 return length_; |
| 1235 } | 1242 } |
| 1236 | 1243 |
| 1237 XRefcountedMemory::~XRefcountedMemory() { | 1244 XRefcountedMemory::~XRefcountedMemory() { |
| 1238 XFree(x11_data_); | 1245 XFree(x11_data_); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1371 << "request_code " << static_cast<int>(error_event.request_code) << ", " | 1378 << "request_code " << static_cast<int>(error_event.request_code) << ", " |
| 1372 << "minor_code " << static_cast<int>(error_event.minor_code) | 1379 << "minor_code " << static_cast<int>(error_event.minor_code) |
| 1373 << " (" << request_str << ")"; | 1380 << " (" << request_str << ")"; |
| 1374 } | 1381 } |
| 1375 | 1382 |
| 1376 // ---------------------------------------------------------------------------- | 1383 // ---------------------------------------------------------------------------- |
| 1377 // End of x11_util_internal.h | 1384 // End of x11_util_internal.h |
| 1378 | 1385 |
| 1379 | 1386 |
| 1380 } // namespace ui | 1387 } // namespace ui |
| OLD | NEW |