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

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

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

Powered by Google App Engine
This is Rietveld 408576698