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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/ipc/chromium/src/chrome/common/x11_util.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,92 @@
     1.4 +// Copyright (c) 2009 The Chromium Authors. All rights reserved.
     1.5 +// Use of this source code is governed by a BSD-style license that can be
     1.6 +// found in the LICENSE file.
     1.7 +
     1.8 +#ifndef CHROME_COMMON_X11_UTIL_H_
     1.9 +#define CHROME_COMMON_X11_UTIL_H_
    1.10 +
    1.11 +// This file declares utility functions for X11 (Linux only).
    1.12 +//
    1.13 +// These functions do not require the Xlib headers to be included (which is why
    1.14 +// we use a void* for Visual*). The Xlib headers are highly polluting so we try
    1.15 +// hard to limit their spread into the rest of the code.
    1.16 +
    1.17 +#if (MOZ_WIDGET_GTK == 2)
    1.18 +typedef struct _GdkDrawable GdkWindow;
    1.19 +#else
    1.20 +typedef struct _GdkWindow GdkWindow;
    1.21 +#endif
    1.22 +typedef struct _GtkWidget GtkWidget;
    1.23 +typedef unsigned long XID;
    1.24 +typedef struct _XDisplay Display;
    1.25 +
    1.26 +namespace base {
    1.27 +class Thread;
    1.28 +}
    1.29 +namespace x11_util {
    1.30 +
    1.31 +// These functions use the GDK default display and this /must/ be called from
    1.32 +// the UI thread. Thus, they don't support multiple displays.
    1.33 +
    1.34 +// These functions cache their results.
    1.35 +
    1.36 +// Return an X11 connection for the current, primary display.
    1.37 +Display* GetXDisplay();
    1.38 +// Return true iff the connection supports X shared memory
    1.39 +bool QuerySharedMemorySupport(Display* dpy);
    1.40 +// Return true iff the display supports Xrender
    1.41 +bool QueryRenderSupport(Display* dpy);
    1.42 +// Return the default screen number for the display
    1.43 +int GetDefaultScreen(Display* display);
    1.44 +
    1.45 +// These functions do not cache their results
    1.46 +
    1.47 +// Get the X window id for the default root window
    1.48 +XID GetX11RootWindow();
    1.49 +// Get the X window id for the given GTK widget.
    1.50 +XID GetX11WindowFromGtkWidget(GtkWidget*);
    1.51 +XID GetX11WindowFromGdkWindow(GdkWindow*);
    1.52 +// Get a Visual from the given widget. Since we don't include the Xlib
    1.53 +// headers, this is returned as a void*.
    1.54 +void* GetVisualFromGtkWidget(GtkWidget*);
    1.55 +// Return the number of bits-per-pixel for a pixmap of the given depth
    1.56 +int BitsPerPixelForPixmapDepth(Display*, int depth);
    1.57 +
    1.58 +// Return a handle to a server side pixmap. |shared_memory_key| is a SysV
    1.59 +// IPC key. The shared memory region must contain 32-bit pixels.
    1.60 +XID AttachSharedMemory(Display* display, int shared_memory_support);
    1.61 +void DetachSharedMemory(Display* display, XID shmseg);
    1.62 +
    1.63 +// Return a handle to an XRender picture where |pixmap| is a handle to a
    1.64 +// pixmap containing Skia ARGB data.
    1.65 +XID CreatePictureFromSkiaPixmap(Display* display, XID pixmap);
    1.66 +
    1.67 +void FreePicture(Display* display, XID picture);
    1.68 +void FreePixmap(Display* display, XID pixmap);
    1.69 +
    1.70 +// These functions are for performing X opertions outside of the UI thread.
    1.71 +
    1.72 +// Return the Display for the secondary X connection. We keep a second
    1.73 +// connection around for making X requests outside of the UI thread.
    1.74 +// This function may only be called from the BACKGROUND_X11 thread.
    1.75 +Display* GetSecondaryDisplay();
    1.76 +
    1.77 +// Since one cannot include both WebKit header and Xlib headers in the same
    1.78 +// file (due to collisions), we wrap all the Xlib functions that we need here.
    1.79 +// These functions must be called on the BACKGROUND_X11 thread since they
    1.80 +// reference GetSecondaryDisplay().
    1.81 +
    1.82 +// Get the position of the given window in screen coordinates as well as its
    1.83 +// current size.
    1.84 +bool GetWindowGeometry(int* x, int* y, unsigned* width, unsigned* height,
    1.85 +                       XID window);
    1.86 +
    1.87 +// Find the immediate parent of an X window.
    1.88 +//
    1.89 +// parent_window: (output) the parent window of |window|, or 0.
    1.90 +// parent_is_root: (output) true iff the parent of |window| is the root window.
    1.91 +bool GetWindowParent(XID* parent_window, bool* parent_is_root, XID window);
    1.92 +
    1.93 +}  // namespace x11_util
    1.94 +
    1.95 +#endif  // CHROME_COMMON_X11_UTIL_H_

mercurial