コード例 #1
0
// this function will make sure that everything has been initialized.
nsresult
nsScreenManagerGtk :: EnsureInit()
{
  if (mCachedScreenArray.Count() > 0)
    return NS_OK;

  mRootWindow = gdk_get_default_root_window();
  if (!mRootWindow) {
    // Sometimes we don't initial X (e.g., xpcshell)
    return NS_OK;
  }

  g_object_ref(mRootWindow);

  // GDK_PROPERTY_CHANGE_MASK ==> PropertyChangeMask, for PropertyNotify
  gdk_window_set_events(mRootWindow,
                        GdkEventMask(gdk_window_get_events(mRootWindow) |
                                     GDK_PROPERTY_CHANGE_MASK));

  g_signal_connect(gdk_screen_get_default(), "monitors-changed",
                   G_CALLBACK(monitors_changed), this);
#ifdef MOZ_X11
  gdk_window_add_filter(mRootWindow, root_window_event_filter, this);
  if (GDK_IS_X11_DISPLAY(gdk_display_get_default()))
      mNetWorkareaAtom =
        XInternAtom(GDK_WINDOW_XDISPLAY(mRootWindow), "_NET_WORKAREA", False);
#endif

  return Init();
}
コード例 #2
0
static void
synaptics_check_capabilities (CcMousePropertiesPrivate *d)
{
	if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
		synaptics_check_capabilities_x11 (d);
	/* else we unconditionally show all touchpad knobs */
}
コード例 #3
0
ファイル: PlatformDisplay.cpp プロジェクト: endlessm/WebKit
std::unique_ptr<PlatformDisplay> PlatformDisplay::createPlatformDisplay()
{
#if PLATFORM(GTK)
#if defined(GTK_API_VERSION_2)
    return std::make_unique<PlatformDisplayX11>(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()));
#else
    GdkDisplay* display = gdk_display_manager_get_default_display(gdk_display_manager_get());
#if PLATFORM(X11)
    if (GDK_IS_X11_DISPLAY(display))
        return std::make_unique<PlatformDisplayX11>(GDK_DISPLAY_XDISPLAY(display));
#endif
#if PLATFORM(WAYLAND)
    if (GDK_IS_WAYLAND_DISPLAY(display))
        return std::make_unique<PlatformDisplayWayland>(gdk_wayland_display_get_wl_display(display));
#endif
#endif
#elif PLATFORM(EFL) && defined(HAVE_ECORE_X)
    return std::make_unique<PlatformDisplayX11>(static_cast<Display*>(ecore_x_display_get()));
#elif PLATFORM(WIN)
    return std::make_unique<PlatformDisplayWin>();
#endif

#if PLATFORM(X11)
    return std::make_unique<PlatformDisplayX11>();
#endif

    ASSERT_NOT_REACHED();
    return nullptr;
}
コード例 #4
0
ファイル: gtkselection.c プロジェクト: sam-m888/gtk
static gboolean
selection_set_compound_text (GtkSelectionData *selection_data,
			     const gchar      *str,
			     gint              len)
{
  gboolean result = FALSE;

#ifdef GDK_WINDOWING_X11
  gchar *tmp;
  guchar *text;
  GdkAtom encoding;
  gint format;
  gint new_length;

  if (GDK_IS_X11_DISPLAY (selection_data->display))
    {
      tmp = g_strndup (str, len);
      if (gdk_x11_display_utf8_to_compound_text (selection_data->display, tmp,
                                                 &encoding, &format, &text, &new_length))
        {
          gtk_selection_data_set (selection_data, encoding, format, text, new_length);
          gdk_x11_free_compound_text (text);

          result = TRUE;
        }
      g_free (tmp);
    }
#endif

  return result;
}
コード例 #5
0
static void
first_call_complete (GObject *proxy, GAsyncResult *res, RBMMKeysPlugin *plugin)
{
	GVariant *result;
	GError *error = NULL;
	GtkWindow *window;

	result = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, &error);
	if (error != NULL) {
		g_warning ("Unable to grab media player keys: %s", error->message);
		g_clear_error (&error);
#ifdef HAVE_MMKEYS
		if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) {
			mmkeys_grab (plugin, TRUE);
			plugin->grab_type = X_KEY_GRAB;
		}
