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 976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 987 } else { | 987 } else { |
| 988 char* role_c = const_cast<char*>(role.c_str()); | 988 char* role_c = const_cast<char*>(role.c_str()); |
| 989 XChangeProperty(display, window, GetAtom("WM_WINDOW_ROLE"), XA_STRING, 8, | 989 XChangeProperty(display, window, GetAtom("WM_WINDOW_ROLE"), XA_STRING, 8, |
| 990 PropModeReplace, | 990 PropModeReplace, |
| 991 reinterpret_cast<unsigned char*>(role_c), | 991 reinterpret_cast<unsigned char*>(role_c), |
| 992 role.size()); | 992 role.size()); |
| 993 } | 993 } |
| 994 } | 994 } |
| 995 | 995 |
| 996 bool GetCustomFramePrefDefault() { | 996 bool GetCustomFramePrefDefault() { |
| 997 // Ideally, we'd use the custom frame by default and just fall back on using | 997 // If the window manager doesn't support enough of EWMH to tell us its name, |
| 998 // system decorations for the few (?) tiling window managers where the custom | 998 // assume that it doesn't want custom frames. |
|
Matt Giuca
2014/09/17 01:09:16
I'm not sure why you make this assumption. If the
Daniel Erat
2014/09/18 16:07:58
if the WM doesn't support EWMH, then it doesn't un
Matt Giuca
2014/09/19 01:01:38
Acknowledged.
| |
| 999 // frame doesn't make sense (e.g. awesome, ion3, ratpoison, xmonad, etc.) or | 999 std::string wm_name; |
| 1000 // other WMs where it has issues (e.g. Fluxbox -- see issue 19130). The EWMH | 1000 if (!GetWindowManagerName(&wm_name)) |
| 1001 // _NET_SUPPORTING_WM property makes it easy to look up a name for the current | 1001 return false; |
| 1002 // WM, but at least some of the WMs in the latter group don't set it. | 1002 |
| 1003 // Instead, we default to using system decorations for all WMs and | 1003 // Also disable custom frames for (at-least-partially-)EWMH-supporting tiling |
| 1004 // special-case the ones where the custom frame should be used. | 1004 // window managers. |
| 1005 ui::WindowManagerName wm_type = GuessWindowManager(); | 1005 ui::WindowManagerName wm = GuessWindowManager(); |
| 1006 return (wm_type == WM_BLACKBOX || | 1006 if (wm == WM_AWESOME || |
| 1007 wm_type == WM_COMPIZ || | 1007 wm == WM_I3 || |
| 1008 wm_type == WM_ENLIGHTENMENT || | 1008 wm == WM_ION3 || |
| 1009 wm_type == WM_METACITY || | 1009 wm == WM_MATCHBOX || |
| 1010 wm_type == WM_MUFFIN || | 1010 wm == WM_NOTION || |
| 1011 wm_type == WM_MUTTER || | 1011 wm == WM_QTILE || |
| 1012 wm_type == WM_OPENBOX || | 1012 wm == WM_RATPOISON || |
| 1013 wm_type == WM_XFWM4); | 1013 wm == WM_STUMPWM) |
| 1014 return false; | |
| 1015 | |
| 1016 // Handle a few more window managers that don't get along well with custom | |
| 1017 // frames. | |
|
Daniel Erat
2014/09/16 23:48:34
at least, i'm assuming that their omission from th
Elliot Glaysher
2014/09/16 23:59:36
We've had problems with icewm in the past, at leas
| |
| 1018 if (wm == WM_ICE_WM || | |
| 1019 wm == WM_KWIN) | |
| 1020 return false; | |
| 1021 | |
| 1022 // For everything else, use custom frames. | |
| 1023 return true; | |
| 1014 } | 1024 } |
| 1015 | 1025 |
| 1016 bool GetWindowDesktop(XID window, int* desktop) { | 1026 bool GetWindowDesktop(XID window, int* desktop) { |
| 1017 return GetIntProperty(window, "_NET_WM_DESKTOP", desktop); | 1027 return GetIntProperty(window, "_NET_WM_DESKTOP", desktop); |
| 1018 } | 1028 } |
| 1019 | 1029 |
| 1020 std::string GetX11ErrorString(XDisplay* display, int err) { | 1030 std::string GetX11ErrorString(XDisplay* display, int err) { |
| 1021 char buffer[256]; | 1031 char buffer[256]; |
| 1022 XGetErrorText(display, err, buffer, arraysize(buffer)); | 1032 XGetErrorText(display, err, buffer, arraysize(buffer)); |
| 1023 return buffer; | 1033 return buffer; |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1184 return false; | 1194 return false; |
| 1185 } | 1195 } |
| 1186 | 1196 |
| 1187 return true; | 1197 return true; |
| 1188 } | 1198 } |
| 1189 | 1199 |
| 1190 WindowManagerName GuessWindowManager() { | 1200 WindowManagerName GuessWindowManager() { |
| 1191 std::string name; | 1201 std::string name; |
| 1192 if (GetWindowManagerName(&name)) { | 1202 if (GetWindowManagerName(&name)) { |
| 1193 // These names are taken from the WMs' source code. | 1203 // These names are taken from the WMs' source code. |
| 1204 if (name == "awesome") | |
| 1205 return WM_AWESOME; | |
| 1194 if (name == "Blackbox") | 1206 if (name == "Blackbox") |
| 1195 return WM_BLACKBOX; | 1207 return WM_BLACKBOX; |
| 1196 if (name == "chromeos-wm") | |
| 1197 return WM_CHROME_OS; | |
| 1198 if (name == "Compiz" || name == "compiz") | 1208 if (name == "Compiz" || name == "compiz") |
| 1199 return WM_COMPIZ; | 1209 return WM_COMPIZ; |
| 1200 if (name == "e16") | 1210 if (name == "e16") |
| 1201 return WM_ENLIGHTENMENT; | 1211 return WM_ENLIGHTENMENT; |
| 1202 if (StartsWithASCII(name, "IceWM", true)) | 1212 if (StartsWithASCII(name, "IceWM", true)) |
| 1203 return WM_ICE_WM; | 1213 return WM_ICE_WM; |
| 1204 if (name == "KWin") | 1214 if (name == "KWin") |
| 1205 return WM_KWIN; | 1215 return WM_KWIN; |
| 1206 if (name == "Metacity") | 1216 if (name == "Metacity") |
| 1207 return WM_METACITY; | 1217 return WM_METACITY; |
| 1208 if (name == "Mutter (Muffin)") | 1218 if (name == "Mutter (Muffin)") |
| 1209 return WM_MUFFIN; | 1219 return WM_MUFFIN; |
| 1210 if (name == "GNOME Shell") | 1220 if (name == "GNOME Shell") |
| 1211 return WM_MUTTER; // GNOME Shell uses Mutter | 1221 return WM_MUTTER; // GNOME Shell uses Mutter |
| 1222 if (name == "i3") | |
| 1223 return WM_I3; | |
| 1224 if (name == "ion3") | |
| 1225 return WM_ION3; | |
| 1226 if (name == "matchbox") | |
| 1227 return WM_MATCHBOX; | |
| 1212 if (name == "Mutter") | 1228 if (name == "Mutter") |
| 1213 return WM_MUTTER; | 1229 return WM_MUTTER; |
| 1230 if (name == "notion") // FIXME: Double-check this. | |
| 1231 return WM_NOTION; | |
| 1214 if (name == "Openbox") | 1232 if (name == "Openbox") |
| 1215 return WM_OPENBOX; | 1233 return WM_OPENBOX; |
| 1234 if (name == "qtile") | |
| 1235 return WM_QTILE; | |
| 1236 if (name == "ratpoison") | |
| 1237 return WM_OPENBOX; | |
| 1238 if (name == "stumpwm") | |
| 1239 return WM_STUMPWM; | |
| 1216 if (name == "Xfwm4") | 1240 if (name == "Xfwm4") |
| 1217 return WM_XFWM4; | 1241 return WM_XFWM4; |
| 1218 } | 1242 } |
| 1219 return WM_UNKNOWN; | 1243 return WM_UNKNOWN; |
| 1220 } | 1244 } |
| 1221 | 1245 |
| 1222 std::string GuessWindowManagerName() { | 1246 std::string GuessWindowManagerName() { |
| 1223 std::string name; | 1247 std::string name; |
| 1224 if (GetWindowManagerName(&name)) | 1248 if (GetWindowManagerName(&name)) |
| 1225 return name; | 1249 return name; |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1420 << "request_code " << static_cast<int>(error_event.request_code) << ", " | 1444 << "request_code " << static_cast<int>(error_event.request_code) << ", " |
| 1421 << "minor_code " << static_cast<int>(error_event.minor_code) | 1445 << "minor_code " << static_cast<int>(error_event.minor_code) |
| 1422 << " (" << request_str << ")"; | 1446 << " (" << request_str << ")"; |
| 1423 } | 1447 } |
| 1424 | 1448 |
| 1425 // ---------------------------------------------------------------------------- | 1449 // ---------------------------------------------------------------------------- |
| 1426 // End of x11_util_internal.h | 1450 // End of x11_util_internal.h |
| 1427 | 1451 |
| 1428 | 1452 |
| 1429 } // namespace ui | 1453 } // namespace ui |
| OLD | NEW |