gtk2/gdk/gdkdisplayprivate.h

311 lines
17 KiB
C
Raw Normal View History

/* GDK - The GIMP Drawing Kit
* Copyright (C) 2010 Red Hat, Inc.
*
* 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
2012-02-27 13:01:10 +00:00
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GDK_DISPLAY_PRIVATE_H__
#define __GDK_DISPLAY_PRIVATE_H__
#include "gdkdisplay.h"
2010-12-16 00:07:36 +00:00
#include "gdkwindow.h"
#include "gdkcursor.h"
#include "gdkmonitor.h"
#include "gdkinternals.h"
#ifdef GDK_RENDERING_VULKAN
#include <vulkan/vulkan.h>
#endif
G_BEGIN_DECLS
#define GDK_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DISPLAY, GdkDisplayClass))
#define GDK_IS_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_DISPLAY))
#define GDK_DISPLAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_DISPLAY, GdkDisplayClass))
typedef struct _GdkDisplayClass GdkDisplayClass;
/* Tracks information about the device grab on this display */
typedef struct
{
GdkWindow *window;
GdkWindow *native_window;
gulong serial_start;
gulong serial_end; /* exclusive, i.e. not active on serial_end */
guint event_mask;
guint32 time;
GdkGrabOwnership ownership;
guint activated : 1;
guint implicit_ungrab : 1;
guint owner_events : 1;
guint implicit : 1;
} GdkDeviceGrabInfo;
/* Tracks information about which window and position the pointer last was in.
* This is useful when we need to synthesize events later.
* Note that we track toplevel_under_pointer using enter/leave events,
* so in the case of a grab, either with owner_events==FALSE or with the
* pointer in no clients window the x/y coordinates may actually be outside
* the window.
*/
typedef struct
{
GdkWindow *window_under_pointer; /* window that last got a normal enter event */
gdouble toplevel_x, toplevel_y;
guint32 state;
guint32 button;
GdkDevice *last_slave;
} GdkPointerWindowInfo;
struct _GdkDisplay
{
GObject parent_instance;
GList *queued_events;
GList *queued_tail;
guint event_pause_count; /* How many times events are blocked */
guint closed : 1; /* Whether this display has been closed */
GHashTable *device_grabs;
GdkDeviceManager *device_manager;
GHashTable *pointers_info; /* GdkPointerWindowInfo for each device */
guint32 last_event_time; /* Last reported event time from server */
guint double_click_time; /* Maximum time between clicks in msecs */
guint double_click_distance; /* Maximum distance between clicks in pixels */
#ifdef GDK_RENDERING_VULKAN
VkInstance vk_instance;
VkDebugReportCallbackEXT vk_debug_callback;
VkPhysicalDevice vk_physical_device;
VkDevice vk_device;
VkQueue vk_queue;
uint32_t vk_queue_family_index;
guint vulkan_refcount;
#endif /* GDK_RENDERING_VULKAN */
guint rgba : 1;
guint composited : 1;
GdkRenderingMode rendering_mode;
GList *seats;
};
struct _GdkDisplayClass
{
GObjectClass parent_class;
GType window_type; /* type for native windows for this display, set in class_init */
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 */
2011-06-06 18:05:18 +00:00
const gchar * (*get_name) (GdkDisplay *display);
void (*beep) (GdkDisplay *display);
void (*sync) (GdkDisplay *display);
void (*flush) (GdkDisplay *display);
gboolean (*has_pending) (GdkDisplay *display);
void (*queue_events) (GdkDisplay *display);
void (*make_default) (GdkDisplay *display);
GdkWindow * (*get_default_group) (GdkDisplay *display);
gboolean (*supports_selection_notification) (GdkDisplay *display);
gboolean (*request_selection_notification) (GdkDisplay *display,
GdkAtom selection);
gboolean (*supports_shapes) (GdkDisplay *display);
gboolean (*supports_input_shapes) (GdkDisplay *display);
gboolean (*supports_cursor_alpha) (GdkDisplay *display);
gboolean (*supports_cursor_color) (GdkDisplay *display);
gboolean (*supports_clipboard_persistence) (GdkDisplay *display);
void (*store_clipboard) (GdkDisplay *display,
GdkWindow *clipboard_window,
guint32 time_,
const GdkAtom *targets,
gint n_targets);
void (*get_default_cursor_size) (GdkDisplay *display,
guint *width,
guint *height);
void (*get_maximal_cursor_size) (GdkDisplay *display,
guint *width,
guint *height);
GdkAppLaunchContext * (*get_app_launch_context) (GdkDisplay *display);
gulong (*get_next_serial) (GdkDisplay *display);
void (*notify_startup_complete) (GdkDisplay *display,
const gchar *startup_id);
void (*event_data_copy) (GdkDisplay *display,
const GdkEvent *event,
GdkEvent *new_event);
void (*event_data_free) (GdkDisplay *display,
GdkEvent *event);
2010-12-16 00:07:36 +00:00
void (*create_window_impl) (GdkDisplay *display,
GdkWindow *window,
GdkWindow *real_parent,
GdkEventMask event_mask,
GdkWindowAttr *attributes);
GdkKeymap * (*get_keymap) (GdkDisplay *display);
2010-12-16 06:21:49 +00:00
void (*push_error_trap) (GdkDisplay *display);
gint (*pop_error_trap) (GdkDisplay *display,
gboolean ignore);
2010-12-17 00:22:44 +00:00
GdkWindow * (*get_selection_owner) (GdkDisplay *display,
GdkAtom selection);
gboolean (*set_selection_owner) (GdkDisplay *display,
GdkWindow *owner,
GdkAtom selection,
guint32 time,
gboolean send_event);
void (*send_selection_notify) (GdkDisplay *dispay,
GdkWindow *requestor,
GdkAtom selection,
GdkAtom target,
GdkAtom property,
2010-12-17 01:25:32 +00:00
guint32 time);
gint (*get_selection_property) (GdkDisplay *display,
GdkWindow *requestor,
guchar **data,
GdkAtom *type,
gint *format);
void (*clear_selection_targets)(GdkDisplay *display,
GdkAtom selection);
void (*add_selection_targets) (GdkDisplay *display,
GdkWindow *window,
GdkAtom selection,
GdkAtom *targets,
guint ntargets);
2010-12-17 01:25:32 +00:00
void (*convert_selection) (GdkDisplay *display,
GdkWindow *requestor,
GdkAtom selection,
GdkAtom target,
guint32 time);
2010-12-17 00:22:44 +00:00
gint (*text_property_to_utf8_list) (GdkDisplay *display,
GdkAtom encoding,
gint format,
const guchar *text,
gint length,
gchar ***list);
gchar * (*utf8_to_string_target) (GdkDisplay *display,
const gchar *text);
gboolean (*make_gl_context_current) (GdkDisplay *display,
GdkGLContext *context);
gdk: Add support for OpenGL This adds the new type GdkGLContext that wraps an OpenGL context for a particular native window. It also adds support for the gdk paint machinery to use OpenGL to draw everything. As soon as anyone creates a GL context for a native window we create a "paint context" for that GdkWindow and switch to using GL for painting it. This commit contains only an implementation for X11 (using GLX). The way painting works is that all client gl contexts draw into offscreen buffers rather than directly to the back buffer, and the way something gets onto the window is by using gdk_cairo_draw_from_gl() to draw part of that buffer onto the draw cairo context. As a fallback (if we're doing redirected drawing or some effect like a cairo_push_group()) we read back the gl buffer into memory and composite using cairo. This means that GL rendering works in all cases, including rendering to a PDF. However, this is not particularly fast. In the *typical* case, where we're drawing directly to the window in the regular paint loop we hit the fast path. The fast path uses opengl to draw the buffer to the window back buffer, either by blitting or texturing. Then we track the region that was drawn, and when the draw ends we paint the normal cairo surface to the window (using texture-from-pixmap in the X11 case, or texture from cairo image otherwise) in the regions where there is no gl painted. There are some complexities wrt layering of gl and cairo areas though: * We track via gdk_window_mark_paint_from_clip() whenever gtk is painting over a region we previously rendered with opengl (flushed_region). This area (needs_blend_region) is blended rather than copied at the end of the frame. * If we're drawing a gl texture with alpha we first copy the current cairo_surface inside the target region to the back buffer before we blend over it. These two operations allow us full stacking of transparent gl and cairo regions.
2014-10-09 08:45:44 +00:00
GdkSeat * (*get_default_seat) (GdkDisplay *display);
int (*get_n_monitors) (GdkDisplay *display);
GdkMonitor * (*get_monitor) (GdkDisplay *display,
int index);
GdkMonitor * (*get_primary_monitor) (GdkDisplay *display);
GdkMonitor * (*get_monitor_at_window) (GdkDisplay *display,
GdkWindow *window);
gboolean (*get_setting) (GdkDisplay *display,
const char *name,
GValue *value);
/* Signals */
void (*opened) (GdkDisplay *display);
void (*closed) (GdkDisplay *display,
gboolean is_error);
};
typedef void (* GdkDisplayPointerInfoForeach) (GdkDisplay *display,
GdkDevice *device,
GdkPointerWindowInfo *device_info,
gpointer user_data);
void _gdk_display_update_last_event (GdkDisplay *display,
const GdkEvent *event);
void _gdk_display_device_grab_update (GdkDisplay *display,
GdkDevice *device,
GdkDevice *source_device,
gulong current_serial);
GdkDeviceGrabInfo * _gdk_display_get_last_device_grab (GdkDisplay *display,
GdkDevice *device);
GdkDeviceGrabInfo * _gdk_display_add_device_grab (GdkDisplay *display,
GdkDevice *device,
GdkWindow *window,
GdkWindow *native_window,
GdkGrabOwnership grab_ownership,
gboolean owner_events,
GdkEventMask event_mask,
gulong serial_start,
guint32 time,
gboolean implicit);
GdkDeviceGrabInfo * _gdk_display_has_device_grab (GdkDisplay *display,
GdkDevice *device,
gulong serial);
gboolean _gdk_display_end_device_grab (GdkDisplay *display,
GdkDevice *device,
gulong serial,
GdkWindow *if_child,
gboolean implicit);
gboolean _gdk_display_check_grab_ownership (GdkDisplay *display,
GdkDevice *device,
gulong serial);
GdkPointerWindowInfo * _gdk_display_get_pointer_info (GdkDisplay *display,
GdkDevice *device);
void _gdk_display_pointer_info_foreach (GdkDisplay *display,
GdkDisplayPointerInfoForeach func,
gpointer user_data);
gulong _gdk_display_get_next_serial (GdkDisplay *display);
void _gdk_display_pause_events (GdkDisplay *display);
void _gdk_display_unpause_events (GdkDisplay *display);
void _gdk_display_event_data_copy (GdkDisplay *display,
const GdkEvent *event,
GdkEvent *new_event);
void _gdk_display_event_data_free (GdkDisplay *display,
GdkEvent *event);
2010-12-16 00:07:36 +00:00
void _gdk_display_create_window_impl (GdkDisplay *display,
GdkWindow *window,
GdkWindow *real_parent,
GdkEventMask event_mask,
GdkWindowAttr *attributes);
GdkWindow * _gdk_display_create_window (GdkDisplay *display);
gboolean gdk_display_make_gl_context_current (GdkDisplay *display,
gdk: Add support for OpenGL This adds the new type GdkGLContext that wraps an OpenGL context for a particular native window. It also adds support for the gdk paint machinery to use OpenGL to draw everything. As soon as anyone creates a GL context for a native window we create a "paint context" for that GdkWindow and switch to using GL for painting it. This commit contains only an implementation for X11 (using GLX). The way painting works is that all client gl contexts draw into offscreen buffers rather than directly to the back buffer, and the way something gets onto the window is by using gdk_cairo_draw_from_gl() to draw part of that buffer onto the draw cairo context. As a fallback (if we're doing redirected drawing or some effect like a cairo_push_group()) we read back the gl buffer into memory and composite using cairo. This means that GL rendering works in all cases, including rendering to a PDF. However, this is not particularly fast. In the *typical* case, where we're drawing directly to the window in the regular paint loop we hit the fast path. The fast path uses opengl to draw the buffer to the window back buffer, either by blitting or texturing. Then we track the region that was drawn, and when the draw ends we paint the normal cairo surface to the window (using texture-from-pixmap in the X11 case, or texture from cairo image otherwise) in the regions where there is no gl painted. There are some complexities wrt layering of gl and cairo areas though: * We track via gdk_window_mark_paint_from_clip() whenever gtk is painting over a region we previously rendered with opengl (flushed_region). This area (needs_blend_region) is blended rather than copied at the end of the frame. * If we're drawing a gl texture with alpha we first copy the current cairo_surface inside the target region to the back buffer before we blend over it. These two operations allow us full stacking of transparent gl and cairo regions.
2014-10-09 08:45:44 +00:00
GdkGLContext *context);
void gdk_display_set_rgba (GdkDisplay *display,
gboolean rgba);
void gdk_display_set_composited (GdkDisplay *display,
gboolean composited);
void gdk_display_add_seat (GdkDisplay *display,
GdkSeat *seat);
void gdk_display_remove_seat (GdkDisplay *display,
GdkSeat *seat);
void gdk_display_monitor_added (GdkDisplay *display,
GdkMonitor *monitor);
void gdk_display_monitor_removed (GdkDisplay *display,
GdkMonitor *monitor);
void gdk_display_emit_opened (GdkDisplay *display);
void gdk_display_setting_changed (GdkDisplay *display,
const char *name);
G_END_DECLS
#endif /* __GDK_DISPLAY_PRIVATE_H__ */