Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(283)

Side by Side Diff: ui/base/x/x11_util.h

Issue 7328011: Introduce ui.dll / libui.so for the component build. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef UI_BASE_X_X11_UTIL_H_ 5 #ifndef UI_BASE_X_X11_UTIL_H_
6 #define UI_BASE_X_X11_UTIL_H_ 6 #define UI_BASE_X_X11_UTIL_H_
7 #pragma once 7 #pragma once
8 8
9 // This file declares utility functions for X11 (Linux only). 9 // This file declares utility functions for X11 (Linux only).
10 // 10 //
11 // These functions do not require the Xlib headers to be included (which is why 11 // These functions do not require the Xlib headers to be included (which is why
12 // we use a void* for Visual*). The Xlib headers are highly polluting so we try 12 // we use a void* for Visual*). The Xlib headers are highly polluting so we try
13 // hard to limit their spread into the rest of the code. 13 // hard to limit their spread into the rest of the code.
14 14
15 #include <string> 15 #include <string>
16 #include <vector> 16 #include <vector>
17 17
18 #include "base/basictypes.h" 18 #include "base/basictypes.h"
19 #include "ui/ui_api.h"
19 20
20 typedef unsigned long Atom; 21 typedef unsigned long Atom;
21 typedef struct _GdkDrawable GdkWindow; 22 typedef struct _GdkDrawable GdkWindow;
22 typedef struct _GtkWidget GtkWidget; 23 typedef struct _GtkWidget GtkWidget;
23 typedef unsigned long XID; 24 typedef unsigned long XID;
24 typedef unsigned long XSharedMemoryId; // ShmSeg in the X headers. 25 typedef unsigned long XSharedMemoryId; // ShmSeg in the X headers.
25 typedef struct _XDisplay Display; 26 typedef struct _XDisplay Display;
26 27
27 namespace gfx { 28 namespace gfx {
28 class Rect; 29 class Rect;
29 } 30 }
30 31
31 namespace ui { 32 namespace ui {
32 33
33 // These functions use the GDK default display and this /must/ be called from 34 // These functions use the GDK default display and this /must/ be called from
34 // the UI thread. Thus, they don't support multiple displays. 35 // the UI thread. Thus, they don't support multiple displays.
35 36
36 // These functions cache their results --------------------------------- 37 // These functions cache their results ---------------------------------
37 38
38 // Check if there's an open connection to an X server. 39 // Check if there's an open connection to an X server.
39 bool XDisplayExists(); 40 UI_API bool XDisplayExists();
40 // Return an X11 connection for the current, primary display. 41 // Return an X11 connection for the current, primary display.
41 Display* GetXDisplay(); 42 UI_API Display* GetXDisplay();
42 43
43 // X shared memory comes in three flavors: 44 // X shared memory comes in three flavors:
44 // 1) No SHM support, 45 // 1) No SHM support,
45 // 2) SHM putimage, 46 // 2) SHM putimage,
46 // 3) SHM pixmaps + putimage. 47 // 3) SHM pixmaps + putimage.
47 enum SharedMemorySupport { 48 enum SharedMemorySupport {
48 SHARED_MEMORY_NONE, 49 SHARED_MEMORY_NONE,
49 SHARED_MEMORY_PUTIMAGE, 50 SHARED_MEMORY_PUTIMAGE,
50 SHARED_MEMORY_PIXMAP 51 SHARED_MEMORY_PIXMAP
51 }; 52 };
52 // Return the shared memory type of our X connection. 53 // Return the shared memory type of our X connection.
53 SharedMemorySupport QuerySharedMemorySupport(Display* dpy); 54 UI_API SharedMemorySupport QuerySharedMemorySupport(Display* dpy);
54 55
55 // Return true iff the display supports Xrender 56 // Return true iff the display supports Xrender
56 bool QueryRenderSupport(Display* dpy); 57 UI_API bool QueryRenderSupport(Display* dpy);
57 58
58 // Return the default screen number for the display 59 // Return the default screen number for the display
59 int GetDefaultScreen(Display* display); 60 int GetDefaultScreen(Display* display);
60 61
61 // These functions do not cache their results -------------------------- 62 // These functions do not cache their results --------------------------
62 63
63 // Get the X window id for the default root window 64 // Get the X window id for the default root window
64 XID GetX11RootWindow(); 65 UI_API XID GetX11RootWindow();
65 // Returns the user's current desktop. 66 // Returns the user's current desktop.
66 bool GetCurrentDesktop(int* desktop); 67 bool GetCurrentDesktop(int* desktop);
67 // Get the X window id for the given GTK widget. 68 // Get the X window id for the given GTK widget.
68 XID GetX11WindowFromGtkWidget(GtkWidget* widget); 69 UI_API XID GetX11WindowFromGtkWidget(GtkWidget* widget);
69 XID GetX11WindowFromGdkWindow(GdkWindow* window); 70 XID GetX11WindowFromGdkWindow(GdkWindow* window);
70 // Get a Visual from the given widget. Since we don't include the Xlib 71 // Get a Visual from the given widget. Since we don't include the Xlib
71 // headers, this is returned as a void*. 72 // headers, this is returned as a void*.
72 void* GetVisualFromGtkWidget(GtkWidget* widget); 73 UI_API void* GetVisualFromGtkWidget(GtkWidget* widget);
73 // Return the number of bits-per-pixel for a pixmap of the given depth 74 // Return the number of bits-per-pixel for a pixmap of the given depth
74 int BitsPerPixelForPixmapDepth(Display* display, int depth); 75 UI_API int BitsPerPixelForPixmapDepth(Display* display, int depth);
75 // Returns true if |window| is visible. 76 // Returns true if |window| is visible.
76 bool IsWindowVisible(XID window); 77 UI_API bool IsWindowVisible(XID window);
77 // Returns the bounds of |window|. 78 // Returns the bounds of |window|.
78 bool GetWindowRect(XID window, gfx::Rect* rect); 79 UI_API bool GetWindowRect(XID window, gfx::Rect* rect);
79 // Return true if |window| has any property with |property_name|. 80 // Return true if |window| has any property with |property_name|.
80 bool PropertyExists(XID window, const std::string& property_name); 81 UI_API bool PropertyExists(XID window, const std::string& property_name);
81 // Get the value of an int, int array, atom array or string property. On 82 // Get the value of an int, int array, atom array or string property. On
82 // success, true is returned and the value is stored in |value|. 83 // success, true is returned and the value is stored in |value|.
83 bool GetIntProperty(XID window, const std::string& property_name, int* value); 84 bool GetIntProperty(XID window, const std::string& property_name, int* value);
84 bool GetIntArrayProperty(XID window, const std::string& property_name, 85 bool GetIntArrayProperty(XID window, const std::string& property_name,
85 std::vector<int>* value); 86 std::vector<int>* value);
86 bool GetAtomArrayProperty(XID window, const std::string& property_name, 87 UI_API bool GetAtomArrayProperty(XID window, const std::string& property_name,
87 std::vector<Atom>* value); 88 std::vector<Atom>* value);
88 bool GetStringProperty( 89 UI_API bool GetStringProperty(
89 XID window, const std::string& property_name, std::string* value); 90 XID window, const std::string& property_name, std::string* value);
90 91
91 // Get |window|'s parent window, or None if |window| is the root window. 92 // Get |window|'s parent window, or None if |window| is the root window.
92 XID GetParentWindow(XID window); 93 XID GetParentWindow(XID window);
93 94
94 // Walk up |window|'s hierarchy until we find a direct child of |root|. 95 // Walk up |window|'s hierarchy until we find a direct child of |root|.
95 XID GetHighestAncestorWindow(XID window, XID root); 96 XID GetHighestAncestorWindow(XID window, XID root);
96 97
97 static const int kAllDesktops = -1; 98 static const int kAllDesktops = -1;
98 // Queries the desktop |window| is on, kAllDesktops if sticky. Returns false if 99 // Queries the desktop |window| is on, kAllDesktops if sticky. Returns false if
99 // property not found. 100 // property not found.
100 bool GetWindowDesktop(XID window, int* desktop); 101 bool GetWindowDesktop(XID window, int* desktop);
101 102
102 // Implementers of this interface receive a notification for every X window of 103 // Implementers of this interface receive a notification for every X window of
103 // the main display. 104 // the main display.
104 class EnumerateWindowsDelegate { 105 class EnumerateWindowsDelegate {
105 public: 106 public:
106 // |xid| is the X Window ID of the enumerated window. Return true to stop 107 // |xid| is the X Window ID of the enumerated window. Return true to stop
107 // further iteration. 108 // further iteration.
108 virtual bool ShouldStopIterating(XID xid) = 0; 109 virtual bool ShouldStopIterating(XID xid) = 0;
109 110
110 protected: 111 protected:
111 virtual ~EnumerateWindowsDelegate() {} 112 virtual ~EnumerateWindowsDelegate() {}
112 }; 113 };
113 114
114 // Enumerates all windows in the current display. Will recurse into child 115 // Enumerates all windows in the current display. Will recurse into child
115 // windows up to a depth of |max_depth|. 116 // windows up to a depth of |max_depth|.
116 bool EnumerateAllWindows(EnumerateWindowsDelegate* delegate, int max_depth); 117 UI_API bool EnumerateAllWindows(EnumerateWindowsDelegate* delegate,
118 int max_depth);
117 119
118 // Returns all children windows of a given window in top-to-bottom stacking 120 // Returns all children windows of a given window in top-to-bottom stacking
119 // order. 121 // order.
120 bool GetXWindowStack(XID window, std::vector<XID>* windows); 122 UI_API bool GetXWindowStack(XID window, std::vector<XID>* windows);
121 123
122 // Restack a window in relation to one of its siblings. If |above| is true, 124 // Restack a window in relation to one of its siblings. If |above| is true,
123 // |window| will be stacked directly above |sibling|; otherwise it will stacked 125 // |window| will be stacked directly above |sibling|; otherwise it will stacked
124 // directly below it. Both windows must be immediate children of the same 126 // directly below it. Both windows must be immediate children of the same
125 // window. 127 // window.
126 void RestackWindow(XID window, XID sibling, bool above); 128 void RestackWindow(XID window, XID sibling, bool above);
127 129
128 // Return a handle to a X ShmSeg. |shared_memory_key| is a SysV 130 // Return a handle to a X ShmSeg. |shared_memory_key| is a SysV
129 // IPC key. The shared memory region must contain 32-bit pixels. 131 // IPC key. The shared memory region must contain 32-bit pixels.
130 XSharedMemoryId AttachSharedMemory(Display* display, int shared_memory_support); 132 UI_API XSharedMemoryId AttachSharedMemory(Display* display,
131 void DetachSharedMemory(Display* display, XSharedMemoryId shmseg); 133 int shared_memory_support);
134 UI_API void DetachSharedMemory(Display* display, XSharedMemoryId shmseg);
132 135
133 // Return a handle to an XRender picture where |pixmap| is a handle to a 136 // Return a handle to an XRender picture where |pixmap| is a handle to a
134 // pixmap containing Skia ARGB data. 137 // pixmap containing Skia ARGB data.
135 XID CreatePictureFromSkiaPixmap(Display* display, XID pixmap); 138 UI_API XID CreatePictureFromSkiaPixmap(Display* display, XID pixmap);
136 139
137 // Draws ARGB data on the given pixmap using the given GC, converting to the 140 // Draws ARGB data on the given pixmap using the given GC, converting to the
138 // server side visual depth as needed. Destination is assumed to be the same 141 // server side visual depth as needed. Destination is assumed to be the same
139 // dimensions as |data| or larger. |data| is also assumed to be in row order 142 // dimensions as |data| or larger. |data| is also assumed to be in row order
140 // with each line being exactly |width| * 4 bytes long. 143 // with each line being exactly |width| * 4 bytes long.
141 void PutARGBImage(Display* display, void* visual, int depth, XID pixmap, 144 UI_API void PutARGBImage(Display* display, void* visual, int depth, XID pixmap,
142 void* pixmap_gc, const uint8* data, int width, int height); 145 void* pixmap_gc, const uint8* data, int width,
146 int height);
143 147
144 void FreePicture(Display* display, XID picture); 148 void FreePicture(Display* display, XID picture);
145 void FreePixmap(Display* display, XID pixmap); 149 void FreePixmap(Display* display, XID pixmap);
146 150
147 // Get the window manager name. 151 // Get the window manager name.
148 bool GetWindowManagerName(std::string* name); 152 UI_API bool GetWindowManagerName(std::string* name);
149 153
150 // Change desktop for |window| to the desktop of |destination| window. 154 // Change desktop for |window| to the desktop of |destination| window.
151 bool ChangeWindowDesktop(XID window, XID destination); 155 UI_API bool ChangeWindowDesktop(XID window, XID destination);
152 156
153 // Enable the default X error handlers. These will log the error and abort 157 // Enable the default X error handlers. These will log the error and abort
154 // the process if called. Use SetX11ErrorHandlers() from x11_util_internal.h 158 // the process if called. Use SetX11ErrorHandlers() from x11_util_internal.h
155 // to set your own error handlers. 159 // to set your own error handlers.
156 void SetDefaultX11ErrorHandlers(); 160 UI_API void SetDefaultX11ErrorHandlers();
157 161
158 // Return true if a given window is in full-screen mode. 162 // Return true if a given window is in full-screen mode.
159 bool IsX11WindowFullScreen(XID window); 163 UI_API bool IsX11WindowFullScreen(XID window);
160 164
161 } // namespace ui 165 } // namespace ui
162 166
163 #endif // UI_BASE_X_X11_UTIL_H_ 167 #endif // UI_BASE_X_X11_UTIL_H_
OLDNEW
« no previous file with comments | « ui/base/x/active_window_watcher_x.h ('k') | ui/base/x/x11_util_internal.h » ('j') | ui/ui.gyp » ('J')

Powered by Google App Engine
This is Rietveld 408576698