gtk2/gdk/gdkwindowimpl.h
Jasper St. Pierre d48adf9cee gdkwindow: Remove the internal cairo_surface used for out-of-band painting
Traditionally, the way painting was done in GTK+ was with the
"expose-event" handler, where you'd use GDK methods to do drawing on
your surface. In GTK+ 2.24, we added cairo support with gdk_cairo_create,
so you could paint your graphics with cairo.

Since then, we've added client-side windows, double buffering, the paint
clock, and various other enhancements, and the modern way to do drawing
is to connect to the "draw" signal on GtkWidget, which hands you a
cairo_t. To do double-buffering, the cairo_t we hand you is actually on
a secret surface, not the actual backing store of the window, and when
the draw handler completes we blit it into the main backing store
atomically.

The code to do this is with the APIs gdk_window_begin_paint_region,
which creates the temporary surface, and gdk_window_end_paint which
blits it back into the backing store. GTK+'s implementation of the
"draw" signal uses these APIs.

We've always sort-of supported people calling gdk_cairo_create
"outside" of a begin_paint / end_paint like old times, but then you're
not getting the benefit of double-buffering, and it's harder for GDK to
optimize.

Additionally, newer backends like Mir and Wayland can't actually support
this model, since they're based on double-buffering and swapping buffers
at various points in time. If we hand you a random cairo_t, we have no
idea when is a good time to swap.

Remove support for this.

This is technically a GDK API break: a warning is added in cases where
gdk_cairo_create is called outside of a paint cycle, and the returned
surface is a dummy that won't ever be composited back onto the main
surface. Testing with complex applications like Ardour didn't produce
any warnings.
2014-06-20 20:41:54 -04:00

306 lines
15 KiB
C

