Commit 712a5d4f authored by Matthias Clasen's avatar Matthias Clasen
Browse files

Get rid of GdkSurfaceImpl

We don't need the complicated wrapper system anymore,
since client-side windows are gone. This commit moves
all the vfuncs to GtkSurfaceClass, and changes the
backends to just derive their surface implementation
from GdkSurface.
parent 93b8f256
......@@ -20,7 +20,7 @@
#include "gdkdevice-broadway.h"
#include "gdksurface.h"
#include "gdksurfaceprivate.h"
#include "gdkprivate-broadway.h"
static gboolean gdk_broadway_device_get_history (GdkDevice *device,
......@@ -251,7 +251,7 @@ gdk_broadway_device_grab (GdkDevice *device,
{
/* Device is a pointer */
return _gdk_broadway_server_grab_pointer (broadway_display->server,
GDK_SURFACE_IMPL_BROADWAY (surface->impl)->id,
GDK_BROADWAY_SURFACE (surface)->id,
owner_events,
event_mask,
time_);
......
......@@ -95,10 +95,10 @@ _gdk_broadway_display_size_changed (GdkDisplay *display,
toplevels = broadway_display->toplevels;
for (l = toplevels; l != NULL; l = l->next)
{
GdkSurfaceImplBroadway *toplevel_impl = l->data;
GdkBroadwaySurface *toplevel = l->data;
if (toplevel_impl->maximized)
gdk_surface_move_resize (toplevel_impl->wrapper, 0, 0, msg->width, msg->height);
if (toplevel->maximized)
gdk_surface_move_resize (GDK_SURFACE (toplevel), 0, 0, msg->width, msg->height);
}
}
......@@ -420,7 +420,6 @@ gdk_broadway_display_class_init (GdkBroadwayDisplayClass * class)
object_class->dispose = gdk_broadway_display_dispose;
object_class->finalize = gdk_broadway_display_finalize;
display_class->surface_type = GDK_TYPE_BROADWAY_SURFACE;
display_class->cairo_context_type = GDK_TYPE_BROADWAY_CAIRO_CONTEXT;
display_class->get_name = gdk_broadway_display_get_name;
......@@ -435,7 +434,7 @@ gdk_broadway_display_class_init (GdkBroadwayDisplayClass * class)
display_class->get_next_serial = gdk_broadway_display_get_next_serial;
display_class->notify_startup_complete = gdk_broadway_display_notify_startup_complete;
display_class->create_surface_impl = _gdk_broadway_display_create_surface_impl;
display_class->create_surface = _gdk_broadway_display_create_surface;
display_class->get_keymap = _gdk_broadway_display_get_keymap;
display_class->text_property_to_utf8_list = _gdk_broadway_display_text_property_to_utf8_list;
display_class->utf8_to_string_target = _gdk_broadway_display_utf8_to_string_target;
......
......@@ -26,7 +26,7 @@
#include "gdkdragprivate.h"
#include "gdkinternals.h"
#include "gdksurfaceprivate.h"
#include "gdkproperty.h"
#include "gdkprivate-broadway.h"
#include "gdkinternals.h"
......@@ -94,7 +94,7 @@ _gdk_broadway_surface_drag_begin (GdkSurface *surface,
GdkDrag *new_context;
g_return_val_if_fail (surface != NULL, NULL);
g_return_val_if_fail (GDK_SURFACE_IS_BROADWAY (surface), NULL);
g_return_val_if_fail (GDK_IS_BROADWAY_SURFACE (surface), NULL);
new_context = g_object_new (GDK_TYPE_BROADWAY_DRAG,
"device", device,
......
......@@ -20,7 +20,7 @@
#include "gdkeventsource.h"
#include "gdkseat.h"
#include "gdkinternals.h"
#include "gdksurfaceprivate.h"
#include "gdkframeclockprivate.h"
#include <stdlib.h>
......
......@@ -101,9 +101,13 @@ void _gdk_broadway_display_get_default_cursor_size (GdkDisplay *display,
void _gdk_broadway_display_get_maximal_cursor_size (GdkDisplay *display,
guint *width,
guint *height);
void _gdk_broadway_display_create_surface_impl (GdkDisplay *display,
GdkSurface *surface,
GdkSurface *real_parent);
GdkSurface * _gdk_broadway_display_create_surface (GdkDisplay *display,
GdkSurfaceType surface_type,
GdkSurface *parent,
int x,
int y,
int width,
int height);
gint _gdk_broadway_display_text_property_to_utf8_list (GdkDisplay *display,
GdkAtom encoding,
gint format,
......@@ -125,6 +129,4 @@ void _gdk_broadway_surface_resize_surface (GdkSurface *surface);
void _gdk_broadway_cursor_update_theme (GdkCursor *cursor);
void _gdk_broadway_cursor_display_finalize (GdkDisplay *display);
#define GDK_SURFACE_IS_BROADWAY(win) (GDK_IS_SURFACE_IMPL_BROADWAY (((GdkSurface *)win)->impl))
#endif /* __GDK_PRIVATE_BROADWAY_H__ */
This diff is collapsed.
......@@ -25,28 +25,17 @@
#ifndef __GDK_SURFACE_BROADWAY_H__
#define __GDK_SURFACE_BROADWAY_H__
#include <gdk/gdksurfaceimpl.h>
#include <gdk/gdksurfaceprivate.h>
#include "gdkbroadwaysurface.h"
G_BEGIN_DECLS
typedef struct _GdkSurfaceImplBroadway GdkSurfaceImplBroadway;
typedef struct _GdkSurfaceImplBroadwayClass GdkSurfaceImplBroadwayClass;
/* Surface implementation for Broadway
*/
#define GDK_TYPE_SURFACE_IMPL_BROADWAY (gdk_surface_impl_broadway_get_type ())
#define GDK_SURFACE_IMPL_BROADWAY(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_SURFACE_IMPL_BROADWAY, GdkSurfaceImplBroadway))
#define GDK_SURFACE_IMPL_BROADWAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_SURFACE_IMPL_BROADWAY, GdkSurfaceImplBroadwayClass))
#define GDK_IS_SURFACE_IMPL_BROADWAY(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_SURFACE_IMPL_BROADWAY))
#define GDK_IS_SURFACE_IMPL_BROADWAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_SURFACE_IMPL_BROADWAY))
#define GDK_SURFACE_IMPL_BROADWAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_SURFACE_IMPL_BROADWAY, GdkSurfaceImplBroadwayClass))
struct _GdkSurfaceImplBroadway
struct _GdkBroadwaySurface
{
GdkSurfaceImpl parent_instance;
GdkSurface *wrapper;
GdkSurface parent_instance;
GdkCursor *cursor;
......@@ -73,12 +62,12 @@ struct _GdkSurfaceImplBroadway
GPtrArray *node_data_textures;
};
struct _GdkSurfaceImplBroadwayClass
struct _GdkBroadwaySurfaceClass
{
GdkSurfaceImplClass parent_class;
GdkSurfaceClass parent_class;
};
GType gdk_surface_impl_broadway_get_type (void);
GType gdk_surface_broadway_get_type (void);
G_END_DECLS
......
......@@ -31,9 +31,9 @@
#include "gdkdeviceprivate.h"
#include "gdkdisplaymanagerprivate.h"
#include "gdkevents.h"
#include "gdksurfaceimpl.h"
#include "gdkinternals.h"
#include "gdkmonitorprivate.h"
#include "gdkframeclockidleprivate.h"
#include <math.h>
#include <glib.h>
......@@ -171,8 +171,6 @@ gdk_display_class_init (GdkDisplayClass *class)
object_class->get_property = gdk_display_get_property;
class->get_app_launch_context = gdk_display_real_get_app_launch_context;
class->surface_type = GDK_TYPE_SURFACE;
class->opened = gdk_display_real_opened;
class->make_default = gdk_display_real_make_default;
class->event_data_copy = gdk_display_real_event_data_copy;
......@@ -1324,22 +1322,19 @@ _gdk_display_event_data_free (GdkDisplay *display,
GDK_DISPLAY_GET_CLASS (display)->event_data_free (display, event);
}
void
gdk_display_create_surface_impl (GdkDisplay *display,
GdkSurface *surface,
GdkSurface *real_parent)
{
GDK_DISPLAY_GET_CLASS (display)->create_surface_impl (display,
surface,
real_parent);
}
GdkSurface *
_gdk_display_create_surface (GdkDisplay *display)
{
return g_object_new (GDK_DISPLAY_GET_CLASS (display)->surface_type,
"display", display,
NULL);
gdk_display_create_surface (GdkDisplay *display,
GdkSurfaceType surface_type,
GdkSurface *parent,
int x,
int y,
int width,
int height)
{
return GDK_DISPLAY_GET_CLASS (display)->create_surface (display,
surface_type,
parent,
x, y, width, height);
}
/**
......
......@@ -112,7 +112,6 @@ struct _GdkDisplayClass
{
GObjectClass parent_class;
GType surface_type; /* type for native surfaces for this display, set in class_init */
GType cairo_context_type; /* type for GdkCairoContext, must be set */
GType vk_context_type; /* type for GdkVulkanContext, must be set if vk_extension_name != NULL */
const char *vk_extension_name; /* Name of required windowing vulkan extension or %NULL (default) if Vulkan isn't supported */
......@@ -141,9 +140,13 @@ struct _GdkDisplayClass
GdkEvent *new_event);
void (*event_data_free) (GdkDisplay *display,
GdkEvent *event);
void (*create_surface_impl) (GdkDisplay *display,
GdkSurface *surface,
GdkSurface *real_parent);
GdkSurface * (*create_surface) (GdkDisplay *display,
GdkSurfaceType surface_type,
GdkSurface *parent,
int x,
int y,
int width,
int height);
GdkKeymap * (*get_keymap) (GdkDisplay *display);
......@@ -228,10 +231,13 @@ void _gdk_display_event_data_copy (GdkDisplay *display
GdkEvent *new_event);
void _gdk_display_event_data_free (GdkDisplay *display,
GdkEvent *event);
void gdk_display_create_surface_impl (GdkDisplay *display,
GdkSurface *surface,
GdkSurface *real_parent);
GdkSurface * _gdk_display_create_surface (GdkDisplay *display);
GdkSurface * gdk_display_create_surface (GdkDisplay *display,
GdkSurfaceType surface_type,
GdkSurface *parent,
int x,
int y,
int width,
int height);
gboolean gdk_display_make_gl_context_current (GdkDisplay *display,
GdkGLContext *context);
......
......@@ -28,9 +28,9 @@
#define __GDK_INTERNALS_H__
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "gdksurfaceimpl.h"
#include "gdkdisplay.h"
#include "gdkeventsprivate.h"
#include "gdksurfaceprivate.h"
#include "gdkenumtypes.h"
#include "gdkdragprivate.h"
......@@ -116,79 +116,6 @@ typedef enum
typedef struct _GdkSurfacePaint GdkSurfacePaint;
struct _GdkSurface
{
GObject parent_instance;
GdkDisplay *display;
GdkSurfaceImpl *impl; /* window-system-specific delegate object */
GdkSurface *transient_for;
gpointer widget;
gint x;
gint y;
guint8 surface_type;
guint8 resize_count;
GdkGLContext *gl_paint_context;
cairo_region_t *update_area;
guint update_freeze_count;
/* This is the update_area that was in effect when the current expose
started. It may be smaller than the expose area if we'e painting
more than we have to, but it represents the "true" damage. */
cairo_region_t *active_update_area;
GdkSurfaceState old_state;
GdkSurfaceState state;
guint8 alpha;
guint8 fullscreen_mode;
guint modal_hint : 1;
guint destroyed : 2;
guint accept_focus : 1;
guint focus_on_map : 1;
guint support_multidevice : 1;
guint viewable : 1; /* mapped and all parents mapped */
guint in_update : 1;
guint frame_clock_events_paused : 1;
/* The GdkSurface that has the impl, ref:ed if another surface.
* This ref is required to keep the wrapper of the impl surface alive
* for as long as any GdkSurface references the impl. */
GdkSurface *impl_surface;
guint update_and_descendants_freeze_count;
gint width, height;
gint shadow_top;
gint shadow_left;
gint shadow_right;
gint shadow_bottom;
GdkCursor *cursor;
GHashTable *device_cursor;
cairo_region_t *input_shape;
GList *devices_inside;
GdkFrameClock *frame_clock; /* NULL to use from parent or default */
GSList *draw_contexts;
GdkDrawContext *paint_context;
cairo_region_t *opaque_region;
};
#define GDK_SURFACE_TYPE(d) ((((GdkSurface *)(d)))->surface_type)
#define GDK_SURFACE_DESTROYED(d) (((GdkSurface *)(d))->destroyed)
......
This diff is collapsed.
......@@ -411,21 +411,6 @@ typedef struct _GdkSurfaceClass GdkSurfaceClass;
#define GDK_SURFACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_SURFACE, GdkSurfaceClass))
struct _GdkSurfaceClass
{
GObjectClass parent_class;
/* Padding for future expansion */
void (*_gdk_reserved1) (void);
void (*_gdk_reserved2) (void);
void (*_gdk_reserved3) (void);
void (*_gdk_reserved4) (void);
void (*_gdk_reserved5) (void);
void (*_gdk_reserved6) (void);
void (*_gdk_reserved7) (void);
void (*_gdk_reserved8) (void);
};
/* Surfaces
*/
GDK_AVAILABLE_IN_ALL
......
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* 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/>.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include "config.h"
#include "gdksurfaceimpl.h"
#include "gdkinternals.h"
G_DEFINE_TYPE (GdkSurfaceImpl, gdk_surface_impl, G_TYPE_OBJECT);
static gboolean
gdk_surface_impl_beep (GdkSurface *surface)
{
/* FALSE means surfaces can't beep, so the display will be
* made to beep instead. */
return FALSE;
}
static GdkDisplay *
get_display_for_surface (GdkSurface *primary,
GdkSurface *secondary)
{
GdkDisplay *display = gdk_surface_get_display (primary);
if (display)
return display;
display = gdk_surface_get_display (secondary);
if (display)
return display;
g_warning ("no display for surface, using default");
return gdk_display_get_default ();
}
static GdkMonitor *
get_monitor_for_rect (GdkDisplay *display,
const GdkRectangle *rect)
{
gint biggest_area = G_MININT;
GdkMonitor *best_monitor = NULL;
GdkMonitor *monitor;
GdkRectangle workarea;
GdkRectangle intersection;
gint x;
gint y;
gint i;
for (i = 0; i < gdk_display_get_n_monitors (display); i++)
{
monitor = gdk_display_get_monitor (display, i);
gdk_monitor_get_workarea (monitor, &workarea);
if (gdk_rectangle_intersect (&workarea, rect, &intersection))
{
if (intersection.width * intersection.height > biggest_area)
{
biggest_area = intersection.width * intersection.height;
best_monitor = monitor;
}
}
}
if (best_monitor)
return best_monitor;
x = rect->x + rect->width / 2;
y = rect->y + rect->height / 2;
return gdk_display_get_monitor_at_point (display, x, y);
}
static gint
get_anchor_x_sign (GdkGravity anchor)
{
switch (anchor)
{
case GDK_GRAVITY_STATIC:
case GDK_GRAVITY_NORTH_WEST:
case GDK_GRAVITY_WEST:
case GDK_GRAVITY_SOUTH_WEST:
return -1;
default:
case GDK_GRAVITY_NORTH:
case GDK_GRAVITY_CENTER:
case GDK_GRAVITY_SOUTH:
return 0;
case GDK_GRAVITY_NORTH_EAST:
case GDK_GRAVITY_EAST:
case GDK_GRAVITY_SOUTH_EAST:
return 1;
}
}
static gint
get_anchor_y_sign (GdkGravity anchor)
{
switch (anchor)
{
case GDK_GRAVITY_STATIC:
case GDK_GRAVITY_NORTH_WEST:
case GDK_GRAVITY_NORTH:
case GDK_GRAVITY_NORTH_EAST:
return -1;
default:
case GDK_GRAVITY_WEST:
case GDK_GRAVITY_CENTER:
case GDK_GRAVITY_EAST:
return 0;
case GDK_GRAVITY_SOUTH_WEST:
case GDK_GRAVITY_SOUTH:
case GDK_GRAVITY_SOUTH_EAST:
return 1;
}
}
static gint
maybe_flip_position (gint bounds_pos,
gint bounds_size,
gint rect_pos,
gint rect_size,
gint surface_size,
gint rect_sign,
gint surface_sign,
gint offset,
gboolean flip,
gboolean *flipped)
{
gint primary;
gint secondary;
*flipped = FALSE;
primary = rect_pos + (1 + rect_sign) * rect_size / 2 + offset - (1 + surface_sign) * surface_size / 2;
if (!flip || (primary >= bounds_pos && primary + surface_size <= bounds_pos + bounds_size))
return primary;
*flipped = TRUE;
secondary = rect_pos + (1 - rect_sign) * rect_size / 2 - offset - (1 - surface_sign) * surface_size / 2;
if (secondary >= bounds_pos && secondary + surface_size <= bounds_pos + bounds_size)
return secondary;
*flipped = FALSE;
return primary;
}
static void
gdk_surface_impl_move_to_rect (GdkSurface *surface,
const GdkRectangle *rect,
GdkGravity rect_anchor,
GdkGravity surface_anchor,
GdkAnchorHints anchor_hints,
gint rect_anchor_dx,
gint rect_anchor_dy)
{
GdkSurface *transient_for_toplevel;
GdkDisplay *display;
GdkMonitor *monitor;
GdkRectangle bounds;
GdkRectangle root_rect = *rect;
GdkRectangle flipped_rect;
GdkRectangle final_rect;
gboolean flipped_x;
gboolean flipped_y;
/*
* First translate the anchor rect to toplevel coordinates. This is needed
* because not all backends will be able to get root coordinates for
* non-toplevel surfaces.
*/
transient_for_toplevel = surface->transient_for;
gdk_surface_get_root_coords (transient_for_toplevel,
root_rect.x,
root_rect.y,
&root_rect.x,
&root_rect.y);
display = get_display_for_surface (surface, surface->transient_for);
monitor = get_monitor_for_rect (display, &root_rect);
gdk_monitor_get_workarea (monitor, &bounds);
flipped_rect.width = surface->width - surface->shadow_left - surface->shadow_right;
flipped_rect.height = surface->height - surface->shadow_top - surface->shadow_bottom;
flipped_rect.x = maybe_flip_position (bounds.x,
bounds.width,
root_rect.x,
root_rect.width,
flipped_rect.width,
get_anchor_x_sign (rect_anchor),
get_anchor_x_sign (surface_anchor),
rect_anchor_dx,
anchor_hints & GDK_ANCHOR_FLIP_X,
&flipped_x);
flipped_rect.y = maybe_flip_position (bounds.y,
bounds.height,
root_rect.y,
root_rect.height,
flipped_rect.height,
get_anchor_y_sign (rect_anchor),
get_anchor_y_sign (surface_anchor),
rect_anchor_dy,
anchor_hints & GDK_ANCHOR_FLIP_Y,
&flipped_y);
final_rect = flipped_rect;
if (anchor_hints & GDK_ANCHOR_SLIDE_X)
{
if (final_rect.x + final_rect.width > bounds.x + bounds.width)
final_rect.x = bounds.x + bounds.width - final_rect.width;
if (final_rect.x < bounds.x)
final_rect.x = bounds.x;
}
if (anchor_hints & GDK_ANCHOR_SLIDE_Y)
{
if (final_rect.y + final_rect.height > bounds.y + bounds.height)
final_rect.y = bounds.y + bounds.height - final_rect.height;
if (final_rect.y < bounds.y)
final_rect.y = bounds.y;
}
if (anchor_hints & GDK_ANCHOR_RESIZE_X)
{
if (final_rect.x < bounds.x)
{
final_rect.width -= bounds.x - final_rect.x;
final_rect.x