Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
/* Clutter.
|
|
|
|
* An OpenGL based 'interactive canvas' library.
|
|
|
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
|
|
|
* Copyright (C) 2006-2007 OpenedHand
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
2011-08-26 22:16:12 +00:00
|
|
|
#include <cogl/cogl.h>
|
2014-12-03 12:07:06 +00:00
|
|
|
|
gdk: Use the Cogl visual on Xlib winsys
GDK 3.16 started selecting different visuals, to best comply with the
requirements for OpenGL, and this has broken Clutter on GLX drivers that
are fairly picky in how they select visuals and GLXFBConfig.
GDK selects GLXFBConfig that do not include depth or stencil buffers;
Cogl, on the other hand, needs both depth and stencil buffers, and keeps
selecting the first available visual, assuming that the GLX driver will
give us the best compliant one, as per specification. Sadly, some
drivers will return incompatible configurations, and then bomb out when
you try to embed Clutter inside GTK+, because of mismatched visuals.
Cogl has an old, deprecated, Clutter-only API that allows us to retrieve
the XVisualInfo mapping to the GLXFBConfig it uses; this means we should
look up the GdkVisual for it when creating our own GdkWindows, instead
of relying on the RGBA and system GdkVisuals exposed by GDK — at least
on X11.
https://bugzilla.gnome.org/show_bug.cgi?id=747489
2015-06-10 10:55:50 +00:00
|
|
|
#ifdef COGL_HAS_XLIB_SUPPORT
|
|
|
|
#include <cogl/cogl-xlib.h>
|
|
|
|
#endif
|
|
|
|
|
2014-12-03 12:07:06 +00:00
|
|
|
#define GDK_DISABLE_DEPRECATION_WARNINGS
|
|
|
|
|
2011-08-26 22:16:12 +00:00
|
|
|
#include <gdk/gdk.h>
|
|
|
|
#ifdef GDK_WINDOWING_X11
|
|
|
|
#include <gdk/gdkx.h>
|
|
|
|
#endif
|
2014-08-16 19:35:54 +00:00
|
|
|
#ifdef GDK_WINDOWING_WAYLAND
|
|
|
|
#include <gdk/gdkwayland.h>
|
|
|
|
#endif
|
2011-08-26 22:16:12 +00:00
|
|
|
#ifdef GDK_WINDOWING_WIN32
|
|
|
|
#include <gdk/gdkwin32.h>
|
|
|
|
#endif
|
|
|
|
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
#include "clutter-backend-gdk.h"
|
|
|
|
#include "clutter-stage-gdk.h"
|
|
|
|
#include "clutter-gdk.h"
|
|
|
|
|
|
|
|
#include "clutter-actor-private.h"
|
|
|
|
#include "clutter-debug.h"
|
|
|
|
#include "clutter-device-manager-private.h"
|
|
|
|
#include "clutter-enum-types.h"
|
|
|
|
#include "clutter-event-translator.h"
|
|
|
|
#include "clutter-event-private.h"
|
|
|
|
#include "clutter-feature.h"
|
|
|
|
#include "clutter-main.h"
|
|
|
|
#include "clutter-paint-volume-private.h"
|
|
|
|
#include "clutter-private.h"
|
|
|
|
#include "clutter-stage-private.h"
|
|
|
|
|
|
|
|
static void clutter_stage_window_iface_init (ClutterStageWindowIface *iface);
|
|
|
|
|
2011-08-26 22:16:12 +00:00
|
|
|
static ClutterStageWindowIface *clutter_stage_window_parent_iface = NULL;
|
|
|
|
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
#define clutter_stage_gdk_get_type _clutter_stage_gdk_get_type
|
|
|
|
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (ClutterStageGdk,
|
|
|
|
clutter_stage_gdk,
|
2011-08-26 22:16:12 +00:00
|
|
|
CLUTTER_TYPE_STAGE_COGL,
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_STAGE_WINDOW,
|
|
|
|
clutter_stage_window_iface_init));
|
|
|
|
|
2015-05-29 09:13:03 +00:00
|
|
|
#if defined(GDK_WINDOWING_X11) && defined(COGL_HAS_XLIB_SUPPORT)
|
2011-08-26 22:16:12 +00:00
|
|
|
static void
|
|
|
|
clutter_stage_gdk_update_foreign_event_mask (CoglOnscreen *onscreen,
|
|
|
|
guint32 event_mask,
|
|
|
|
void *user_data)
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
{
|
|
|
|
ClutterStageGdk *stage_gdk = user_data;
|
|
|
|
|
|
|
|
/* we assume that a GDK event mask is bitwise compatible with X11
|
|
|
|
event masks */
|
|
|
|
gdk_window_set_events (stage_gdk->window, event_mask | CLUTTER_STAGE_GDK_EVENT_MASK);
|
|
|
|
}
|
2012-07-29 12:39:13 +00:00
|
|
|
#endif
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_stage_gdk_set_gdk_geometry (ClutterStageGdk *stage)
|
|
|
|
{
|
|
|
|
GdkGeometry geometry;
|
2011-08-26 22:16:12 +00:00
|
|
|
ClutterStage *wrapper = CLUTTER_STAGE_COGL (stage)->wrapper;
|
|
|
|
gboolean resize = clutter_stage_get_user_resizable (wrapper);
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
|
|
|
|
if (!resize)
|
|
|
|
{
|
|
|
|
geometry.min_width = geometry.max_width = gdk_window_get_width (stage->window);
|
|
|
|
geometry.min_height = geometry.max_height = gdk_window_get_height (stage->window);
|
|
|
|
|
|
|
|
gdk_window_set_geometry_hints (stage->window,
|
|
|
|
&geometry,
|
|
|
|
GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-08-26 22:16:12 +00:00
|
|
|
clutter_stage_get_minimum_size (wrapper,
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
(guint *)&geometry.min_width,
|
|
|
|
(guint *)&geometry.min_height);
|
|
|
|
|
|
|
|
gdk_window_set_geometry_hints (stage->window,
|
|
|
|
&geometry,
|
|
|
|
GDK_HINT_MIN_SIZE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-09-29 17:16:48 +00:00
|
|
|
clutter_stage_gdk_get_geometry (ClutterStageWindow *stage_window,
|
|
|
|
cairo_rectangle_int_t *geometry)
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
{
|
|
|
|
ClutterStageGdk *stage_gdk = CLUTTER_STAGE_GDK (stage_window);
|
|
|
|
|
2015-11-22 17:22:41 +00:00
|
|
|
geometry->x = geometry->y = 0;
|
|
|
|
|
|
|
|
if (stage_gdk->window != NULL)
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
{
|
2015-11-22 17:22:41 +00:00
|
|
|
geometry->width = gdk_window_get_width (stage_gdk->window);
|
|
|
|
geometry->height = gdk_window_get_height (stage_gdk->window);
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
}
|
|
|
|
else
|
2015-11-22 17:22:41 +00:00
|
|
|
{
|
|
|
|
geometry->width = 800;
|
|
|
|
geometry->height = 600;
|
|
|
|
}
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_stage_gdk_resize (ClutterStageWindow *stage_window,
|
|
|
|
gint width,
|
|
|
|
gint height)
|
|
|
|
{
|
|
|
|
ClutterStageGdk *stage_gdk = CLUTTER_STAGE_GDK (stage_window);
|
|
|
|
|
|
|
|
if (width == 0 || height == 0)
|
|
|
|
{
|
|
|
|
/* Should not happen, if this turns up we need to debug it and
|
|
|
|
* determine the cleanest way to fix.
|
|
|
|
*/
|
|
|
|
g_warning ("GDK stage not allowed to have 0 width or height");
|
|
|
|
width = 1;
|
|
|
|
height = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
CLUTTER_NOTE (BACKEND, "New size received: (%d, %d)", width, height);
|
|
|
|
|
2015-08-31 21:58:11 +00:00
|
|
|
/* No need to resize foreign windows, it should be handled by the
|
|
|
|
* embedding framework, but on wayland we might need to resize our
|
|
|
|
* own subsurface.
|
|
|
|
*/
|
|
|
|
if (!stage_gdk->foreign_window)
|
|
|
|
gdk_window_resize (stage_gdk->window, width, height);
|
|
|
|
#if defined(GDK_WINDOWING_WAYLAND)
|
|
|
|
else if (GDK_IS_WAYLAND_WINDOW (stage_gdk->window))
|
2015-11-22 17:22:41 +00:00
|
|
|
{
|
|
|
|
int scale = gdk_window_get_scale_factor (stage_gdk->window);
|
|
|
|
cogl_wayland_onscreen_resize (CLUTTER_STAGE_COGL (stage_gdk)->onscreen,
|
|
|
|
width * scale, height * scale, 0, 0);
|
|
|
|
}
|
2015-08-31 21:58:11 +00:00
|
|
|
#endif
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_stage_gdk_unrealize (ClutterStageWindow *stage_window)
|
|
|
|
{
|
|
|
|
ClutterStageGdk *stage_gdk = CLUTTER_STAGE_GDK (stage_window);
|
|
|
|
|
2011-08-26 22:16:12 +00:00
|
|
|
if (stage_gdk->window != NULL)
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
{
|
|
|
|
g_object_set_data (G_OBJECT (stage_gdk->window),
|
|
|
|
"clutter-stage-window", NULL);
|
2011-09-29 17:16:48 +00:00
|
|
|
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
if (stage_gdk->foreign_window)
|
2015-09-11 15:24:05 +00:00
|
|
|
{
|
|
|
|
ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_window);
|
|
|
|
|
|
|
|
g_object_unref (stage_gdk->window);
|
|
|
|
|
|
|
|
/* Clutter still uses part of the deprecated stateful API of
|
|
|
|
* Cogl (in particulart cogl_set_framebuffer). It means Cogl
|
|
|
|
* can keep an internal reference to the onscreen object we
|
|
|
|
* rendered to. In the case of foreign window, we want to
|
|
|
|
* avoid this, as we don't know what's going to happen to
|
|
|
|
* that window.
|
|
|
|
*
|
|
|
|
* The following call sets the current Cogl framebuffer to a
|
|
|
|
* dummy 1x1 one if we're unrealizing the current one, so
|
|
|
|
* Cogl doesn't keep any reference to the foreign window.
|
|
|
|
*/
|
|
|
|
if (cogl_get_draw_framebuffer () == COGL_FRAMEBUFFER (stage_cogl->onscreen))
|
2015-09-14 23:30:05 +00:00
|
|
|
_clutter_backend_reset_cogl_framebuffer (stage_cogl->backend);
|
2015-09-11 15:24:05 +00:00
|
|
|
}
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
else
|
|
|
|
gdk_window_destroy (stage_gdk->window);
|
2011-09-29 17:16:48 +00:00
|
|
|
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
stage_gdk->window = NULL;
|
|
|
|
}
|
2011-09-29 17:16:48 +00:00
|
|
|
|
2015-08-31 21:58:11 +00:00
|
|
|
clutter_stage_window_parent_iface->unrealize (stage_window);
|
|
|
|
|
|
|
|
#if defined(GDK_WINDOWING_WAYLAND)
|
|
|
|
g_clear_pointer (&stage_gdk->subsurface, wl_subsurface_destroy);
|
|
|
|
g_clear_pointer (&stage_gdk->clutter_surface, wl_surface_destroy);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(GDK_WINDOWING_WAYLAND)
|
|
|
|
static struct wl_surface *
|
|
|
|
clutter_stage_gdk_wayland_surface (ClutterStageGdk *stage_gdk)
|
|
|
|
{
|
|
|
|
GdkDisplay *display;
|
|
|
|
struct wl_compositor *compositor;
|
|
|
|
struct wl_surface *parent_surface;
|
|
|
|
struct wl_region *input_region;
|
|
|
|
gint x, y;
|
|
|
|
|
|
|
|
if (!stage_gdk->foreign_window ||
|
|
|
|
gdk_window_get_window_type (stage_gdk->window) != GDK_WINDOW_CHILD)
|
|
|
|
return gdk_wayland_window_get_wl_surface (stage_gdk->window);
|
|
|
|
|
|
|
|
if (stage_gdk->clutter_surface)
|
|
|
|
return stage_gdk->clutter_surface;
|
|
|
|
|
|
|
|
/* On Wayland if we render to a foreign window, we setup our own
|
|
|
|
* surface to not render in the same buffers as the embedding
|
|
|
|
* framework.
|
|
|
|
*/
|
|
|
|
display = gdk_display_get_default ();
|
|
|
|
compositor = gdk_wayland_display_get_wl_compositor (display);
|
|
|
|
stage_gdk->clutter_surface = wl_compositor_create_surface (compositor);
|
|
|
|
|
|
|
|
/* Since we run inside GDK, we can let the embedding framework
|
|
|
|
* dispatch the events to Clutter. For that to happen we need to
|
|
|
|
* disable input on our surface. */
|
|
|
|
input_region = wl_compositor_create_region (compositor);
|
|
|
|
wl_region_add (input_region, 0, 0, 0, 0);
|
|
|
|
wl_surface_set_input_region (stage_gdk->clutter_surface, input_region);
|
|
|
|
wl_region_destroy (input_region);
|
|
|
|
|
2015-11-22 17:22:41 +00:00
|
|
|
wl_surface_set_buffer_scale (stage_gdk->clutter_surface,
|
|
|
|
gdk_window_get_scale_factor (stage_gdk->window));
|
|
|
|
|
2015-08-31 21:58:11 +00:00
|
|
|
parent_surface = gdk_wayland_window_get_wl_surface (gdk_window_get_toplevel (stage_gdk->window));
|
|
|
|
stage_gdk->subsurface = wl_subcompositor_get_subsurface (stage_gdk->subcompositor,
|
|
|
|
stage_gdk->clutter_surface,
|
|
|
|
parent_surface);
|
|
|
|
|
|
|
|
gdk_window_get_origin (stage_gdk->window, &x, &y);
|
|
|
|
wl_subsurface_set_position (stage_gdk->subsurface, x, y);
|
|
|
|
wl_subsurface_set_desync (stage_gdk->subsurface);
|
|
|
|
|
|
|
|
return stage_gdk->clutter_surface;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void
|
|
|
|
_clutter_stage_gdk_notify_configure (ClutterStageGdk *stage_gdk,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint width,
|
|
|
|
gint height)
|
|
|
|
{
|
|
|
|
if (x < 0 || y < 0 || width < 1 || height < 1)
|
|
|
|
return;
|
2015-11-22 17:22:41 +00:00
|
|
|
|
2015-09-13 23:00:12 +00:00
|
|
|
if (stage_gdk->foreign_window)
|
2015-08-31 21:58:11 +00:00
|
|
|
{
|
2015-11-22 17:22:41 +00:00
|
|
|
ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_gdk);
|
|
|
|
int scale = gdk_window_get_scale_factor (stage_gdk->window);
|
|
|
|
|
2015-09-13 23:00:12 +00:00
|
|
|
#if defined(GDK_WINDOWING_WAYLAND)
|
|
|
|
if (GDK_IS_WAYLAND_WINDOW (stage_gdk->window) &&
|
|
|
|
gdk_window_get_window_type (stage_gdk->window) == GDK_WINDOW_CHILD &&
|
|
|
|
stage_gdk->subsurface)
|
|
|
|
{
|
|
|
|
gint rx, ry;
|
|
|
|
gdk_window_get_origin (stage_gdk->window, &rx, &ry);
|
|
|
|
wl_subsurface_set_position (stage_gdk->subsurface, rx, ry);
|
2015-11-22 17:22:41 +00:00
|
|
|
|
|
|
|
wl_surface_set_buffer_scale (stage_gdk->clutter_surface, scale);
|
|
|
|
cogl_wayland_onscreen_resize (stage_cogl->onscreen,
|
|
|
|
width * scale, height * scale, 0, 0);
|
2015-09-13 23:00:12 +00:00
|
|
|
}
|
|
|
|
else
|
2015-08-31 21:58:11 +00:00
|
|
|
#endif
|
2015-09-13 23:00:12 +00:00
|
|
|
#if defined(GDK_WINDOWING_X11)
|
|
|
|
if (GDK_IS_X11_WINDOW (stage_gdk->window))
|
|
|
|
{
|
|
|
|
ClutterBackend *backend = CLUTTER_BACKEND (stage_cogl->backend);
|
|
|
|
XConfigureEvent xevent = { ConfigureNotify };
|
|
|
|
xevent.window = GDK_WINDOW_XID (stage_gdk->window);
|
2015-11-22 17:22:41 +00:00
|
|
|
xevent.width = width * scale;
|
|
|
|
xevent.height = height * scale;
|
2015-09-13 23:00:12 +00:00
|
|
|
|
|
|
|
/* Ensure cogl knows about the new size immediately, as we will
|
|
|
|
* draw before we get the ConfigureNotify response. */
|
|
|
|
cogl_xlib_renderer_handle_event (backend->cogl_renderer, (XEvent *)&xevent);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
/* Currently we only support X11 and Wayland. */
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
}
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
clutter_stage_gdk_realize (ClutterStageWindow *stage_window)
|
|
|
|
{
|
|
|
|
ClutterStageGdk *stage_gdk = CLUTTER_STAGE_GDK (stage_window);
|
2011-08-26 22:16:12 +00:00
|
|
|
ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_window);
|
|
|
|
ClutterBackend *backend = CLUTTER_BACKEND (stage_cogl->backend);
|
|
|
|
ClutterBackendGdk *backend_gdk = CLUTTER_BACKEND_GDK (backend);
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
GdkWindowAttr attributes;
|
|
|
|
gboolean cursor_visible;
|
|
|
|
gboolean use_alpha;
|
gdk: Use the Cogl visual on Xlib winsys
GDK 3.16 started selecting different visuals, to best comply with the
requirements for OpenGL, and this has broken Clutter on GLX drivers that
are fairly picky in how they select visuals and GLXFBConfig.
GDK selects GLXFBConfig that do not include depth or stencil buffers;
Cogl, on the other hand, needs both depth and stencil buffers, and keeps
selecting the first available visual, assuming that the GLX driver will
give us the best compliant one, as per specification. Sadly, some
drivers will return incompatible configurations, and then bomb out when
you try to embed Clutter inside GTK+, because of mismatched visuals.
Cogl has an old, deprecated, Clutter-only API that allows us to retrieve
the XVisualInfo mapping to the GLXFBConfig it uses; this means we should
look up the GdkVisual for it when creating our own GdkWindows, instead
of relying on the RGBA and system GdkVisuals exposed by GDK — at least
on X11.
https://bugzilla.gnome.org/show_bug.cgi?id=747489
2015-06-10 10:55:50 +00:00
|
|
|
gfloat width, height;
|
2015-11-22 17:22:41 +00:00
|
|
|
int scale;
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
|
2015-03-02 16:08:18 +00:00
|
|
|
if (backend->cogl_context == NULL)
|
|
|
|
{
|
|
|
|
g_warning ("Missing Cogl context: was Clutter correctly initialized?");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
gdk: Use the Cogl visual on Xlib winsys
GDK 3.16 started selecting different visuals, to best comply with the
requirements for OpenGL, and this has broken Clutter on GLX drivers that
are fairly picky in how they select visuals and GLXFBConfig.
GDK selects GLXFBConfig that do not include depth or stencil buffers;
Cogl, on the other hand, needs both depth and stencil buffers, and keeps
selecting the first available visual, assuming that the GLX driver will
give us the best compliant one, as per specification. Sadly, some
drivers will return incompatible configurations, and then bomb out when
you try to embed Clutter inside GTK+, because of mismatched visuals.
Cogl has an old, deprecated, Clutter-only API that allows us to retrieve
the XVisualInfo mapping to the GLXFBConfig it uses; this means we should
look up the GdkVisual for it when creating our own GdkWindows, instead
of relying on the RGBA and system GdkVisuals exposed by GDK — at least
on X11.
https://bugzilla.gnome.org/show_bug.cgi?id=747489
2015-06-10 10:55:50 +00:00
|
|
|
if (!stage_gdk->foreign_window)
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
{
|
2011-09-29 17:16:48 +00:00
|
|
|
if (stage_gdk->window != NULL)
|
|
|
|
{
|
|
|
|
/* complete realizing the stage */
|
|
|
|
cairo_rectangle_int_t geometry;
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
|
2011-09-29 17:16:48 +00:00
|
|
|
clutter_stage_gdk_get_geometry (stage_window, &geometry);
|
|
|
|
clutter_actor_set_size (CLUTTER_ACTOR (stage_cogl->wrapper),
|
|
|
|
geometry.width,
|
|
|
|
geometry.height);
|
2011-08-26 22:16:12 +00:00
|
|
|
|
2011-09-29 17:16:48 +00:00
|
|
|
gdk_window_ensure_native (stage_gdk->window);
|
|
|
|
gdk_window_set_events (stage_gdk->window, CLUTTER_STAGE_GDK_EVENT_MASK);
|
2011-08-26 22:16:12 +00:00
|
|
|
|
2011-09-29 17:16:48 +00:00
|
|
|
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)
|
2014-12-03 12:11:55 +00:00
|
|
|
stage_gdk->blank_cursor = gdk_cursor_new_for_display (backend_gdk->display, GDK_BLANK_CURSOR);
|
2011-09-29 17:16:48 +00:00
|
|
|
|
|
|
|
attributes.cursor = stage_gdk->blank_cursor;
|
|
|
|
}
|
|
|
|
|
gdk: Use the Cogl visual on Xlib winsys
GDK 3.16 started selecting different visuals, to best comply with the
requirements for OpenGL, and this has broken Clutter on GLX drivers that
are fairly picky in how they select visuals and GLXFBConfig.
GDK selects GLXFBConfig that do not include depth or stencil buffers;
Cogl, on the other hand, needs both depth and stencil buffers, and keeps
selecting the first available visual, assuming that the GLX driver will
give us the best compliant one, as per specification. Sadly, some
drivers will return incompatible configurations, and then bomb out when
you try to embed Clutter inside GTK+, because of mismatched visuals.
Cogl has an old, deprecated, Clutter-only API that allows us to retrieve
the XVisualInfo mapping to the GLXFBConfig it uses; this means we should
look up the GdkVisual for it when creating our own GdkWindows, instead
of relying on the RGBA and system GdkVisuals exposed by GDK — at least
on X11.
https://bugzilla.gnome.org/show_bug.cgi?id=747489
2015-06-10 10:55:50 +00:00
|
|
|
/* If the ClutterStage:use-alpha is set, but GDK does not have an
|
|
|
|
* RGBA visual, then we unset the property on the Stage
|
|
|
|
*/
|
2011-09-29 17:16:48 +00:00
|
|
|
if (use_alpha)
|
|
|
|
{
|
gdk: Use the Cogl visual on Xlib winsys
GDK 3.16 started selecting different visuals, to best comply with the
requirements for OpenGL, and this has broken Clutter on GLX drivers that
are fairly picky in how they select visuals and GLXFBConfig.
GDK selects GLXFBConfig that do not include depth or stencil buffers;
Cogl, on the other hand, needs both depth and stencil buffers, and keeps
selecting the first available visual, assuming that the GLX driver will
give us the best compliant one, as per specification. Sadly, some
drivers will return incompatible configurations, and then bomb out when
you try to embed Clutter inside GTK+, because of mismatched visuals.
Cogl has an old, deprecated, Clutter-only API that allows us to retrieve
the XVisualInfo mapping to the GLXFBConfig it uses; this means we should
look up the GdkVisual for it when creating our own GdkWindows, instead
of relying on the RGBA and system GdkVisuals exposed by GDK — at least
on X11.
https://bugzilla.gnome.org/show_bug.cgi?id=747489
2015-06-10 10:55:50 +00:00
|
|
|
if (gdk_screen_get_rgba_visual (backend_gdk->screen) == NULL)
|
|
|
|
{
|
|
|
|
clutter_stage_set_use_alpha (stage_cogl->wrapper, FALSE);
|
|
|
|
use_alpha = FALSE;
|
|
|
|
}
|
|
|
|
}
|
2011-09-29 17:16:48 +00:00
|
|
|
|
gdk: Use the Cogl visual on Xlib winsys
GDK 3.16 started selecting different visuals, to best comply with the
requirements for OpenGL, and this has broken Clutter on GLX drivers that
are fairly picky in how they select visuals and GLXFBConfig.
GDK selects GLXFBConfig that do not include depth or stencil buffers;
Cogl, on the other hand, needs both depth and stencil buffers, and keeps
selecting the first available visual, assuming that the GLX driver will
give us the best compliant one, as per specification. Sadly, some
drivers will return incompatible configurations, and then bomb out when
you try to embed Clutter inside GTK+, because of mismatched visuals.
Cogl has an old, deprecated, Clutter-only API that allows us to retrieve
the XVisualInfo mapping to the GLXFBConfig it uses; this means we should
look up the GdkVisual for it when creating our own GdkWindows, instead
of relying on the RGBA and system GdkVisuals exposed by GDK — at least
on X11.
https://bugzilla.gnome.org/show_bug.cgi?id=747489
2015-06-10 10:55:50 +00:00
|
|
|
#if defined(GDK_WINDOWING_X11) && defined(COGL_HAS_XLIB_SUPPORT)
|
|
|
|
if (GDK_IS_X11_DISPLAY (backend_gdk->display))
|
|
|
|
{
|
|
|
|
XVisualInfo *xvisinfo = cogl_clutter_winsys_xlib_get_visual_info ();
|
|
|
|
if (xvisinfo != NULL)
|
|
|
|
{
|
|
|
|
attributes.visual = gdk_x11_screen_lookup_visual (backend_gdk->screen,
|
|
|
|
xvisinfo->visualid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
attributes.visual = use_alpha
|
|
|
|
? gdk_screen_get_rgba_visual (backend_gdk->screen)
|
|
|
|
: gdk_screen_get_system_visual (backend_gdk->screen);
|
2011-09-29 17:16:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2015-08-31 22:20:29 +00:00
|
|
|
gdk_window_ensure_native (stage_gdk->window);
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
}
|
gdk: Use the Cogl visual on Xlib winsys
GDK 3.16 started selecting different visuals, to best comply with the
requirements for OpenGL, and this has broken Clutter on GLX drivers that
are fairly picky in how they select visuals and GLXFBConfig.
GDK selects GLXFBConfig that do not include depth or stencil buffers;
Cogl, on the other hand, needs both depth and stencil buffers, and keeps
selecting the first available visual, assuming that the GLX driver will
give us the best compliant one, as per specification. Sadly, some
drivers will return incompatible configurations, and then bomb out when
you try to embed Clutter inside GTK+, because of mismatched visuals.
Cogl has an old, deprecated, Clutter-only API that allows us to retrieve
the XVisualInfo mapping to the GLXFBConfig it uses; this means we should
look up the GdkVisual for it when creating our own GdkWindows, instead
of relying on the RGBA and system GdkVisuals exposed by GDK — at least
on X11.
https://bugzilla.gnome.org/show_bug.cgi?id=747489
2015-06-10 10:55:50 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
width = gdk_window_get_width (stage_gdk->window);
|
|
|
|
height = gdk_window_get_height (stage_gdk->window);
|
|
|
|
}
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
|
gdk: Use the Cogl visual on Xlib winsys
GDK 3.16 started selecting different visuals, to best comply with the
requirements for OpenGL, and this has broken Clutter on GLX drivers that
are fairly picky in how they select visuals and GLXFBConfig.
GDK selects GLXFBConfig that do not include depth or stencil buffers;
Cogl, on the other hand, needs both depth and stencil buffers, and keeps
selecting the first available visual, assuming that the GLX driver will
give us the best compliant one, as per specification. Sadly, some
drivers will return incompatible configurations, and then bomb out when
you try to embed Clutter inside GTK+, because of mismatched visuals.
Cogl has an old, deprecated, Clutter-only API that allows us to retrieve
the XVisualInfo mapping to the GLXFBConfig it uses; this means we should
look up the GdkVisual for it when creating our own GdkWindows, instead
of relying on the RGBA and system GdkVisuals exposed by GDK — at least
on X11.
https://bugzilla.gnome.org/show_bug.cgi?id=747489
2015-06-10 10:55:50 +00:00
|
|
|
g_object_set_data (G_OBJECT (stage_gdk->window), "clutter-stage-window", stage_gdk);
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
|
2015-11-22 17:22:41 +00:00
|
|
|
scale = gdk_window_get_scale_factor (stage_gdk->window);
|
2011-08-26 22:16:12 +00:00
|
|
|
stage_cogl->onscreen = cogl_onscreen_new (backend->cogl_context,
|
2015-11-22 17:22:41 +00:00
|
|
|
width * scale, height * scale);
|
2011-08-26 22:16:12 +00:00
|
|
|
|
|
|
|
#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
|
2014-08-16 19:35:54 +00:00
|
|
|
#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,
|
2015-08-31 21:58:11 +00:00
|
|
|
clutter_stage_gdk_wayland_surface (stage_gdk));
|
2014-08-16 19:35:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
2011-08-26 22:16:12 +00:00
|
|
|
#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;
|
|
|
|
|
2011-09-29 17:16:48 +00:00
|
|
|
if (!stage_gdk->foreign_window)
|
|
|
|
gdk_window_destroy (stage_gdk->window);
|
|
|
|
|
2011-08-26 22:16:12 +00:00
|
|
|
stage_gdk->window = NULL;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
|
2011-08-26 22:16:12 +00:00
|
|
|
return clutter_stage_window_parent_iface->realize (stage_window);
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_stage_gdk_set_fullscreen (ClutterStageWindow *stage_window,
|
|
|
|
gboolean is_fullscreen)
|
|
|
|
{
|
|
|
|
ClutterStageGdk *stage_gdk = CLUTTER_STAGE_GDK (stage_window);
|
2011-08-26 22:16:12 +00:00
|
|
|
ClutterStage *stage = CLUTTER_STAGE_COGL (stage_window)->wrapper;
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
|
|
|
|
if (stage == NULL || CLUTTER_ACTOR_IN_DESTRUCTION (stage))
|
|
|
|
return;
|
|
|
|
|
2015-09-07 11:21:18 +00:00
|
|
|
if (stage_gdk->window == NULL || stage_gdk->foreign_window)
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
CLUTTER_NOTE (BACKEND, "%ssetting fullscreen", is_fullscreen ? "" : "un");
|
|
|
|
|
|
|
|
if (is_fullscreen)
|
|
|
|
gdk_window_fullscreen (stage_gdk->window);
|
|
|
|
else
|
|
|
|
gdk_window_unfullscreen (stage_gdk->window);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_stage_gdk_set_cursor_visible (ClutterStageWindow *stage_window,
|
|
|
|
gboolean cursor_visible)
|
|
|
|
{
|
|
|
|
ClutterStageGdk *stage_gdk = CLUTTER_STAGE_GDK (stage_window);
|
|
|
|
|
|
|
|
if (stage_gdk->window == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (cursor_visible)
|
|
|
|
{
|
|
|
|
gdk_window_set_cursor (stage_gdk->window, NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (stage_gdk->blank_cursor == NULL)
|
2014-12-03 12:11:55 +00:00
|
|
|
{
|
|
|
|
GdkDisplay *display = clutter_gdk_get_default_display ();
|
|
|
|
|
|
|
|
stage_gdk->blank_cursor = gdk_cursor_new_for_display (display, GDK_BLANK_CURSOR);
|
|
|
|
}
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
|
|
|
|
gdk_window_set_cursor (stage_gdk->window, stage_gdk->blank_cursor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_stage_gdk_set_title (ClutterStageWindow *stage_window,
|
|
|
|
const gchar *title)
|
|
|
|
{
|
|
|
|
ClutterStageGdk *stage_gdk = CLUTTER_STAGE_GDK (stage_window);
|
|
|
|
|
2015-09-07 11:21:18 +00:00
|
|
|
if (stage_gdk->window == NULL || stage_gdk->foreign_window)
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
gdk_window_set_title (stage_gdk->window, title);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_stage_gdk_set_user_resizable (ClutterStageWindow *stage_window,
|
|
|
|
gboolean is_resizable)
|
|
|
|
{
|
|
|
|
ClutterStageGdk *stage_gdk = CLUTTER_STAGE_GDK (stage_window);
|
|
|
|
GdkWMFunction function;
|
|
|
|
|
2015-09-07 11:21:18 +00:00
|
|
|
if (stage_gdk->window == NULL || stage_gdk->foreign_window)
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
function = GDK_FUNC_MOVE | GDK_FUNC_MINIMIZE | GDK_FUNC_CLOSE;
|
|
|
|
if (is_resizable)
|
|
|
|
function |= GDK_FUNC_RESIZE | GDK_FUNC_MAXIMIZE;
|
|
|
|
|
|
|
|
gdk_window_set_functions (stage_gdk->window, function);
|
|
|
|
|
|
|
|
clutter_stage_gdk_set_gdk_geometry (stage_gdk);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_stage_gdk_set_accept_focus (ClutterStageWindow *stage_window,
|
|
|
|
gboolean accept_focus)
|
|
|
|
{
|
|
|
|
ClutterStageGdk *stage_gdk = CLUTTER_STAGE_GDK (stage_window);
|
|
|
|
|
2015-09-07 11:21:18 +00:00
|
|
|
if (stage_gdk->window == NULL || stage_gdk->foreign_window)
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
gdk_window_set_accept_focus (stage_gdk->window, accept_focus);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_stage_gdk_show (ClutterStageWindow *stage_window,
|
|
|
|
gboolean do_raise)
|
|
|
|
{
|
|
|
|
ClutterStageGdk *stage_gdk = CLUTTER_STAGE_GDK (stage_window);
|
|
|
|
|
|
|
|
g_return_if_fail (stage_gdk->window != NULL);
|
|
|
|
|
2011-08-26 22:16:12 +00:00
|
|
|
clutter_actor_map (CLUTTER_ACTOR (CLUTTER_STAGE_COGL (stage_gdk)->wrapper));
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
|
2015-09-07 11:21:18 +00:00
|
|
|
/* Foreign window should be shown by the embedding framework. */
|
|
|
|
if (!stage_gdk->foreign_window)
|
|
|
|
{
|
|
|
|
if (do_raise)
|
|
|
|
gdk_window_show (stage_gdk->window);
|
|
|
|
else
|
|
|
|
gdk_window_show_unraised (stage_gdk->window);
|
|
|
|
}
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_stage_gdk_hide (ClutterStageWindow *stage_window)
|
|
|
|
{
|
|
|
|
ClutterStageGdk *stage_gdk = CLUTTER_STAGE_GDK (stage_window);
|
|
|
|
|
|
|
|
g_return_if_fail (stage_gdk->window != NULL);
|
|
|
|
|
2011-08-26 22:16:12 +00:00
|
|
|
clutter_actor_unmap (CLUTTER_ACTOR (CLUTTER_STAGE_COGL (stage_gdk)->wrapper));
|
2015-09-07 11:21:18 +00:00
|
|
|
|
|
|
|
/* Foreign window should be hidden by the embedding framework. */
|
|
|
|
if (!stage_gdk->foreign_window)
|
|
|
|
gdk_window_hide (stage_gdk->window);
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
}
|
|
|
|
|
2011-09-30 12:58:40 +00:00
|
|
|
static gboolean
|
|
|
|
clutter_stage_gdk_can_clip_redraws (ClutterStageWindow *stage_window)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2015-01-12 15:04:27 +00:00
|
|
|
static int
|
|
|
|
clutter_stage_gdk_get_scale_factor (ClutterStageWindow *stage_window)
|
|
|
|
{
|
|
|
|
ClutterStageGdk *stage_gdk = CLUTTER_STAGE_GDK (stage_window);
|
|
|
|
|
|
|
|
if (stage_gdk->window == NULL)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return gdk_window_get_scale_factor (stage_gdk->window);
|
|
|
|
}
|
|
|
|
|
2015-02-17 14:52:17 +00:00
|
|
|
static void
|
|
|
|
clutter_stage_gdk_redraw (ClutterStageWindow *stage_window)
|
|
|
|
{
|
|
|
|
ClutterStageGdk *stage_gdk = CLUTTER_STAGE_GDK (stage_window);
|
|
|
|
GdkFrameClock *clock;
|
|
|
|
|
|
|
|
if (stage_gdk->window == NULL ||
|
|
|
|
(clock = gdk_window_get_frame_clock (stage_gdk->window)) == NULL)
|
|
|
|
{
|
|
|
|
clutter_stage_window_parent_iface->redraw (stage_window);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
gdk_frame_clock_begin_updating (clock);
|
|
|
|
|
|
|
|
clutter_stage_window_parent_iface->redraw (stage_window);
|
|
|
|
|
|
|
|
gdk_frame_clock_end_updating (clock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_stage_gdk_schedule_update (ClutterStageWindow *stage_window,
|
|
|
|
gint sync_delay)
|
|
|
|
{
|
|
|
|
ClutterStageGdk *stage_gdk = CLUTTER_STAGE_GDK (stage_window);
|
|
|
|
GdkFrameClock *clock;
|
|
|
|
|
|
|
|
if (stage_gdk->window == NULL ||
|
|
|
|
(clock = gdk_window_get_frame_clock (stage_gdk->window)) == NULL)
|
|
|
|
{
|
|
|
|
clutter_stage_window_parent_iface->schedule_update (stage_window, sync_delay);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-09-11 11:15:16 +00:00
|
|
|
gdk_frame_clock_request_phase (clock, GDK_FRAME_CLOCK_PHASE_PAINT);
|
2015-02-17 14:52:17 +00:00
|
|
|
|
|
|
|
clutter_stage_window_parent_iface->schedule_update (stage_window, sync_delay);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint64
|
|
|
|
clutter_stage_gdk_get_update_time (ClutterStageWindow *stage_window)
|
|
|
|
{
|
|
|
|
ClutterStageGdk *stage_gdk = CLUTTER_STAGE_GDK (stage_window);
|
|
|
|
GdkFrameClock *frame_clock;
|
|
|
|
GdkFrameTimings *frame_timings;
|
|
|
|
|
|
|
|
if (stage_gdk->window == NULL ||
|
|
|
|
(frame_clock = gdk_window_get_frame_clock (stage_gdk->window)) == NULL ||
|
|
|
|
(frame_timings = gdk_frame_clock_get_current_timings (frame_clock)) == NULL ||
|
|
|
|
!gdk_frame_timings_get_complete (frame_timings))
|
|
|
|
return -1; /* No data, indefinite */
|
|
|
|
|
|
|
|
return (gdk_frame_timings_get_presentation_time (frame_timings) +
|
|
|
|
gdk_frame_timings_get_refresh_interval (frame_timings));
|
|
|
|
}
|
|
|
|
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
static void
|
|
|
|
clutter_stage_gdk_dispose (GObject *gobject)
|
|
|
|
{
|
|
|
|
ClutterStageGdk *stage_gdk = CLUTTER_STAGE_GDK (gobject);
|
|
|
|
|
2011-08-26 22:16:12 +00:00
|
|
|
if (stage_gdk->window != NULL)
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
{
|
|
|
|
g_object_set_data (G_OBJECT (stage_gdk->window),
|
|
|
|
"clutter-stage-window", NULL);
|
|
|
|
if (stage_gdk->foreign_window)
|
|
|
|
g_object_unref (stage_gdk->window);
|
|
|
|
else
|
|
|
|
gdk_window_destroy (stage_gdk->window);
|
|
|
|
stage_gdk->window = NULL;
|
|
|
|
}
|
|
|
|
|
2011-08-26 22:16:12 +00:00
|
|
|
if (stage_gdk->blank_cursor != NULL)
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
{
|
|
|
|
g_object_unref (stage_gdk->blank_cursor);
|
|
|
|
stage_gdk->blank_cursor = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (clutter_stage_gdk_parent_class)->dispose (gobject);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_stage_gdk_class_init (ClutterStageGdkClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
gobject_class->dispose = clutter_stage_gdk_dispose;
|
|
|
|
}
|
|
|
|
|
2015-08-31 21:58:11 +00:00
|
|
|
#if defined(GDK_WINDOWING_WAYLAND)
|
|
|
|
static void
|
|
|
|
registry_handle_global (void *data,
|
|
|
|
struct wl_registry *registry,
|
|
|
|
uint32_t name,
|
|
|
|
const char *interface,
|
|
|
|
uint32_t version)
|
|
|
|
{
|
|
|
|
ClutterStageGdk *stage_gdk = data;
|
|
|
|
|
|
|
|
if (strcmp (interface, "wl_subcompositor") == 0)
|
|
|
|
{
|
|
|
|
stage_gdk->subcompositor = wl_registry_bind (registry,
|
|
|
|
name,
|
|
|
|
&wl_subcompositor_interface,
|
|
|
|
1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
registry_handle_global_remove (void *data,
|
|
|
|
struct wl_registry *registry,
|
|
|
|
uint32_t name)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct wl_registry_listener registry_listener = {
|
|
|
|
registry_handle_global,
|
|
|
|
registry_handle_global_remove
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
static void
|
|
|
|
clutter_stage_gdk_init (ClutterStageGdk *stage)
|
|
|
|
{
|
2015-08-31 21:58:11 +00:00
|
|
|
#if defined(GDK_WINDOWING_WAYLAND)
|
|
|
|
{
|
|
|
|
GdkDisplay *gdk_display = gdk_display_get_default ();
|
|
|
|
if (GDK_IS_WAYLAND_DISPLAY (gdk_display))
|
|
|
|
{
|
|
|
|
struct wl_display *display;
|
|
|
|
struct wl_registry *registry;
|
|
|
|
|
|
|
|
display = gdk_wayland_display_get_wl_display (gdk_display);
|
|
|
|
registry = wl_display_get_registry (display);
|
|
|
|
wl_registry_add_listener (registry, ®istry_listener, stage);
|
|
|
|
|
|
|
|
wl_display_roundtrip (display);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_stage_window_iface_init (ClutterStageWindowIface *iface)
|
|
|
|
{
|
2011-08-26 22:16:12 +00:00
|
|
|
clutter_stage_window_parent_iface = g_type_interface_peek_parent (iface);
|
|
|
|
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
iface->set_title = clutter_stage_gdk_set_title;
|
|
|
|
iface->set_fullscreen = clutter_stage_gdk_set_fullscreen;
|
|
|
|
iface->set_cursor_visible = clutter_stage_gdk_set_cursor_visible;
|
|
|
|
iface->set_user_resizable = clutter_stage_gdk_set_user_resizable;
|
|
|
|
iface->set_accept_focus = clutter_stage_gdk_set_accept_focus;
|
|
|
|
iface->show = clutter_stage_gdk_show;
|
|
|
|
iface->hide = clutter_stage_gdk_hide;
|
|
|
|
iface->resize = clutter_stage_gdk_resize;
|
|
|
|
iface->get_geometry = clutter_stage_gdk_get_geometry;
|
|
|
|
iface->realize = clutter_stage_gdk_realize;
|
|
|
|
iface->unrealize = clutter_stage_gdk_unrealize;
|
2011-09-30 12:58:40 +00:00
|
|
|
iface->can_clip_redraws = clutter_stage_gdk_can_clip_redraws;
|
2015-01-12 15:04:27 +00:00
|
|
|
iface->get_scale_factor = clutter_stage_gdk_get_scale_factor;
|
2015-02-17 14:52:17 +00:00
|
|
|
|
|
|
|
iface->redraw = clutter_stage_gdk_redraw;
|
|
|
|
iface->schedule_update = clutter_stage_gdk_schedule_update;
|
|
|
|
iface->get_update_time = clutter_stage_gdk_get_update_time;
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_gdk_get_stage_window:
|
|
|
|
* @stage: a #ClutterStage
|
|
|
|
*
|
|
|
|
* Gets the stages GdkWindow.
|
|
|
|
*
|
|
|
|
* Return value: (transfer none): A GdkWindow* for the stage window.
|
|
|
|
*
|
2011-09-30 12:58:40 +00:00
|
|
|
* Since: 1.10
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
*/
|
2011-09-21 17:05:03 +00:00
|
|
|
GdkWindow *
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
clutter_gdk_get_stage_window (ClutterStage *stage)
|
|
|
|
{
|
|
|
|
ClutterStageWindow *impl;
|
|
|
|
|
2012-07-29 12:39:13 +00:00
|
|
|
g_return_val_if_fail (CLUTTER_IS_STAGE (stage), NULL);
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
|
|
|
|
impl = _clutter_stage_get_window (stage);
|
2011-09-21 17:05:03 +00:00
|
|
|
if (!CLUTTER_IS_STAGE_GDK (impl))
|
|
|
|
{
|
|
|
|
g_critical ("The Clutter backend is not a GDK backend");
|
|
|
|
return NULL;
|
|
|
|
}
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
|
|
|
|
return CLUTTER_STAGE_GDK (impl)->window;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_gdk_get_stage_from_window:
|
|
|
|
* @window: a #GtkWindow
|
|
|
|
*
|
|
|
|
* Gets the stage for a particular X window.
|
|
|
|
*
|
|
|
|
* Return value: (transfer none): A #ClutterStage, or% NULL if a stage
|
|
|
|
* does not exist for the window
|
|
|
|
*
|
2011-09-30 12:58:40 +00:00
|
|
|
* Since: 1.10
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
*/
|
|
|
|
ClutterStage *
|
|
|
|
clutter_gdk_get_stage_from_window (GdkWindow *window)
|
|
|
|
{
|
|
|
|
ClutterStageGdk *stage_gdk = g_object_get_data (G_OBJECT (window), "clutter-stage-window");
|
|
|
|
|
|
|
|
if (stage_gdk != NULL && CLUTTER_IS_STAGE_GDK (stage_gdk))
|
2011-08-26 22:16:12 +00:00
|
|
|
return CLUTTER_STAGE_COGL (stage_gdk)->wrapper;
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
ClutterStageGdk *stage_gdk;
|
|
|
|
GdkWindow *window;
|
|
|
|
} ForeignWindowClosure;
|
|
|
|
|
|
|
|
static void
|
|
|
|
set_foreign_window_callback (ClutterActor *actor,
|
|
|
|
void *data)
|
|
|
|
{
|
|
|
|
ForeignWindowClosure *closure = data;
|
|
|
|
ClutterStageGdk *stage_gdk = closure->stage_gdk;
|
|
|
|
|
|
|
|
stage_gdk->window = closure->window;
|
|
|
|
stage_gdk->foreign_window = TRUE;
|
|
|
|
|
|
|
|
/* calling this with the stage unrealized will unset the stage
|
|
|
|
* from the GL context; once the stage is realized the GL context
|
|
|
|
* will be set again
|
|
|
|
*/
|
|
|
|
clutter_stage_ensure_current (CLUTTER_STAGE (actor));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_gdk_set_stage_foreign:
|
|
|
|
* @stage: a #ClutterStage
|
|
|
|
* @window: an existing #GdkWindow
|
|
|
|
*
|
|
|
|
* Target the #ClutterStage to use an existing external #GdkWindow
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if foreign window is valid
|
|
|
|
*
|
2011-09-30 12:58:40 +00:00
|
|
|
* Since: 1.10
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
clutter_gdk_set_stage_foreign (ClutterStage *stage,
|
|
|
|
GdkWindow *window)
|
|
|
|
{
|
|
|
|
ForeignWindowClosure closure;
|
|
|
|
ClutterStageGdk *stage_gdk;
|
|
|
|
ClutterStageWindow *impl;
|
|
|
|
ClutterActor *actor;
|
|
|
|
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_STAGE (stage), FALSE);
|
|
|
|
g_return_val_if_fail (!CLUTTER_ACTOR_IN_DESTRUCTION (stage), FALSE);
|
|
|
|
g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
|
|
|
|
|
|
|
|
impl = _clutter_stage_get_window (stage);
|
2011-09-21 17:05:03 +00:00
|
|
|
if (!CLUTTER_IS_STAGE_GDK (impl))
|
|
|
|
{
|
|
|
|
g_critical ("The Clutter backend is not a GDK backend");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
Add a new GDK backend
This commit introduces a new flavour for Clutter, that uses GDK
for handling all window system specific interactions (except for
creating the cogl context, as cogl does not know about GDK), including
in particular events. This is not compatible with the X11 (glx)
flavour, and this is reflected by the different soname (libclutter-gdk-1.0.so),
as all X11 specific functions and classes are not available. If you
wish to be compatible, you should check for CLUTTER_WINDOWING_X11.
Other than that, this backend should be on feature parity with X11,
including XInput 2, XSettings and EMWH (with much, much less code)
https://bugzilla.gnome.org/show_bug.cgi?id=657434
2011-08-26 01:09:18 +00:00
|
|
|
stage_gdk = CLUTTER_STAGE_GDK (impl);
|
|
|
|
|
|
|
|
if (g_object_get_data (G_OBJECT (window), "clutter-stage-window") != NULL)
|
|
|
|
{
|
|
|
|
g_critical ("The provided GdkWindow is already in use by another ClutterStage");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
closure.stage_gdk = stage_gdk;
|
|
|
|
closure.window = g_object_ref (window);
|
|
|
|
|
|
|
|
actor = CLUTTER_ACTOR (stage);
|
|
|
|
|
|
|
|
_clutter_actor_rerealize (actor,
|
|
|
|
set_foreign_window_callback,
|
|
|
|
&closure);
|
|
|
|
|
|
|
|
/* Queue a relayout - so the stage will be allocated the new
|
|
|
|
* window size.
|
|
|
|
*
|
|
|
|
* Note also that when the stage gets allocated the new
|
|
|
|
* window size that will result in the stage's
|
|
|
|
* priv->viewport being changed, which will in turn result
|
|
|
|
* in the Cogl viewport changing when _clutter_do_redraw
|
|
|
|
* calls _clutter_stage_maybe_setup_viewport().
|
|
|
|
*/
|
|
|
|
clutter_actor_queue_relayout (actor);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|