ipc/chromium/src/chrome/common/x11_util.h

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

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

mercurial