| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/x11_util.h" | 9 #include "app/x11_util.h" |
| 10 | 10 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 CachedPictFormats* get_cached_pict_formats() { | 45 CachedPictFormats* get_cached_pict_formats() { |
| 46 static CachedPictFormats* formats = NULL; | 46 static CachedPictFormats* formats = NULL; |
| 47 if (!formats) | 47 if (!formats) |
| 48 formats = new CachedPictFormats(); | 48 formats = new CachedPictFormats(); |
| 49 return formats; | 49 return formats; |
| 50 } | 50 } |
| 51 | 51 |
| 52 // Maximum number of CachedPictFormats we keep around. | 52 // Maximum number of CachedPictFormats we keep around. |
| 53 const size_t kMaxCacheSize = 5; | 53 const size_t kMaxCacheSize = 5; |
| 54 | 54 |
| 55 int X11ErrorHandler(Display* d, XErrorEvent* e) { |
| 56 LOG(FATAL) << "X Error detected: serial " << e->serial |
| 57 << " error_code " << static_cast<unsigned int>(e->error_code) |
| 58 << " request_code " << static_cast<unsigned int>(e->request_code) |
| 59 << " minor_code " << static_cast<unsigned int>(e->minor_code); |
| 60 return 0; |
| 61 } |
| 62 |
| 63 int X11IOErrorHandler(Display* d) { |
| 64 LOG(FATAL) << "X IO Error detected"; |
| 65 return 0; |
| 66 } |
| 67 |
| 55 } // namespace | 68 } // namespace |
| 56 | 69 |
| 70 void SetX11ErrorHandlers() { |
| 71 XSetErrorHandler(X11ErrorHandler); |
| 72 XSetIOErrorHandler(X11IOErrorHandler); |
| 73 } |
| 74 |
| 57 bool XDisplayExists() { | 75 bool XDisplayExists() { |
| 58 return (gdk_display_get_default() != NULL); | 76 return (gdk_display_get_default() != NULL); |
| 59 } | 77 } |
| 60 | 78 |
| 61 Display* GetXDisplay() { | 79 Display* GetXDisplay() { |
| 62 static Display* display = NULL; | 80 static Display* display = NULL; |
| 63 | 81 |
| 64 if (!display) | 82 if (!display) |
| 65 display = gdk_x11_get_default_xdisplay(); | 83 display = gdk_x11_get_default_xdisplay(); |
| 66 | 84 |
| (...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 event.xclient.format = 32; | 798 event.xclient.format = 32; |
| 781 event.xclient.data.l[0] = desktop; | 799 event.xclient.data.l[0] = desktop; |
| 782 event.xclient.data.l[1] = 1; // source indication | 800 event.xclient.data.l[1] = 1; // source indication |
| 783 | 801 |
| 784 int result = XSendEvent(GetXDisplay(), GetX11RootWindow(), False, | 802 int result = XSendEvent(GetXDisplay(), GetX11RootWindow(), False, |
| 785 SubstructureNotifyMask, &event); | 803 SubstructureNotifyMask, &event); |
| 786 return result == Success; | 804 return result == Success; |
| 787 } | 805 } |
| 788 | 806 |
| 789 } // namespace x11_util | 807 } // namespace x11_util |
| OLD | NEW |