Exemple #1
0
static void
gtk_application_window_real_map (GtkWidget *widget)
{
    GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (widget);

    /* XXX could eliminate this by tweaking gtk_window_map */
    if (window->priv->menubar)
        gtk_widget_map (window->priv->menubar);

#ifdef GDK_WINDOWING_WAYLAND
    {
        GdkWindow *gdkwindow;
        GtkApplication *application;

        application = gtk_window_get_application (GTK_WINDOW (window));
        gdkwindow = gtk_widget_get_window (widget);

        if (GDK_IS_WAYLAND_WINDOW (gdkwindow) && window->priv->session)
        {
            gdk_wayland_window_set_dbus_properties_libgtk_only (gdkwindow,
                    g_application_get_application_id (G_APPLICATION (application)),
                    gtk_application_get_app_menu_object_path (application),
                    gtk_application_get_menubar_object_path (application),
                    window->priv->object_path,
                    g_application_get_dbus_object_path (G_APPLICATION (application)),
                    g_dbus_connection_get_unique_name (window->priv->session));
        }
    }
#endif

    GTK_WIDGET_CLASS (gtk_application_window_parent_class)->map (widget);
}
bool WaylandEGLContext::attach (GtkWidget *widget)
{
    GdkWindow *window = gtk_widget_get_window (widget);

    if (!GDK_IS_WAYLAND_WINDOW (window))
        return false;

    gdk_window = window;
    gdk_window_get_geometry (gdk_window, &x, &y, &width, &height);

    display  = gdk_wayland_display_get_wl_display (gdk_window_get_display (gdk_window));
    parent   = gdk_wayland_window_get_wl_surface (gdk_window);
    registry = wl_display_get_registry (display);

    wl_registry_add_listener (registry, &wl_registry_listener, this);
    wl_display_roundtrip (display);

    if (!compositor || !subcompositor)
        return false;

    child = wl_compositor_create_surface (compositor);
    region = wl_compositor_create_region (compositor);
    subsurface = wl_subcompositor_get_subsurface (subcompositor, child, parent);

    wl_surface_set_input_region (child, region);
    wl_subsurface_set_desync (subsurface);
    wl_subsurface_set_position (subsurface, x, y);

    return true;
}
static const struct backend_callbacks *
get_backend_callbacks(GdkWindow *window)
{
#if defined(GDK_WINDOWING_WAYLAND) && defined(COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT)
    if (GDK_IS_WAYLAND_WINDOW(window)) {
        static const struct backend_callbacks cbs =
            {
                COGL_WINSYS_ID_EGL_WAYLAND,
                wayland_init,
                noop_get_scale,
                wayland_set_window,
                wayland_resize,
            };
        return &cbs;
    }
#endif
#if defined(GDK_WINDOWING_X11) && defined(COGL_HAS_XLIB_SUPPORT)
    if (GDK_IS_X11_WINDOW(window)) {
        static const struct backend_callbacks cbs =
            {
              //COGL_WINSYS_ID_EGL_XLIB,
                COGL_WINSYS_ID_GLX,
                x11_init,
                x11_get_scale,
                x11_set_window,
                x11_resize,
            };
        return &cbs;
    }
#endif
#if defined(GDK_WINDOWING_WIN32) && defined(COGL_HAS_WIN32_SUPPORT)
    if (GDK_IS_WIN32_WINDOW(window)) {
        static const struct backend_callbacks cbs =
            {
                COGL_WINSYS_ID_WGL,
                noop_init,
                noop_get_scale,
                win32_set_window,
                noop_resize,
            };
        return &cbs;
    }
#endif

    static const struct backend_callbacks cbs =
    {
        COGL_WINSYS_ID_STUB,
        noop_init,
        noop_get_scale,
        noop_set_window,
        noop_resize,
    };
    return &cbs;
}
bool S9xOpenGLDisplayDriver::create_context()
{
    gdk_window = gtk_widget_get_window (drawing_area);

#ifdef GDK_WINDOWING_WAYLAND
    if (GDK_IS_WAYLAND_WINDOW (gdk_window))
    {
        context = &wl;
    }
#endif
#ifdef GDK_WINDOWING_X11
    if (GDK_IS_X11_WINDOW (gdk_window))
    {
        context = &glx;
    }
#endif

    if (!context->attach (drawing_area))
        return false;

    if (!context->create_context ())
        return false;

    output_window_width = context->width;
    output_window_height = context->height;

    context->make_current ();

    legacy = false;
    version = epoxy_gl_version ();
    if (version < 20)
    {
        printf ("OpenGL version is only %d.%d. Recommended version is 2.0.\n",
                version / 10,
                version % 10);
        legacy = true;
    }

    int profile_mask = 0;
    glGetIntegerv (GL_CONTEXT_PROFILE_MASK, &profile_mask);
    if (profile_mask & GL_CONTEXT_CORE_PROFILE_BIT)
        core = true;
    else
        core = false;

    return true;
}
Exemple #5
0
static gboolean
clutter_stage_gdk_realize (ClutterStageWindow *stage_window)
{
  ClutterStageGdk *stage_gdk = CLUTTER_STAGE_GDK (stage_window);
  ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_window);
  ClutterBackend *backend = CLUTTER_BACKEND (stage_cogl->backend);
  ClutterBackendGdk *backend_gdk = CLUTTER_BACKEND_GDK (backend);
  GdkWindowAttr attributes;
  gboolean cursor_visible;
  gboolean use_alpha;
  gfloat   width, height;

  if (stage_gdk->foreign_window)
    {
      width = gdk_window_get_width (stage_gdk->window);
      height = gdk_window_get_height (stage_gdk->window);
    }
  else
    {
      if (stage_gdk->window != NULL)
        {
          /* complete realizing the stage */
          cairo_rectangle_int_t geometry;

          clutter_stage_gdk_get_geometry (stage_window, &geometry);
          clutter_actor_set_size (CLUTTER_ACTOR (stage_cogl->wrapper),
                                  geometry.width,
                                  geometry.height);

          gdk_window_ensure_native (stage_gdk->window);
          gdk_window_set_events (stage_gdk->window, CLUTTER_STAGE_GDK_EVENT_MASK);

          return TRUE;
        }
      else
        {
          attributes.title = NULL;
          g_object_get (stage_cogl->wrapper,
                        "cursor-visible", &cursor_visible,
                        "title", &attributes.title,
                        "width", &width,
                        "height", &height,
                        "use-alpha", &use_alpha,
                        NULL);

          attributes.width = width;
          attributes.height = height;
          attributes.wclass = GDK_INPUT_OUTPUT;
          attributes.window_type = GDK_WINDOW_TOPLEVEL;
          attributes.event_mask = CLUTTER_STAGE_GDK_EVENT_MASK;

          attributes.cursor = NULL;
          if (!cursor_visible)
            {
              if (stage_gdk->blank_cursor == NULL)
                stage_gdk->blank_cursor = gdk_cursor_new_for_display (backend_gdk->display, GDK_BLANK_CURSOR);

              attributes.cursor = stage_gdk->blank_cursor;
            }

          attributes.visual = NULL;
          if (use_alpha)
            {
              attributes.visual = gdk_screen_get_rgba_visual (backend_gdk->screen);

              if (attributes.visual == NULL)
                clutter_stage_set_use_alpha (stage_cogl->wrapper, FALSE);
            }

          if (attributes.visual == NULL)
            {
             /* This could still be an RGBA visual, although normally it's not */
             attributes.visual = gdk_screen_get_system_visual (backend_gdk->screen);
            }

          stage_gdk->foreign_window = FALSE;
          stage_gdk->window = gdk_window_new (NULL, &attributes,
                                              GDK_WA_TITLE | GDK_WA_CURSOR | GDK_WA_VISUAL);

          g_free (attributes.title);
        }

      clutter_stage_gdk_set_gdk_geometry (stage_gdk);
    }

  gdk_window_ensure_native (stage_gdk->window);

  g_object_set_data (G_OBJECT (stage_gdk->window),
                     "clutter-stage-window", stage_gdk);

  stage_cogl->onscreen = cogl_onscreen_new (backend->cogl_context,
					    width, height);