#endif
		return;
	}

	rb_debug ("grabbed media player keys");

	g_signal_connect_object (plugin->proxy, "g-signal", G_CALLBACK (media_player_key_pressed), plugin, 0);

	/* re-grab keys when the main window gains focus */
	g_object_get (plugin->shell, "window", &window, NULL);
	g_signal_connect_object (window, "focus-in-event",
				 G_CALLBACK (window_focus_cb),
				 plugin, 0);
	g_object_unref (window);

	g_variant_unref (result);
}
コード例 #6
0
int S9xOpenGLDisplayDriver::query_availability ()
{
    GdkDisplay *gdk_display = gdk_display_get_default ();

#ifdef GDK_WINDOWING_WAYLAND
    if (GDK_IS_WAYLAND_DISPLAY (gdk_display))
    {
        return 1;
    }
#endif

#ifdef GDK_WINDOWING_X11
    if (GDK_IS_X11_DISPLAY (gdk_display))
    {
        Display *dpy = GDK_DISPLAY_XDISPLAY (gdk_display);

        if (glXQueryExtension (dpy, NULL, NULL) == True)
        {
           return 1;
        }
    }
#endif

    if (gui_config->hw_accel == HWA_OPENGL)
        gui_config->hw_accel = HWA_NONE;

    return 0;
}
コード例 #7
0
ファイル: totem-interface.c プロジェクト: UIKit0/totem
void
totem_interface_set_transient_for (GtkWindow *window, GtkWindow *parent)
{
#ifdef GDK_WINDOWING_X11
	GdkDisplay *display;

	display = gdk_display_get_default ();

	if (GDK_IS_X11_DISPLAY (display) &&
	    GTK_IS_PLUG (parent)) {
		GdkWindow *toplevel;

		gtk_widget_realize (GTK_WIDGET (window));
		toplevel = totem_gtk_plug_get_toplevel (GTK_PLUG (parent));
		if (toplevel != NULL) {
			gdk_window_set_transient_for
				(gtk_widget_get_window (GTK_WIDGET (window)), toplevel);
			g_object_unref (toplevel);
		}
		return;
	}
#endif /* GDK_WINDOWING_X11 */

	gtk_window_set_transient_for (GTK_WINDOW (window),
				      GTK_WINDOW (parent));
}
コード例 #8
0
ファイル: nsIdleServiceGTK.cpp プロジェクト: LordJZ/gecko-dev
static void Initialize()
{
    if (!GDK_IS_X11_DISPLAY(gdk_display_get_default()))
        return;

    // This will leak - See comments in ~nsIdleServiceGTK().
    PRLibrary* xsslib = PR_LoadLibrary("libXss.so.1");
    if (!xsslib) // ouch.
    {
#ifdef PR_LOGGING
        PR_LOG(sIdleLog, PR_LOG_WARNING, ("Failed to find libXss.so!\n"));
#endif
        return;
    }

    _XSSQueryExtension = (_XScreenSaverQueryExtension_fn)
        PR_FindFunctionSymbol(xsslib, "XScreenSaverQueryExtension");
    _XSSAllocInfo = (_XScreenSaverAllocInfo_fn)
        PR_FindFunctionSymbol(xsslib, "XScreenSaverAllocInfo");
    _XSSQueryInfo = (_XScreenSaverQueryInfo_fn)
        PR_FindFunctionSymbol(xsslib, "XScreenSaverQueryInfo");
#ifdef PR_LOGGING
    if (!_XSSQueryExtension)
        PR_LOG(sIdleLog, PR_LOG_WARNING, ("Failed to get XSSQueryExtension!\n"));
    if (!_XSSAllocInfo)
        PR_LOG(sIdleLog, PR_LOG_WARNING, ("Failed to get XSSAllocInfo!\n"));
    if (!_XSSQueryInfo)
        PR_LOG(sIdleLog, PR_LOG_WARNING, ("Failed to get XSSQueryInfo!\n"));
#endif

    sInitialized = true;
}
コード例 #9
0
ファイル: gtkmisc.c プロジェクト: Riatre/PuTTY
Display *get_x11_display(void)
{
#if GTK_CHECK_VERSION(3,0,0)
    if (!GDK_IS_X11_DISPLAY(gdk_display_get_default()))
        return NULL;
#endif
    return GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
}
コード例 #10
0
static PassOwnPtr<WidgetBackingStore> createBackingStore(GtkWidget* widget, const IntSize& size)
{
#ifdef GDK_WINDOWING_X11
    GdkDisplay* display = gdk_display_manager_get_default_display(gdk_display_manager_get());
    if (GDK_IS_X11_DISPLAY(display))
        return WebCore::WidgetBackingStoreGtkX11::create(widget, size);
#endif
    return WebCore::WidgetBackingStoreCairo::create(widget, size);
}
コード例 #11
0
static OwnPtr<WidgetBackingStore> createBackingStoreForGTK(GtkWidget* widget, const IntSize& size, float deviceScaleFactor)
{
#if PLATFORM(X11) && defined(GDK_WINDOWING_X11)
    GdkDisplay* display = gdk_display_manager_get_default_display(gdk_display_manager_get());
    if (GDK_IS_X11_DISPLAY(display))
        return WebCore::WidgetBackingStoreGtkX11::create(widget, size, deviceScaleFactor);
#endif
    return WebCore::WidgetBackingStoreCairo::create(widget, size, deviceScaleFactor);
}
コード例 #12
0
static guint32 get_keyboard_lock_modifiers(void)
{
    guint32 modifiers = 0;
#if GTK_CHECK_VERSION(3,18,0)
    GdkKeymap *keyboard = gdk_keymap_get_default();

    if (gdk_keymap_get_caps_lock_state(keyboard)) {
        modifiers |= SPICE_INPUTS_CAPS_LOCK;
    }

    if (gdk_keymap_get_num_lock_state(keyboard)) {
        modifiers |= SPICE_INPUTS_NUM_LOCK;
    }

    if (gdk_keymap_get_scroll_lock_state(keyboard)) {
        modifiers |= SPICE_INPUTS_SCROLL_LOCK;
    }
#else
#if HAVE_X11_XKBLIB_H
    Display *x_display = NULL;
    XKeyboardState keyboard_state;

    GdkScreen *screen = gdk_screen_get_default();
    if (!GDK_IS_X11_DISPLAY(gdk_screen_get_display(screen))) {
        SPICE_DEBUG("FIXME: gtk backend is not X11");
        return 0;
    }

    x_display = GDK_SCREEN_XDISPLAY(screen);
    XGetKeyboardControl(x_display, &keyboard_state);

    if (keyboard_state.led_mask & 0x01) {
        modifiers |= SPICE_INPUTS_CAPS_LOCK;
    }
    if (keyboard_state.led_mask & 0x02) {
        modifiers |= SPICE_INPUTS_NUM_LOCK;
    }
    if (keyboard_state.led_mask & 0x04) {
        modifiers |= SPICE_INPUTS_SCROLL_LOCK;
    }
#elif defined(G_OS_WIN32)
    if (GetKeyState(VK_CAPITAL) & 1) {
        modifiers |= SPICE_INPUTS_CAPS_LOCK;
    }
    if (GetKeyState(VK_NUMLOCK) & 1) {
        modifiers |= SPICE_INPUTS_NUM_LOCK;
    }
    if (GetKeyState(VK_SCROLL) & 1) {
        modifiers |= SPICE_INPUTS_SCROLL_LOCK;
    }
#else
    g_warning("get_keyboard_lock_modifiers not implemented");
#endif // HAVE_X11_XKBLIB_H
#endif // GTK_CHECK_VERSION(3,18,0)
    return modifiers;
}
コード例 #13
0
ファイル: main.c プロジェクト: gnarula/gnome-mpv
static gboolean get_use_opengl(void)
{
#ifdef GDK_WINDOWING_X11
	/* TODO: Add option to use opengl on X11 */
	return !GDK_IS_X11_DISPLAY(gdk_display_get_default());
#else
	/* In theory this can work on any backend supporting GtkGLArea */
	return TRUE;
#endif
}
コード例 #14
0
ファイル: empathy-avatar-image.c プロジェクト: GNOME/empathy
static gboolean
running_in_x11 (void)
{
	GdkDisplay *display;

	display = gdk_display_get_default ();
	if (!display)
		return FALSE;

	return GDK_IS_X11_DISPLAY (display);
}
コード例 #15
0
ファイル: gedit-utils.c プロジェクト: daniel94/gedit
/**
 * gedit_utils_get_current_viewport:
 * @screen: a #GdkScreen
 * @x: (out): x-axis point.
 * @y: (out): y-axis point.
 *
 * Get the currently visible viewport origin for the #GdkScreen.
 *
 * If the X11 window property isn't found, (0, 0) is returned.
 */