/* 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/.
*/
#ifndef __GDK_WINDOW_IMPL_H__
#define __GDK_WINDOW_IMPL_H__
#include <gdk/gdkwindow.h>
#include <gdk/gdkproperty.h>
G_BEGIN_DECLS
#define GDK_TYPE_WINDOW_IMPL (gdk_window_impl_get_type ())
#define GDK_WINDOW_IMPL(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WINDOW_IMPL, GdkWindowImpl))
#define GDK_WINDOW_IMPL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WINDOW_IMPL, GdkWindowImplClass))
#define GDK_IS_WINDOW_IMPL(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WINDOW_IMPL))
#define GDK_IS_WINDOW_IMPL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WINDOW_IMPL))
#define GDK_WINDOW_IMPL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WINDOW_IMPL, GdkWindowImplClass))
typedef struct _GdkWindowImpl GdkWindowImpl;
typedef struct _GdkWindowImplClass GdkWindowImplClass;
struct _GdkWindowImpl
{
GObject parent;
};
struct _GdkWindowImplClass
{
GObjectClass parent_class;
cairo_surface_t *
(* ref_cairo_surface) (GdkWindow *window);
cairo_surface_t *
(* create_similar_image_surface) (GdkWindow * window,
cairo_format_t format,
int width,
int height);
void (* show) (GdkWindow *window,
gboolean already_mapped);
void (* hide) (GdkWindow *window);
void (* withdraw) (GdkWindow *window);
void (* raise) (GdkWindow *window);
void (* lower) (GdkWindow *window);
void (* restack_under) (GdkWindow *window,
GList *native_siblings);
void (* restack_toplevel) (GdkWindow *window,
GdkWindow *sibling,
gboolean above);
void (* move_resize) (GdkWindow *window,
gboolean with_move,
gint x,
gint y,
gint width,
gint height);
void (* set_background) (GdkWindow *window,
cairo_pattern_t *pattern);
GdkEventMask (* get_events) (GdkWindow *window);
void (* set_events) (GdkWindow *window,
GdkEventMask event_mask);
gboolean (* reparent) (GdkWindow *window,
GdkWindow *new_parent,
gint x,
gint y);
void (* set_device_cursor) (GdkWindow *window,
GdkDevice *device,
GdkCursor *cursor);
void (* get_geometry) (GdkWindow *window,
gint *x,
gint *y,
gint *width,
gint *height);
void (* get_root_coords) (GdkWindow *window,
gint x,
gint y,
gint *root_x,
gint *root_y);
gboolean (* get_device_state) (GdkWindow *window,
GdkDevice *device,
gdouble *x,
gdouble *y,
GdkModifierType *mask);
gboolean (* begin_paint_region) (GdkWindow *window,
const cairo_region_t *region);
void (* end_paint) (GdkWindow *window);
cairo_region_t * (* get_shape) (GdkWindow *window);
cairo_region_t * (* get_input_shape) (GdkWindow *window);
void (* shape_combine_region) (GdkWindow *window,
const cairo_region_t *shape_region,
gint offset_x,
gint offset_y);
void (* input_shape_combine_region) (GdkWindow *window,
const cairo_region_t *shape_region,
gint offset_x,
gint offset_y);
gboolean (* set_static_gravities) (GdkWindow *window,
gboolean use_static);
/* Called before processing updates for a window. This gives the windowing
* layer a chance to save the region for later use in avoiding duplicate
* exposes. The return value indicates whether the function has a saved
* the region; if the result is TRUE, then the windowing layer is responsible
* for destroying the region later.
*/
gboolean (* queue_antiexpose) (GdkWindow *window,
cairo_region_t *update_area);
/* Called to do the windowing system specific part of gdk_window_destroy(),
*
* window: The window being destroyed
* recursing: If TRUE, then this is being called because a parent
* was destroyed. This generally means that the call to the windowing
* system to destroy the window can be omitted, since it will be
* destroyed as a result of the parent being destroyed.
* Unless @foreign_destroy
* foreign_destroy: If TRUE, the window or a parent was destroyed by some
* external agency. The window has already been destroyed and no
* windowing system calls should be made. (This may never happen
* for some windowing systems.)
*/
void (* destroy) (GdkWindow *window,
gboolean recursing,
gboolean foreign_destroy);
/* Called when gdk_window_destroy() is called on a foreign window
* or an ancestor of the foreign window. It should generally reparent
* the window out of it's current heirarchy, hide it, and then
* send a message to the owner requesting that the window be destroyed.
*/
void (*destroy_foreign) (GdkWindow *window);
/* optional */
gboolean (* beep) (GdkWindow *window);
void (* focus) (GdkWindow *window,
guint32 timestamp);
void (* set_type_hint) (GdkWindow *window,
GdkWindowTypeHint hint);
GdkWindowTypeHint (* get_type_hint) (GdkWindow *window);
void (* set_modal_hint) (GdkWindow *window,
gboolean modal);
void (* set_skip_taskbar_hint) (GdkWindow *window,
gboolean skips_taskbar);
void (* set_skip_pager_hint) (GdkWindow *window,
gboolean skips_pager);
void (* set_urgency_hint) (GdkWindow *window,
gboolean urgent);
void (* set_geometry_hints) (GdkWindow *window,
const GdkGeometry *geometry,
GdkWindowHints geom_mask);
void (* set_title) (GdkWindow *window,
const gchar *title);
void (* set_role) (GdkWindow *window,
const gchar *role);
void (* set_startup_id) (GdkWindow *window,
const gchar *startup_id);
void (* set_transient_for) (GdkWindow *window,
GdkWindow *parent);
void (* get_frame_extents) (GdkWindow *window,
GdkRectangle *rect);
void (* set_override_redirect) (GdkWindow *window,
gboolean override_redirect);
void (* set_accept_focus) (GdkWindow *window,
gboolean accept_focus);
void (* set_focus_on_map) (GdkWindow *window,
gboolean focus_on_map);
void (* set_icon_list) (GdkWindow *window,
GList *pixbufs);
void (* set_icon_name) (GdkWindow *window,
const gchar *name);
void (* iconify) (GdkWindow *window);
void (* deiconify) (GdkWindow *window);
void (* stick) (GdkWindow *window);
void (* unstick) (GdkWindow *window);
void (* maximize) (GdkWindow *window);
void (* unmaximize) (GdkWindow *window);
void (* fullscreen) (GdkWindow *window);
void (* apply_fullscreen_mode) (GdkWindow *window);
void (* unfullscreen) (GdkWindow *window);
void (* set_keep_above) (GdkWindow *window,
gboolean setting);
void (* set_keep_below) (GdkWindow *window,
gboolean setting);
GdkWindow * (* get_group) (GdkWindow *window);
void (* set_group) (GdkWindow *window,
GdkWindow *leader);
void (* set_decorations) (GdkWindow *window,
GdkWMDecoration decorations);
gboolean (* get_decorations) (GdkWindow *window,
GdkWMDecoration *decorations);
void (* set_functions) (GdkWindow *window,
GdkWMFunction functions);
void (* begin_resize_drag) (GdkWindow *window,
GdkWindowEdge edge,
GdkDevice *device,
gint button,
gint root_x,
gint root_y,
guint32 timestamp);
void (* begin_move_drag) (GdkWindow *window,
GdkDevice *device,
gint button,
gint root_x,
gint root_y,
guint32 timestamp);
void (* enable_synchronized_configure) (GdkWindow *window);
void (* configure_finished) (GdkWindow *window);
void (* set_opacity) (GdkWindow *window,
gdouble opacity);
void (* set_composited) (GdkWindow *window,
gboolean composited);
void (* destroy_notify) (GdkWindow *window);
GdkDragProtocol (* get_drag_protocol) (GdkWindow *window,
GdkWindow **target);
void (* register_dnd) (GdkWindow *window);
GdkDragContext * (*drag_begin) (GdkWindow *window,
GdkDevice *device,
GList *targets);
void (*process_updates_recurse) (GdkWindow *window,
cairo_region_t *region);
void (*sync_rendering) (GdkWindow *window);
gboolean (*simulate_key) (GdkWindow *window,
gint x,
gint y,
guint keyval,
GdkModifierType modifiers,
GdkEventType event_type);
gboolean (*simulate_button) (GdkWindow *window,
gint x,
gint y,
guint button,
GdkModifierType modifiers,
GdkEventType event_type);
gboolean (*get_property) (GdkWindow *window,
GdkAtom property,
GdkAtom type,
gulong offset,
gulong length,
gint pdelete,
GdkAtom *actual_type,
gint *actual_format,
gint *actual_length,
guchar **data);
void (*change_property) (GdkWindow *window,
GdkAtom property,
GdkAtom type,
gint format,
GdkPropMode mode,
const guchar *data,
gint n_elements);
void (*delete_property) (GdkWindow *window,
GdkAtom property);
gint (* get_scale_factor) (GdkWindow *window);
void (* set_opaque_region) (GdkWindow *window,
cairo_region_t *region);
void (* set_shadow_width) (GdkWindow *window,
gint left,
gint right,
gint top,
gint bottom);
gboolean (* show_window_menu) (GdkWindow *window,
GdkEvent *event);
};
/* Interface Functions */
GType gdk_window_impl_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* __GDK_WINDOW_IMPL_H__ */