#if defined(GDK_WINDOWING_X11) && defined(COGL_HAS_XLIB_SUPPORT)
  if (GDK_IS_X11_WINDOW (stage_gdk->window))
    {
      cogl_x11_onscreen_set_foreign_window_xid (stage_cogl->onscreen,
                                                GDK_WINDOW_XID (stage_gdk->window),
                                                clutter_stage_gdk_update_foreign_event_mask,
                                                stage_gdk);
    }
  else
#endif
#if defined(GDK_WINDOWING_WAYLAND) && defined(COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT)
  if (GDK_IS_WAYLAND_WINDOW (stage_gdk->window))
    {
      cogl_wayland_onscreen_set_foreign_surface (stage_cogl->onscreen,
                                                 gdk_wayland_window_get_wl_surface (stage_gdk->window));
    }
  else
#endif
#if defined(GDK_WINDOWING_WIN32) && defined(COGL_HAS_WIN32_SUPPORT)
  if (GDK_IS_WIN32_WINDOW (stage_gdk->window))
    {
      cogl_win32_onscreen_set_foreign_window (stage_cogl->onscreen,
					      gdk_win32_window_get_handle (stage_gdk->window));
    }
  else
#endif
    {
      g_warning ("Cannot find an appropriate CoglWinsys for a "
		 "GdkWindow of type %s", G_OBJECT_TYPE_NAME (stage_gdk->window));

      cogl_object_unref (stage_cogl->onscreen);
      stage_cogl->onscreen = NULL;

      if (!stage_gdk->foreign_window)
        gdk_window_destroy (stage_gdk->window);

      stage_gdk->window = NULL;

      return FALSE;
    }

  return clutter_stage_window_parent_iface->realize (stage_window);
}
Exemple #6
0
const guint16 const *vnc_display_keymap_gdk2xtkbd_table(GdkWindow *window,
                                                        size_t *maplen)
{
#ifdef GDK_WINDOWING_X11
	if (GDK_IS_X11_WINDOW(window)) {
		XkbDescPtr desc;
		const gchar *keycodes = NULL;
                GdkDisplay *dpy = gdk_window_get_display(window);

		/* There is no easy way to determine what X11 server
		 * and platform & keyboard driver is in use. Thus we
		 * do best guess heuristics.
		 *
		 * This will need more work for people with other
		 * X servers..... patches welcomed.
		 */

		desc = XkbGetKeyboard(gdk_x11_display_get_xdisplay(dpy),
				      XkbGBN_AllComponentsMask,
				      XkbUseCoreKbd);
		if (desc) {
			if (desc->names) {
				keycodes = gdk_x11_get_xatom_name(desc->names->keycodes);
				if (!keycodes)
					g_warning("could not lookup keycode name");
			}
			XkbFreeKeyboard(desc, XkbGBN_AllComponentsMask, True);
		}

		if (check_for_xwin(dpy)) {
			VNC_DEBUG("Using xwin keycode mapping");
			*maplen = G_N_ELEMENTS(keymap_xorgxwin2xtkbd);
			return keymap_xorgxwin2xtkbd;
		} else if (check_for_xquartz(dpy)) {
			VNC_DEBUG("Using xquartz keycode mapping");
			*maplen = G_N_ELEMENTS(keymap_xorgxquartz2xtkbd);
			return keymap_xorgxquartz2xtkbd;
		} else if (keycodes && STRPREFIX(keycodes, "evdev_")) {
			VNC_DEBUG("Using evdev keycode mapping");
			*maplen = G_N_ELEMENTS(keymap_xorgevdev2xtkbd);
			return keymap_xorgevdev2xtkbd;
		} else if (keycodes && STRPREFIX(keycodes, "xfree86_")) {
			VNC_DEBUG("Using xfree86 keycode mapping");
			*maplen = G_N_ELEMENTS(keymap_xorgkbd2xtkbd);
			return keymap_xorgkbd2xtkbd;
		} else {
			g_warning("Unknown keycode mapping '%s'.\n"
				  "Please report to [email protected]\n"
				  "including the following information:\n"
				  "\n"
				  "  - Operating system\n"
				  "  - GDK build\n"
				  "  - X11 Server\n"
				  "  - xprop -root\n"
				  "  - xdpyinfo\n",
				  keycodes);
			return NULL;
		}
	}
#endif

#ifdef GDK_WINDOWING_WIN32
	if (GDK_IS_WIN32_WINDOW(window)) {
		VNC_DEBUG("Using Win32 virtual keycode mapping");
		*maplen = G_N_ELEMENTS(keymap_win322xtkbd);
		return keymap_win322xtkbd;
	}
#endif

#ifdef GDK_WINDOWING_QUARTZ
	if (GDK_IS_QUARTZ_WINDOW(window)) {
		VNC_DEBUG("Using OS-X virtual keycode mapping");
		*maplen = G_N_ELEMENTS(keymap_osx2xtkbd);
		return keymap_osx2xtkbd;
	}
#endif

#ifdef GDK_WINDOWING_WAYLAND
	if (GDK_IS_WAYLAND_WINDOW(window)) {
		VNC_DEBUG("Using Wayland Xorg/evdev virtual keycode mapping");
		*maplen = G_N_ELEMENTS(keymap_xorgevdev2xtkbd);
		return keymap_xorgevdev2xtkbd;
        }
#endif

#ifdef GDK_WINDOWING_BROADWAY
	if (GDK_IS_BROADWAY_WINDOW(window)) {
                g_warning("experimental: using broadway, x11 virtual keysym mapping - with very limited support. See also https://bugzilla.gnome.org/show_bug.cgi?id=700105");

			*maplen = G_N_ELEMENTS(keymap_x112xtkbd);
			return keymap_x112xtkbd;
        }
#endif

	g_warning("Unsupported GDK Windowing platform.\n"
		  "Disabling extended keycode tables.\n"
		  "Please report to [email protected]\n"
		  "including the following information:\n"
		  "\n"
		  "  - Operating system\n"
		  "  - GDK Windowing system build\n");
	return NULL;
}