void
gedit_utils_get_current_viewport (GdkScreen    *screen,
				  gint         *x,
				  gint         *y)
{
#ifdef GDK_WINDOWING_X11
	GdkWindow *root_win;
	GdkDisplay *display;
	Atom type;
	gint format;
	gulong nitems;
	gulong bytes_after;
	gulong *coordinates;
	gint err, result;

	g_return_if_fail (GDK_IS_SCREEN (screen));
	g_return_if_fail (x != NULL && y != NULL);

	/* Default values for the viewport origin */
	*x = 0;
	*y = 0;

	root_win = gdk_screen_get_root_window (screen);
	display = gdk_screen_get_display (screen);

	if (GDK_IS_X11_DISPLAY (display))
	{
		gdk_error_trap_push ();
		result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (root_win),
					     gdk_x11_get_xatom_by_name_for_display (display, "_NET_DESKTOP_VIEWPORT"),
					     0, G_MAXLONG, False, XA_CARDINAL, &type, &format, &nitems,
					     &bytes_after, (void*) &coordinates);
		err = gdk_error_trap_pop ();

		if (err != Success || result != Success)
			return;

		if (type != XA_CARDINAL || format != 32 || nitems < 2)
		{
			XFree (coordinates);
			return;
		}

		*x = coordinates[0];
		*y = coordinates[1];
		XFree (coordinates);
	}
#else
	/* FIXME: on mac etc proably there are native APIs
	 * to get the current workspace etc */
	*x = 0;
	*y = 0;
