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 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 black.red = black.green = black.blue = 0; | 456 black.red = black.green = black.blue = 0; |
457 Pixmap blank = XCreateBitmapFromData(xdisplay, | 457 Pixmap blank = XCreateBitmapFromData(xdisplay, |
458 DefaultRootWindow(xdisplay), | 458 DefaultRootWindow(xdisplay), |
459 nodata, 8, 8); | 459 nodata, 8, 8); |
460 invisible_cursor = XCreatePixmapCursor(xdisplay, blank, blank, | 460 invisible_cursor = XCreatePixmapCursor(xdisplay, blank, blank, |
461 &black, &black, 0, 0); | 461 &black, &black, 0, 0); |
462 XFreePixmap(xdisplay, blank); | 462 XFreePixmap(xdisplay, blank); |
463 return invisible_cursor; | 463 return invisible_cursor; |
464 } | 464 } |
465 | 465 |
| 466 void SetUseOSWindowFrame(XID window, bool use_os_window_frame) { |
| 467 // This data structure represents additional hints that we send to the window |
| 468 // manager and has a direct lineage back to Motif, which defined this de facto |
| 469 // standard. This struct doesn't seem 64-bit safe though, but it's what GDK |
| 470 // does. |
| 471 typedef struct { |
| 472 unsigned long flags; |
| 473 unsigned long functions; |
| 474 unsigned long decorations; |
| 475 long input_mode; |
| 476 unsigned long status; |
| 477 } MotifWmHints; |
| 478 |
| 479 MotifWmHints motif_hints; |
| 480 memset(&motif_hints, 0, sizeof(motif_hints)); |
| 481 // Signals that the reader of the _MOTIF_WM_HINTS property should pay |
| 482 // attention to the value of |decorations|. |
| 483 motif_hints.flags = (1L << 1); |
| 484 motif_hints.decorations = use_os_window_frame ? 1 : 0; |
| 485 |
| 486 ::Atom hint_atom = GetAtom("_MOTIF_WM_HINTS"); |
| 487 XChangeProperty(gfx::GetXDisplay(), |
| 488 window, |
| 489 hint_atom, |
| 490 hint_atom, |
| 491 32, |
| 492 PropModeReplace, |
| 493 reinterpret_cast<unsigned char*>(&motif_hints), |
| 494 sizeof(MotifWmHints)/sizeof(long)); |
| 495 } |
| 496 |
466 bool IsShapeExtensionAvailable() { | 497 bool IsShapeExtensionAvailable() { |
467 int dummy; | 498 int dummy; |
468 static bool is_shape_available = | 499 static bool is_shape_available = |
469 XShapeQueryExtension(gfx::GetXDisplay(), &dummy, &dummy); | 500 XShapeQueryExtension(gfx::GetXDisplay(), &dummy, &dummy); |
470 return is_shape_available; | 501 return is_shape_available; |
471 } | 502 } |
472 | 503 |
473 XID GetX11RootWindow() { | 504 XID GetX11RootWindow() { |
474 return DefaultRootWindow(gfx::GetXDisplay()); | 505 return DefaultRootWindow(gfx::GetXDisplay()); |
475 } | 506 } |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
848 window, | 879 window, |
849 name_atom, | 880 name_atom, |
850 type_atom, | 881 type_atom, |
851 32, // size in bits of items in 'value' | 882 32, // size in bits of items in 'value' |
852 PropModeReplace, | 883 PropModeReplace, |
853 reinterpret_cast<const unsigned char*>(data.get()), | 884 reinterpret_cast<const unsigned char*>(data.get()), |
854 value.size()); // num items | 885 value.size()); // num items |
855 return !err_tracker.FoundNewError(); | 886 return !err_tracker.FoundNewError(); |
856 } | 887 } |
857 | 888 |
| 889 bool SetAtomProperty(XID window, |
| 890 const std::string& name, |
| 891 const std::string& type, |
| 892 Atom value) { |
| 893 return SetAtomArrayProperty(window, name, type, std::vector<Atom>(1, value)); |
| 894 } |
| 895 |
858 bool SetAtomArrayProperty(XID window, | 896 bool SetAtomArrayProperty(XID window, |
859 const std::string& name, | 897 const std::string& name, |
860 const std::string& type, | 898 const std::string& type, |
861 const std::vector<Atom>& value) { | 899 const std::vector<Atom>& value) { |
862 DCHECK(!value.empty()); | 900 DCHECK(!value.empty()); |
863 Atom name_atom = GetAtom(name.c_str()); | 901 Atom name_atom = GetAtom(name.c_str()); |
864 Atom type_atom = GetAtom(type.c_str()); | 902 Atom type_atom = GetAtom(type.c_str()); |
865 | 903 |
866 // XChangeProperty() expects values of type 32 to be longs. | 904 // XChangeProperty() expects values of type 32 to be longs. |
867 scoped_ptr<Atom[]> data(new Atom[value.size()]); | 905 scoped_ptr<Atom[]> data(new Atom[value.size()]); |
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1371 << "request_code " << static_cast<int>(error_event.request_code) << ", " | 1409 << "request_code " << static_cast<int>(error_event.request_code) << ", " |
1372 << "minor_code " << static_cast<int>(error_event.minor_code) | 1410 << "minor_code " << static_cast<int>(error_event.minor_code) |
1373 << " (" << request_str << ")"; | 1411 << " (" << request_str << ")"; |
1374 } | 1412 } |
1375 | 1413 |
1376 // ---------------------------------------------------------------------------- | 1414 // ---------------------------------------------------------------------------- |
1377 // End of x11_util_internal.h | 1415 // End of x11_util_internal.h |
1378 | 1416 |
1379 | 1417 |
1380 } // namespace ui | 1418 } // namespace ui |
OLD | NEW |