tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

X11Util.h (1779B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef mozilla_X11Util_h
      8 #define mozilla_X11Util_h
      9 
     10 // Utilities common to all X clients, regardless of UI toolkit.
     11 
     12 #if defined(MOZ_WIDGET_GTK)
     13 #  include <gdk/gdk.h>
     14 #  include <gdk/gdkx.h>
     15 #  include "mozilla/WidgetUtilsGtk.h"
     16 #  include "X11UndefineNone.h"
     17 #else
     18 #  error Unknown toolkit
     19 #endif
     20 
     21 #include <string.h>  // for memset
     22 
     23 namespace mozilla {
     24 
     25 /**
     26 * Return the default X Display created and used by the UI toolkit.
     27 */
     28 inline Display* DefaultXDisplay() {
     29 #if defined(MOZ_WIDGET_GTK)
     30  GdkDisplay* gdkDisplay = gdk_display_get_default();
     31  if (mozilla::widget::GdkIsX11Display(gdkDisplay)) {
     32    return GDK_DISPLAY_XDISPLAY(gdkDisplay);
     33  }
     34 #endif
     35  return nullptr;
     36 }
     37 
     38 /**
     39 * Sets *aVisual to point to aDisplay's Visual struct corresponding to
     40 * aVisualID, and *aDepth to its depth.  When aVisualID is None, these are set
     41 * to nullptr and 0 respectively.  Both out-parameter pointers are assumed
     42 * non-nullptr.
     43 */
     44 void FindVisualAndDepth(Display* aDisplay, VisualID aVisualID, Visual** aVisual,
     45                        int* aDepth);
     46 
     47 /**
     48 * Ensure that all X requests have been processed.
     49 *
     50 * This is similar to XSync, but doesn't need a round trip if the previous
     51 * request was synchronous or if events have been received since the last
     52 * request.  Subsequent FinishX calls will be noops if there have been no
     53 * intermediate requests.
     54 */
     55 
     56 void FinishX(Display* aDisplay);
     57 
     58 }  // namespace mozilla
     59 
     60 #endif  // mozilla_X11Util_h