#endif
}
コード例 #16
0
static void
impl_activate (PeasActivatable *pplugin)
{
	GDBusConnection *bus;
	RBMMKeysPlugin *plugin;
	GError *error = NULL;

	rb_debug ("activating media player keys plugin");

	plugin = RB_MMKEYS_PLUGIN (pplugin);
	g_object_get (plugin, "object", &plugin->shell, NULL);
	g_object_get (plugin->shell, "shell-player", &plugin->shell_player, NULL);

	bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
	if (plugin->grab_type == NONE && bus != NULL) {
		GError *error = NULL;

		plugin->proxy = g_dbus_proxy_new_sync (bus,
						       G_DBUS_PROXY_FLAGS_NONE,
						       NULL,
						       "org.gnome.SettingsDaemon",
						       "/org/gnome/SettingsDaemon/MediaKeys",
						       "org.gnome.SettingsDaemon.MediaKeys",
						       NULL,
						       &error);
		if (error != NULL) {
			g_warning ("Unable to grab media player keys: %s", error->message);
			g_clear_error (&error);
		} else {
			g_dbus_proxy_call (plugin->proxy,
					   "GrabMediaPlayerKeys",
					   g_variant_new ("(su)", "Rhythmbox", 0),
					   G_DBUS_CALL_FLAGS_NONE,
					   -1,
					   NULL,
					   (GAsyncReadyCallback) first_call_complete,
					   plugin);
			plugin->grab_type = SETTINGS_DAEMON;
		}
	} else {
		g_warning ("couldn't get dbus session bus: %s", error->message);
		g_clear_error (&error);
	}

#ifdef HAVE_MMKEYS
	if (plugin->grab_type == NONE && GDK_IS_X11_DISPLAY (gdk_display_get_default ())) {
		rb_debug ("attempting old-style key grabs");
		mmkeys_grab (plugin, TRUE);
		plugin->grab_type = X_KEY_GRAB;
	}
#endif
}
コード例 #17
0
Display *
_wnck_get_default_display (void)
{
  GdkDisplay *display = gdk_display_get_default ();
  /* FIXME: when we fix libwnck to not use the GDK default display, we will
   * need to fix wnckprop accordingly. */
  if (!GDK_IS_X11_DISPLAY (display))
    {
      g_warning ("libwnck is designed to work in X11 only, no valid display found");
      return NULL;
    }

  return GDK_DISPLAY_XDISPLAY (display);
}
コード例 #18
0
ファイル: gmpv_mpv_obj.c プロジェクト: warmsun0220/gnome-mpv
static void *GLAPIENTRY glMPGetNativeDisplay(const gchar *name)
{
       GdkDisplay *display = gdk_display_get_default();

#ifdef GDK_WINDOWING_WAYLAND
       if(GDK_IS_WAYLAND_DISPLAY(display) && g_strcmp0(name, "wl") == 0)
               return gdk_wayland_display_get_wl_display(display);
#endif
#ifdef GDK_WINDOWING_X11
       if(GDK_IS_X11_DISPLAY(display) && g_strcmp0(name, "x11") == 0)
               return gdk_x11_display_get_xdisplay(display);
#endif

       return NULL;
}
コード例 #19
0
ファイル: gt-player-mpv.c プロジェクト: ElJava/gnome-twitch
static void*
get_proc_address(void* ctx, const gchar* name)
{
    GdkDisplay* display = gdk_display_get_default();

    #ifdef GDK_WINDOWING_WAYLAND
    if (GDK_IS_WAYLAND_DISPLAY(display))
        return eglGetProcAddress(name);
    #endif
    #ifdef GDK_WINDOWING_X11
    if (GDK_IS_X11_DISPLAY(display))
        return (void*)(intptr_t) glXGetProcAddressARB((const GLubyte*) name);
    #endif

    g_return_val_if_reached(NULL);
}
コード例 #20
0
ファイル: gedit-utils.c プロジェクト: daniel94/gedit
/**
 * gedit_utils_get_window_workspace:
 *
 * Get the workspace the window is on
 *
 * This function gets the workspace that the #GtkWindow is visible on,
 * it returns GEDIT_ALL_WORKSPACES if the window is sticky, or if
 * the window manager doesn support this function
 */
guint
gedit_utils_get_window_workspace (GtkWindow *gtkwindow)
{
#ifdef GDK_WINDOWING_X11
	GdkWindow *window;
	GdkDisplay *display;
	Atom type;
	gint format;
	gulong nitems;
	gulong bytes_after;
	guint *workspace;
	gint err, result;
	guint ret = GEDIT_ALL_WORKSPACES;

	g_return_val_if_fail (GTK_IS_WINDOW (gtkwindow), 0);
	g_return_val_if_fail (gtk_widget_get_realized (GTK_WIDGET (gtkwindow)), 0);

	window = gtk_widget_get_window (GTK_WIDGET (gtkwindow));
	display = gdk_window_get_display (window);

	if (GDK_IS_X11_DISPLAY (display))
	{
		gdk_error_trap_push ();
		result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
					     gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP"),
					     0, G_MAXLONG, False, XA_CARDINAL, &type, &format, &nitems,
					     &bytes_after, (gpointer) &workspace);
		err = gdk_error_trap_pop ();

		if (err != Success || result != Success)
			return ret;

		if (type == XA_CARDINAL && format == 32 && nitems > 0)
			ret = workspace[0];

		XFree (workspace);
	}

	return ret;
