Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_COMMON_X11_UTIL_H_
6 #define CHROME_COMMON_X11_UTIL_H_
8 // This file declares utility functions for X11 (Linux only).
9 //
10 // These functions do not require the Xlib headers to be included (which is why
11 // we use a void* for Visual*). The Xlib headers are highly polluting so we try
12 // hard to limit their spread into the rest of the code.
14 #if (MOZ_WIDGET_GTK == 2)
15 typedef struct _GdkDrawable GdkWindow;
16 #else
17 typedef struct _GdkWindow GdkWindow;
18 #endif
19 typedef struct _GtkWidget GtkWidget;
20 typedef unsigned long XID;
21 typedef struct _XDisplay Display;
23 namespace base {
24 class Thread;
25 }
26 namespace x11_util {
28 // These functions use the GDK default display and this /must/ be called from
29 // the UI thread. Thus, they don't support multiple displays.
31 // These functions cache their results.
33 // Return an X11 connection for the current, primary display.
34 Display* GetXDisplay();
35 // Return true iff the connection supports X shared memory
36 bool QuerySharedMemorySupport(Display* dpy);
37 // Return true iff the display supports Xrender
38 bool QueryRenderSupport(Display* dpy);
39 // Return the default screen number for the display
40 int GetDefaultScreen(Display* display);
42 // These functions do not cache their results
44 // Get the X window id for the default root window
45 XID GetX11RootWindow();
46 // Get the X window id for the given GTK widget.
47 XID GetX11WindowFromGtkWidget(GtkWidget*);
48 XID GetX11WindowFromGdkWindow(GdkWindow*);
49 // Get a Visual from the given widget. Since we don't include the Xlib
50 // headers, this is returned as a void*.
51 void* GetVisualFromGtkWidget(GtkWidget*);
52 // Return the number of bits-per-pixel for a pixmap of the given depth
53 int BitsPerPixelForPixmapDepth(Display*, int depth);
55 // Return a handle to a server side pixmap. |shared_memory_key| is a SysV
56 // IPC key. The shared memory region must contain 32-bit pixels.
57 XID AttachSharedMemory(Display* display, int shared_memory_support);
58 void DetachSharedMemory(Display* display, XID shmseg);
60 // Return a handle to an XRender picture where |pixmap| is a handle to a
61 // pixmap containing Skia ARGB data.
62 XID CreatePictureFromSkiaPixmap(Display* display, XID pixmap);
64 void FreePicture(Display* display, XID picture);
65 void FreePixmap(Display* display, XID pixmap);
67 // These functions are for performing X opertions outside of the UI thread.
69 // Return the Display for the secondary X connection. We keep a second
70 // connection around for making X requests outside of the UI thread.
71 // This function may only be called from the BACKGROUND_X11 thread.
72 Display* GetSecondaryDisplay();
74 // Since one cannot include both WebKit header and Xlib headers in the same
75 // file (due to collisions), we wrap all the Xlib functions that we need here.
76 // These functions must be called on the BACKGROUND_X11 thread since they
77 // reference GetSecondaryDisplay().
79 // Get the position of the given window in screen coordinates as well as its
80 // current size.
81 bool GetWindowGeometry(int* x, int* y, unsigned* width, unsigned* height,
82 XID window);
84 // Find the immediate parent of an X window.
85 //
86 // parent_window: (output) the parent window of |window|, or 0.
87 // parent_is_root: (output) true iff the parent of |window| is the root window.
88 bool GetWindowParent(XID* parent_window, bool* parent_is_root, XID window);
90 } // namespace x11_util
92 #endif // CHROME_COMMON_X11_UTIL_H_