#else
	/* FIXME: on mac etc proably there are native APIs
	 * to get the current workspace etc */
	return 0;
#endif
}
コード例 #21
0
ファイル: gedit-utils.c プロジェクト: daniel94/gedit
/**
 * gedit_utils_get_current_workspace:
 * @screen: a #GdkScreen
 *
 * Get the currently visible workspace for the #GdkScreen.
 *
 * If the X11 window property isn't found, 0 (the first workspace)
 * is returned.
 */
guint
gedit_utils_get_current_workspace (GdkScreen *screen)
{
#ifdef GDK_WINDOWING_X11
	GdkWindow *root_win;
	GdkDisplay *display;
	guint ret = 0;

	g_return_val_if_fail (GDK_IS_SCREEN (screen), 0);

	root_win = gdk_screen_get_root_window (screen);
	display = gdk_screen_get_display (screen);

	if (GDK_IS_X11_DISPLAY (display))
	{
		Atom type;
		gint format;
		gulong nitems;
		gulong bytes_after;
		guint *current_desktop;
		gint err, result;

		gdk_error_trap_push ();
		result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (root_win),
					     gdk_x11_get_xatom_by_name_for_display (display, "_NET_CURRENT_DESKTOP"),
					     0, G_MAXLONG, False, XA_CARDINAL, &type, &format, &nitems,
					     &bytes_after, (gpointer) &current_desktop);
		err = gdk_error_trap_pop ();

		if (err != Success || result != Success)
			return ret;

		if (type == XA_CARDINAL && format == 32 && nitems > 0)
			ret = current_desktop[0];

		XFree (current_desktop);
	}

	return ret;
#else
	/* FIXME: on mac etc proably there are native APIs
	 * to get the current workspace etc */
	return 0;
#endif
}
コード例 #22
0
static gboolean
_clutter_backend_gdk_post_parse (ClutterBackend  *backend,
                                 GError         **error)
{
  ClutterBackendGdk *backend_gdk = CLUTTER_BACKEND_GDK (backend);

  if (_foreign_dpy != NULL)
    backend_gdk->display = _foreign_dpy;

  /* Init Gdk, if outside code did not already */
  if (!gdk_init_check (NULL, NULL))
    return FALSE;

  /*
   * Only open connection if not already set by prior call to
   * clutter_gdk_set_display()
   */
  if (backend_gdk->display == NULL)
    backend_gdk->display = g_object_ref (gdk_display_get_default ());

  g_assert (backend_gdk->display != NULL);

#ifdef GDK_WINDOWING_X11
  if (GDK_IS_X11_DISPLAY (backend_gdk->display))
    {
      /* Cogl needs to know the Xlib display connection for
	 CoglTexturePixmapX11 */
      cogl_xlib_set_display (gdk_x11_display_get_xdisplay (backend_gdk->display));
    }
#endif

  backend_gdk->screen = gdk_display_get_default_screen (backend_gdk->display);

  /* add event filter for Cogl events */
  gdk_window_add_filter (NULL, cogl_gdk_filter, NULL);

  clutter_backend_gdk_init_settings (backend_gdk);

  CLUTTER_NOTE (BACKEND,
                "Gdk Display '%s' opened",
                gdk_display_get_name (backend_gdk->display));

  return TRUE;
}
コード例 #23
0
ファイル: PlatformDisplay.cpp プロジェクト: eocanha/webkit
std::unique_ptr<PlatformDisplay> PlatformDisplay::createPlatformDisplay()
{
#if PLATFORM(GTK)
#if defined(GTK_API_VERSION_2)
    return std::make_unique<PlatformDisplayX11>(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()));
#else
    GdkDisplay* display = gdk_display_manager_get_default_display(gdk_display_manager_get());
#if PLATFORM(X11)
    if (GDK_IS_X11_DISPLAY(display))
        return std::make_unique<PlatformDisplayX11>(GDK_DISPLAY_XDISPLAY(display));
#endif
#if PLATFORM(WAYLAND)
    if (GDK_IS_WAYLAND_DISPLAY(display))
        return std::make_unique<PlatformDisplayWayland>(gdk_wayland_display_get_wl_display(display));
#endif
#endif
#elif PLATFORM(EFL) && defined(HAVE_ECORE_X)
    return std::make_unique<PlatformDisplayX11>(static_cast<Display*>(ecore_x_display_get()));
#elif PLATFORM(WIN)
    return std::make_unique<PlatformDisplayWin>();
#endif

#if PLATFORM(WAYLAND)
    if (auto platformDisplay = PlatformDisplayWayland::create())
        return platformDisplay;
#endif

#if PLATFORM(X11)
    if (auto platformDisplay = PlatformDisplayX11::create())
        return platformDisplay;
#endif

    // If at this point we still don't have a display, just create a fake display with no native.
#if PLATFORM(WAYLAND)
    return std::make_unique<PlatformDisplayWayland>(nullptr);
#endif
#if PLATFORM(X11)
    return std::make_unique<PlatformDisplayX11>(nullptr);
#endif

    ASSERT_NOT_REACHED();
    return nullptr;
}
コード例 #24
0
void
gdk_x11_window_force_focus (GdkWindow *window,
                            guint32    timestamp)
{
    GdkDisplay *display;

    g_return_if_fail (GDK_IS_WINDOW (window));

    display = GDK_WINDOW_DISPLAY (window);

    if (GTK_CHECK_VERSION(3,0,0) && !GDK_IS_X11_DISPLAY (display))
        return;

    if (gdk_x11_screen_supports_net_wm_hint (gdk_window_get_screen (window),
                        gdk_atom_intern_static_string ("_NET_ACTIVE_WINDOW")))
    {
        if (!timestamp)
        {
            GTimeVal t;
            g_get_current_time (&t);
            timestamp = t.tv_sec;
        }

        XClientMessageEvent xclient;

        memset (&xclient, 0, sizeof (xclient));
        xclient.type = ClientMessage;
        xclient.window = GDK_WINDOW_XID (window);
        xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display,
                                                                    "_NET_ACTIVE_WINDOW");
        xclient.format = 32;
        xclient.data.l[0] = 2; /* requestor type; we're a tool */
        xclient.data.l[1] = timestamp;
        xclient.data.l[2] = None; /* currently active window */
        xclient.data.l[3] = 0;
        xclient.data.l[4] = 0;

        XSendEvent (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XROOTWIN (window), False,
                    SubstructureRedirectMask | SubstructureNotifyMask,
                    (XEvent *)&xclient);
    }
}
コード例 #25
0
ファイル: gmpv_mpv_obj.c プロジェクト: warmsun0220/gnome-mpv
static void *get_proc_address(void *fn_ctx, const gchar *name)
{
	GdkDisplay *display = gdk_display_get_default();

	if(g_strcmp0(name, "glMPGetNativeDisplay") == 0)
		return glMPGetNativeDisplay;

#ifdef GDK_WINDOWING_WAYLAND
	if (GDK_IS_WAYLAND_DISPLAY(display))
		return eglGetProcAddress(name);
#endif
#ifdef GDK_WINDOWING_X11
	if (GDK_IS_X11_DISPLAY(display))
		return	(void *)(intptr_t)
			glXGetProcAddressARB((const GLubyte *)name);
#endif
#ifdef GDK_WINDOWING_WIN32
	if (GDK_IS_WIN32_DISPLAY(display))
		return wglGetProcAddress(name);
#endif
	g_assert_not_reached();
}
コード例 #26
0
static CoglRenderer *
clutter_backend_gdk_get_renderer (ClutterBackend  *backend,
                                  GError         **error)
{
  ClutterBackendGdk *backend_gdk = CLUTTER_BACKEND_GDK (backend);
  CoglRenderer *renderer = cogl_renderer_new ();

#if defined(GDK_WINDOWING_X11) && defined(COGL_HAS_XLIB_SUPPORT)
  if (GDK_IS_X11_DISPLAY (backend_gdk->display))
    {
      Display *xdisplay = gdk_x11_display_get_xdisplay (backend_gdk->display);

      cogl_xlib_renderer_set_foreign_display (renderer, xdisplay);
    }
  else
#endif
#if defined(GDK_WINDOWING_WIN32)
  if (GDK_IS_WIN32_DISPLAY (backend_gdk->display))
    {
      /* Force a WGL winsys on windows */
      cogl_renderer_set_winsys_id (renderer, COGL_WINSYS_ID_WGL);
    }
  else
#endif
    {
      g_set_error (error, CLUTTER_INIT_ERROR,
                   CLUTTER_INIT_ERROR_BACKEND,
                   _("Could not find a suitable CoglWinsys for a GdkDisplay of type %s"),
                   G_OBJECT_TYPE_NAME (backend_gdk->display));
      cogl_object_unref (renderer);

      return NULL;
    }

  return renderer;
}
コード例 #27
0
ファイル: toplevel.cpp プロジェクト: raydtang/wxWidgets
bool wxGetFrameExtents(GdkWindow* window, int* left, int* right, int* top, int* bottom)
{
#ifdef GDK_WINDOWING_X11
    GdkDisplay* display = gdk_window_get_display(window);

    if (!GDK_IS_X11_DISPLAY(display))
        return false;

    static GdkAtom property = gdk_atom_intern("_NET_FRAME_EXTENTS", false);
    Atom xproperty = gdk_x11_atom_to_xatom_for_display(display, property);
    Atom type;
    int format;
    gulong nitems, bytes_after;
    guchar* data;
    Status status = XGetWindowProperty(
                        GDK_DISPLAY_XDISPLAY(display),
                        GDK_WINDOW_XID(window),
                        xproperty,
                        0, 4, false, XA_CARDINAL,
                        &type, &format, &nitems, &bytes_after, &data);
    const bool success = status == Success && data && nitems == 4;
    if (success)
    {
        long* p = (long*)data;
        if (left)   *left   = int(p[0]);
        if (right)  *right  = int(p[1]);
        if (top)    *top    = int(p[2]);
        if (bottom) *bottom = int(p[3]);
    }
    if (data)
        XFree(data);
    return success;
#else
    return false;
#endif
}
コード例 #28
0
// this function will make sure that everything has been initialized.
nsresult
nsScreenManagerGtk :: EnsureInit()
{
  if (mCachedScreenArray.Count() > 0)
    return NS_OK;

  mRootWindow = gdk_get_default_root_window();
  g_object_ref(mRootWindow);

  // GDK_STRUCTURE_MASK ==> StructureNotifyMask, for ConfigureNotify
  // GDK_PROPERTY_CHANGE_MASK ==> PropertyChangeMask, for PropertyNotify
  gdk_window_set_events(mRootWindow,
                        GdkEventMask(gdk_window_get_events(mRootWindow) |
                                     GDK_STRUCTURE_MASK |
                                     GDK_PROPERTY_CHANGE_MASK));
  gdk_window_add_filter(mRootWindow, root_window_event_filter, this);
#ifdef MOZ_X11
  if (GDK_IS_X11_DISPLAY(gdk_display_get_default()))
      mNetWorkareaAtom =
        XInternAtom(GDK_WINDOW_XDISPLAY(mRootWindow), "_NET_WORKAREA", False);
#endif

  return Init();
}
static gboolean
bacon_video_widget_gst_on_missing_plugins_event (BaconVideoWidget *bvw, char **details,
						 char **descriptions, gboolean playing,
						 gpointer user_data)
{
	GstInstallPluginsContext *install_ctx;
	TotemCodecInstallContext *ctx;
	GstInstallPluginsReturn status;
	guint i, num;
#ifdef GDK_WINDOWING_X11
	GdkDisplay *display;
#endif

	num = g_strv_length (details);
	g_return_val_if_fail (num > 0 && g_strv_length (descriptions) == num, FALSE);

	ctx = g_new0 (TotemCodecInstallContext, 1);
	ctx->descriptions = g_strdupv (descriptions);
	ctx->details = g_strdupv (details);
	ctx->playing = playing;
	ctx->bvw = bvw;

	for (i = 0; i < num; ++i)
	{
		if (bacon_video_widget_gst_codec_install_plugin_is_blacklisted (ctx->details[i]))
		{
			g_message ("Missing plugin: %s (ignoring)", ctx->details[i]);
			g_free (ctx->details[i]);
			g_free (ctx->descriptions[i]);
			ctx->details[i] = ctx->details[num-1];
			ctx->descriptions[i] = ctx->descriptions[num-1];
			ctx->details[num-1] = NULL;
			ctx->descriptions[num-1] = NULL;
			--num;
			--i;
		} else {
			g_message ("Missing plugin: %s (%s)", ctx->details[i], ctx->descriptions[i]);
		}
	}

	if (num == 0)
	{
		g_message ("All missing plugins are blacklisted, doing nothing");
		bacon_video_widget_gst_codec_install_context_free (ctx);
		return FALSE;
	}

	install_ctx = gst_install_plugins_context_new ();

#ifdef GDK_WINDOWING_X11
	display = gdk_display_get_default ();

	if (GDK_IS_X11_DISPLAY (display) &&
	    gtk_widget_get_window (GTK_WIDGET (bvw)) != NULL &&
	    gtk_widget_get_realized (GTK_WIDGET (bvw)))
	{
		gulong xid = 0;

		xid = bacon_video_widget_gst_get_toplevel (GTK_WIDGET (bvw));
		gst_install_plugins_context_set_xid (install_ctx, xid);
	}
#endif /* GDK_WINDOWING_X11 */

	status = gst_install_plugins_async ((const char * const*) ctx->details, install_ctx,
	                                    on_plugin_installation_done,
	                                    ctx);

	gst_install_plugins_context_free (install_ctx);

	GST_INFO ("gst_install_plugins_async() result = %d", status);

	if (status != GST_INSTALL_PLUGINS_STARTED_OK)
	{
		if (status == GST_INSTALL_PLUGINS_HELPER_MISSING)
		{
			g_message ("Automatic missing codec installation not supported "
			           "(helper script missing)");
		} else {
			g_warning ("Failed to start codec installation: %s",
			           gst_install_plugins_return_get_name (status));
		}
		bacon_video_widget_gst_codec_install_context_free (ctx);
		return FALSE;
	}

	/* if we managed to start playing, pause playback, since some install
	 * wizard should now take over in a second anyway and the user might not
	 * be able to use totem's controls while the wizard is running */
	if (playing)
		bacon_video_widget_pause (bvw);

	return TRUE;
}
コード例 #30
0
ファイル: devilspie2.c プロジェクト: NioxOne/devilspie2
/**
 * Program main entry
 */
int main(int argc, char *argv[])
{
	static const GOptionEntry options[]={
		{ "debug",			'd',	0,	G_OPTION_ARG_NONE,		&debug,
			N_("Print debug info to stdout")},
		{ "emulate",		'e',	0,	G_OPTION_ARG_NONE,		&emulate,
			N_("Don't apply any rules, only emulate execution")},
		{ "folder",			'f',	0,	G_OPTION_ARG_STRING,		&script_folder,
			N_("Search for scripts in this folder"),N_("FOLDER")},
		{ "version",		'v',	0,	G_OPTION_ARG_NONE,		&show_version,
			N_("Show Devilspie2 version and quit")},
#ifdef HAVE_GTK3
		// libwnck Version Information is only availible if you have
		// libwnck 3.0 or later
		{ "wnck-version",	'w',	0,	G_OPTION_ARG_NONE,		&show_wnck_version,
			N_("Show libwnck version and quit")},
#endif
		{ NULL }
	};

	GError *error = NULL;
	GOptionContext *context;

	// Init gettext stuff
	setlocale(LC_ALL, "");

	bindtextdomain(PACKAGE, LOCALEDIR);
	bind_textdomain_codeset(PACKAGE, "");
	textdomain(PACKAGE);

	gdk_init(&argc, &argv);

	gchar *devilspie2_description =
		g_strdup_printf(_("apply rules on windows"));

	gchar *full_desc_string = g_strdup_printf("- %s", devilspie2_description);

	context=g_option_context_new(full_desc_string);
	g_option_context_add_main_entries(context,options,NULL);
	if (!g_option_context_parse(context, &argc, &argv, &error)) {
		g_print(_("option parsing failed: %s"), error->message);
		printf("\n");
		exit(EXIT_FAILURE);
	}

	g_free(full_desc_string);
	g_free(devilspie2_description);

	// if the folder is NULL, default to ~/.config/devilspie2/
	if (script_folder == NULL) {

		temp_folder = g_build_path(G_DIR_SEPARATOR_S,
										g_get_user_config_dir(),
										"devilspie2",
										NULL);

		// check if the folder does exist
		if (!g_file_test(temp_folder, G_FILE_TEST_IS_DIR)) {

			// - and if it doesn't, create it.
			if (g_mkdir(temp_folder, 0700) != 0) {
				printf("%s", _("Couldn't create the default folder for devilspie2 scripts."));
				printf("\n");
				exit(EXIT_FAILURE);
			}
		}

		script_folder = temp_folder;
	}

	if (show_version) {
		printf("Devilspie2 v%s\n\n", DEVILSPIE2_VERSION);
		exit(EXIT_SUCCESS);
	}
#ifdef HAVE_GTK3
	// libwnck Version Information is only availible if you have
	// libwnck 3.0 or later
	if (show_wnck_version) {
		printf("libwnck v%d.%d.%d\n\n",
		       WNCK_MAJOR_VERSION,
		       WNCK_MINOR_VERSION,
		       WNCK_MICRO_VERSION);
		exit(EXIT_SUCCESS);
	}
#endif

#if (GTK_MAJOR_VERSION >= 3)
	if (!GDK_IS_X11_DISPLAY(gdk_display_get_default())) {
		printf("%s", _("An X11 display is required for devilspie2."));
		printf("\n\n");
		return EXIT_FAILURE;
	}

#endif

	if (init_script_error_messages()!=0) {
		printf("%s", _("Couldn't init script error messages!"));
		printf("\n");
		exit(EXIT_FAILURE);
	}

	config_filename =
		g_build_filename(script_folder, "devilspie2.lua", NULL);

	if (load_config(config_filename)!=0) {

		devilspie_exit();
		return EXIT_FAILURE;
	}

	if (debug) {

		if (emulate) {
			printf("%s", _("Running devilspie2 in debug and emulate mode."));
		} else {
			printf("%s", _("Running devilspie2 in debug mode."));
		}

		printf("\n\n");

		printf(_("Using scripts from folder: %s"), script_folder);

		printf("\n");

		devilspie2_debug = TRUE;
	}

	// Should we only run an emulation (don't modify any windows)
	if (emulate) devilspie2_emulate = emulate;

	GFile *directory_file;
	directory_file = g_file_new_for_path(script_folder);
//	mon = g_file_monitor_directory(directory_file, G_FILE_MONITOR_WATCH_MOUNTS,
	mon = g_file_monitor_directory(directory_file, G_FILE_MONITOR_NONE,
												NULL, NULL);
	if (!mon) {
		printf("%s", _("Couldn't create directory monitor!"));
		printf("\n");
		return EXIT_FAILURE;
	}

	g_signal_connect(mon, "changed", G_CALLBACK(folder_changed_callback),
		(gpointer)(config_filename));

	global_lua_state = init_script();
	print_script_lists();

	if (debug) printf("------------\n");

	// remove stuff cleanly
	atexit(devilspie_exit);

	struct sigaction signal_action;

	sigemptyset(&signal_action.sa_mask);
	signal_action.sa_flags = 0;
	signal_action.sa_handler = signal_handler;

	if (sigaction(SIGINT, &signal_action, NULL) == -1) {
		exit(EXIT_FAILURE);
	}

	init_screens();

	loop=g_main_loop_new(NULL, TRUE);
	g_main_loop_run(loop);

	return EXIT_SUCCESS;
}