2008-07-01 22:57:50 +00:00
|
|
|
|
/* GDK - The GIMP Drawing Kit
|
1998-12-15 13:54:20 +00:00
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2000-07-26 11:33:08 +00:00
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
1998-12-15 13:54:20 +00:00
|
|
|
|
* 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
|
2000-07-26 11:33:08 +00:00
|
|
|
|
* Lesser General Public License for more details.
|
1998-12-15 13:54:20 +00:00
|
|
|
|
*
|
2000-07-26 11:33:08 +00:00
|
|
|
|
* 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/>.
|
1998-12-15 13:54:20 +00:00
|
|
|
|
*/
|
|
|
|
|
|
1999-02-24 07:37:18 +00:00
|
|
|
|
/*
|
2000-07-26 11:33:08 +00:00
|
|
|
|
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
1999-02-24 07:37:18 +00:00
|
|
|
|
* 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/.
|
|
|
|
|
*/
|
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
|
#include "config.h"
|
2002-10-03 20:53:30 +00:00
|
|
|
|
|
2017-10-25 13:46:47 +00:00
|
|
|
|
#include "gdkintl.h"
|
2017-08-05 13:34:39 +00:00
|
|
|
|
#include "gdkeventsprivate.h"
|
2000-03-28 01:24:44 +00:00
|
|
|
|
#include "gdkinternals.h"
|
2010-12-11 05:14:53 +00:00
|
|
|
|
#include "gdkdisplayprivate.h"
|
2018-07-02 11:39:09 +00:00
|
|
|
|
#include "gdkdragprivate.h"
|
2018-05-22 13:32:27 +00:00
|
|
|
|
#include "gdkdropprivate.h"
|
2017-08-16 08:37:17 +00:00
|
|
|
|
#include "gdk-private.h"
|
2010-07-09 00:34:45 +00:00
|
|
|
|
|
2010-10-15 02:05:51 +00:00
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <math.h>
|
1998-12-24 19:39:00 +00:00
|
|
|
|
|
2010-11-15 18:15:00 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* SECTION:events
|
|
|
|
|
* @Short_description: Functions for handling events from the window system
|
|
|
|
|
* @Title: Events
|
|
|
|
|
*
|
|
|
|
|
* This section describes functions dealing with events from the window
|
|
|
|
|
* system.
|
|
|
|
|
*
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* In GTK applications the events are handled automatically by toplevel
|
|
|
|
|
* widgets and passed on to the event controllers of appropriate widgets,
|
|
|
|
|
* so these functions are rarely needed.
|
2010-11-15 18:15:00 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2017-12-26 19:39:24 +00:00
|
|
|
|
/**
|
|
|
|
|
* GdkEvent:
|
|
|
|
|
*
|
|
|
|
|
* The GdkEvent struct contains only private fields and
|
|
|
|
|
* should not be accessed directly.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GdkEventSequence:
|
|
|
|
|
*
|
|
|
|
|
* GdkEventSequence is an opaque type representing a sequence
|
|
|
|
|
* of related touch events.
|
|
|
|
|
*/
|
2010-11-15 18:15:00 +00:00
|
|
|
|
|
2017-10-25 13:46:47 +00:00
|
|
|
|
|
2020-02-15 20:40:03 +00:00
|
|
|
|
G_DEFINE_BOXED_TYPE (GdkEvent, gdk_event,
|
|
|
|
|
gdk_event_ref,
|
|
|
|
|
gdk_event_unref)
|
2017-10-25 11:23:41 +00:00
|
|
|
|
|
2020-02-20 22:13:21 +00:00
|
|
|
|
static gboolean
|
2019-05-01 20:39:00 +00:00
|
|
|
|
check_event_sanity (GdkEvent *event)
|
2010-12-02 09:59:37 +00:00
|
|
|
|
{
|
2020-02-20 22:13:21 +00:00
|
|
|
|
if (event->any.device != NULL &&
|
|
|
|
|
gdk_surface_get_display (event->any.surface) != gdk_device_get_display (event->any.device))
|
2019-05-01 20:39:00 +00:00
|
|
|
|
{
|
|
|
|
|
char *type = g_enum_to_string (GDK_TYPE_EVENT_TYPE, event->any.type);
|
2020-02-20 22:13:21 +00:00
|
|
|
|
g_warning ("Event of type %s with mismatched device display", type);
|
2019-05-01 20:39:00 +00:00
|
|
|
|
g_free (type);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-20 22:13:21 +00:00
|
|
|
|
if (event->any.source_device != NULL &&
|
|
|
|
|
gdk_surface_get_display (event->any.surface) != gdk_device_get_display (event->any.source_device))
|
2019-05-01 20:39:00 +00:00
|
|
|
|
{
|
|
|
|
|
char *type = g_enum_to_string (GDK_TYPE_EVENT_TYPE, event->any.type);
|
2020-02-20 22:13:21 +00:00
|
|
|
|
g_warning ("Event of type %s with mismatched source device display", type);
|
2019-05-01 20:39:00 +00:00
|
|
|
|
g_free (type);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
_gdk_event_emit (GdkEvent *event)
|
|
|
|
|
{
|
|
|
|
|
if (!check_event_sanity (event))
|
|
|
|
|
return;
|
|
|
|
|
|
2018-06-29 17:34:14 +00:00
|
|
|
|
if (gdk_drag_handle_source_event (event))
|
2016-01-08 20:22:47 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2019-02-23 18:56:51 +00:00
|
|
|
|
gdk_surface_handle_event (event);
|
2010-12-02 09:59:37 +00:00
|
|
|
|
}
|
1998-12-15 13:54:20 +00:00
|
|
|
|
|
1999-01-12 23:27:30 +00:00
|
|
|
|
/*********************************************
|
|
|
|
|
* Functions for maintaining the event queue *
|
|
|
|
|
*********************************************/
|
|
|
|
|
|
2002-04-25 22:29:14 +00:00
|
|
|
|
/**
|
Make gdkx.h the only installed header from gdk/x11. All structures in
Fri Sep 7 11:51:44 2001 Owen Taylor <otaylor@redhat.com>
Make gdkx.h the only installed header from gdk/x11.
All structures in gdk/x11 are opaque.
* gdk/x11/Makefile.am gdk/x11/gdkx.h gdk/x11/gdkprivate-x11.h:
Don't install gdk{drawable,pixmap,window}-x11.h.
* gdk/x11/{gdkcolormap-x11.c, gdkfont-x11.c, gdkx.h, gdkvisual-x11.c:
Move GdkColormapPrivateX11, GdkFontPrivateX GdkImagePrivateX11,
GdkVisualClass into C files.
* gdk/gdkpixmap-x11.[ch]: Make gdk_pixmap_impl_get_type() static.
* gdk/x11/{gdkcolor-x11.c, gdkcursor-x11.c, gdkdrawable-x11.c,
gdkfont-x11.c, gdkgc-x11.c, gdkx.h, gdkimage-x11,gdkvisual-x11.c}
Add public functions to replace previously exported direct
structure access.
gdk_x11_colormap_get_{xdisplay,xcolormap}
gdk_x11_cursor_get_{xdisplay,xcursor},
gdk_x11_drawable_get_{xdisplay,xcursor,gdk_x11_visual_get_xvisual,
gdk_x11_font_get_{xdisplay,xfont}, gdk_x11_image_get_{xdisplay,ximage},
gdk_x11_gc_get_{xdisplay,ximage}
* gdk/gdkprivate.h gdk/gdkinternals.h: Move GdkColorInfo,
GdkEventFilter, GdkClientFilter, GdkFontPrivate to gdkinternals.
Fix a number of variables and functions that were exported
"accidentally" from GDK.
* gdk/**.[ch]: gdk => _gdk for gdk_visual_init,
gdk_events_init, gdk_input_init, gdk_dnd_init, gdk_image_exit,
gdk_input_exit, gdk_windowing_exit, gdk_event_func, gdk_event_data,
gdk_event_notify, gdk_queued_events, gdk_queued_tail,
gdk_event_new, gdk_events_queue, gdk_events_unqueue,
gdk_event_queue_find_first, gdk_event_queue_remove_link,
gdk_event_queue_append, gdk_event_button_generate,
gdk_debug_flags, gdk_default_filters, gdk_parent_root.
* gdk/x11/{gdkevents-x11.c, gdkglobals-x11.c, gdkimage-x11.c,
gdkmain-x11.c, gdkprivate-x11.h, gdk/x11/gdkwindow-x11.c}:
gdk => _gdk for gdk_event_mask_table, gkd_nevent_masks,
gdk_wm_window_protocols, gdk_leader_window, gdk_xgrab_window,
gdk_use_xshm, gdk_input_ignore_core.
* gdk/x11/xsettings-common.h (xsettings_list_insert): Add
#defines to namespace functions into the private _gdk_
namespace.
* gdk/gdkwindow.[ch] gdk/x11/gdkx.h: Add gdk_get_default_root_window ()
to replace gdk_parent_root exported variable. Adjust and
deprecate GDK_ROOT_PARENT().
* demos/{testpixbuf-drawable.c,testpixbuf-save.c}: Fix
GDK_ROOT_PARENT usage, remove includes of port-specific
headers.
* gdk/{win32,x11,fb}/gdkinput*.[ch]: s/gdk/_gdk/ for
_gdk_input_gxid_host, _gdk_input_gxid_port, _gdk_input_ignore_core,
gdk_input_devices, _gdk_input_windows, gdk_init_input_core.
* gdk/x11/{gdkevents-x11.,c gdkglobals-x11.c, gdkmain-x11.c}
docs/Changes-2.0.txt: Remove gdk_wm_protocols,
gdk_wm_delete_window functions, gdk_wm_take_focus,
use gdk_atom_intern() instead.
* gdk/linux-fb/{gdkselection-fb.c, gdkmain-fb.c, gdkprivatefb.h}
gdk/win32/{gdkselection-win32.c, gdkmgdkwin32.h, gdkprivate-win32.h}
gdk/x11/{gdkselection-x11.c gdkx.h, gtkprivate-x11.h}
gtk/gtkselection.c
Unexport gdk_selection_property, just use
gdk_atom_intern ("GDK_SELECTION").
* gdk/x11/{gdkprivate-x11.h,gdkdrawable-x11h,gdkgc-x11.c,gdkx.h}:
Unexport gdk_drawable_impl_x11_get_type, gdk_gc_x11_get_type,
GDK_GC_X11 cast macros, GdkGCX11 structures, GdkCursorPrivate,
GdkVisualprivate, gdk_x11_gc_flush.
Make a number of public exports of variables into functions
to increase encapsulation.
* gdk/gdkinternals.h gdk/gdkinput.h gdk/gdkevents.h
gdk/linux-fb/gdkmouse-fb.c: gdk_core_pointer => _gdk_core_pointer,
move to gdkinternals.h. Add gdk_device_get_core_pointer ().
* gdk/gdkprivate.h gdk/gdkpango.c gdk/gdkinternals.h
docs/Changes-2.0.txt: Unexport gdk_parent_root, gdk_error_code,
gdk_error_warnings.
* gdk/x11/{gdkcolormap-x11.c, gdkmain-x11.c, gdkx.h}
docs/Changes-2.0.txt:
s/gdk_screen/_gdk_screen/, add gdk_x11_get_default_screen()
s/gdk_root_window/_gdk_root_window/, add gdk_x11_get_default_root_xwindow()
Add gdk_x11_get_default_xdisplay().
* gdk/gdk.h gdk/gdk.c linux-fb/gdkfb.h linux-fb/gdkglobals-fb.c
win32/gdkwin32.h x11/gdkglobals-x11.c gdk/x11/gdkmain-x11.c
gdk/x11/gdkx.h: gdk/gdk.def: Add gdk_get/set_program_class,
Don't export gdk_progclass, move --class command line
option and handling to common portion of GDK.
Miscellaneous fixes:
* gdk/x11/gdkwindow-x11.c (gdk_window_set_icon_list): Fix
g_return_val_if_fail that should have been g_return_if_fail.
* gdk/gdkinternals.h gdk/gdkprivate.h: Move
gdk_synthesize_window_state() to the semi-public gdkprivate.h.
* gtk/gtkdnd.c (_gtk_drag_source_handle_event): Remove uneeded
X11 dependency.
* gdk/linux-fb/gdkmain-fb.c gdk/win32/gdkmain-win32.c gdk/TODO:
Remove unused gdk_key_repeat_disable/restore.
* linux-fb/gdkglobals-fb.c win32/gdkglobals-win32.c
x11/gdkglobals-x11.c x11/gdkprivate-x11.h gdk/gdk.def:
Remove unused gdk_null_window_warnings variable.
* gdk/Makefile.am (DIST_SUBDIRS) nanox/*: cvs remove nanox;
it can be retrieved from the repository; it is too far
from functional to be worth having people check out;
it would be easier to start from scratch, I suspect.
* gdk/x11/gdkpixmap-x11.c: Fix lvalue usage of GDK_PIXMAP_XID().
* gdk/x11/gdkkeys-x11.c gdk/gdkrgb.c gdk/gdkwindow.c
gdk/x11/gdkpango-x11.c gdk/x11/gdkselection-x11.c:
Fix some accidentally global variables and unused global variables.
* gdk/x11/gdkkeys-x11.c gdk/gdkrgb.c gdk/gdkwindow.c
gdk/x11/gdkpango-x11.c gdk/x11/gdkselection-x11.c:
Fix some accidentally global variables and unused global variables.
Add some space for future expansion to multihead.
* gdk/gdkdrawable.h: Add four reserved function pointers
for future expansion of GdkDrawableClass.
* gtk/gtkwindow.h gtk/gtkinvisible.h: Add reserved pointer
where we can put a GdkScreen * later.
2001-09-07 21:50:20 +00:00
|
|
|
|
* _gdk_event_queue_find_first:
|
2002-04-25 22:29:14 +00:00
|
|
|
|
* @display: a #GdkDisplay
|
|
|
|
|
*
|
|
|
|
|
* Find the first event on the queue that is not still
|
|
|
|
|
* being filled in.
|
|
|
|
|
*
|
2014-05-08 19:55:50 +00:00
|
|
|
|
* Returns: (nullable): Pointer to the list node for that event, or
|
|
|
|
|
* %NULL.
|
2002-04-25 22:29:14 +00:00
|
|
|
|
**/
|
1999-11-08 20:14:59 +00:00
|
|
|
|
GList*
|
2002-04-25 22:29:14 +00:00
|
|
|
|
_gdk_event_queue_find_first (GdkDisplay *display)
|
1999-01-12 23:27:30 +00:00
|
|
|
|
{
|
2012-09-26 14:28:06 +00:00
|
|
|
|
GList *tmp_list;
|
|
|
|
|
GList *pending_motion = NULL;
|
|
|
|
|
|
2013-11-11 23:04:34 +00:00
|
|
|
|
gboolean paused = display->event_pause_count > 0;
|
1999-01-12 23:27:30 +00:00
|
|
|
|
|
2019-02-05 15:05:06 +00:00
|
|
|
|
tmp_list = g_queue_peek_head_link (&display->queued_events);
|
1999-01-12 23:27:30 +00:00
|
|
|
|
while (tmp_list)
|
|
|
|
|
{
|
2017-10-11 06:42:41 +00:00
|
|
|
|
GdkEvent *event = tmp_list->data;
|
2012-09-26 14:28:06 +00:00
|
|
|
|
|
2017-10-11 06:42:41 +00:00
|
|
|
|
if ((event->any.flags & GDK_EVENT_PENDING) == 0 &&
|
|
|
|
|
(!paused || (event->any.flags & GDK_EVENT_FLUSHED) != 0))
|
2013-09-28 16:06:53 +00:00
|
|
|
|
{
|
|
|
|
|
if (pending_motion)
|
|
|
|
|
return pending_motion;
|
|
|
|
|
|
2017-10-11 06:42:41 +00:00
|
|
|
|
if (event->any.type == GDK_MOTION_NOTIFY && (event->any.flags & GDK_EVENT_FLUSHED) == 0)
|
2013-09-28 16:06:53 +00:00
|
|
|
|
pending_motion = tmp_list;
|
|
|
|
|
else
|
|
|
|
|
return tmp_list;
|
|
|
|
|
}
|
1999-01-21 06:24:09 +00:00
|
|
|
|
|
2015-10-20 00:28:06 +00:00
|
|
|
|
tmp_list = tmp_list->next;
|
1999-01-12 23:27:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2002-04-25 22:29:14 +00:00
|
|
|
|
/**
|
|
|
|
|
* _gdk_event_queue_append:
|
|
|
|
|
* @display: a #GdkDisplay
|
|
|
|
|
* @event: Event to append.
|
|
|
|
|
*
|
|
|
|
|
* Appends an event onto the tail of the event queue.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the newly appended list node.
|
|
|
|
|
**/
|
|
|
|
|
GList *
|
|
|
|
|
_gdk_event_queue_append (GdkDisplay *display,
|
|
|
|
|
GdkEvent *event)
|
|
|
|
|
{
|
2019-02-05 15:05:06 +00:00
|
|
|
|
g_queue_push_tail (&display->queued_events, event);
|
2002-04-25 22:29:14 +00:00
|
|
|
|
|
2019-02-05 15:05:06 +00:00
|
|
|
|
return g_queue_peek_tail_link (&display->queued_events);
|
2002-04-25 22:29:14 +00:00
|
|
|
|
}
|
1999-01-12 23:27:30 +00:00
|
|
|
|
|
2008-07-18 13:03:42 +00:00
|
|
|
|
/**
|
|
|
|
|
* _gdk_event_queue_insert_after:
|
|
|
|
|
* @display: a #GdkDisplay
|
|
|
|
|
* @sibling: Append after this event.
|
|
|
|
|
* @event: Event to append.
|
|
|
|
|
*
|
2014-02-07 18:32:47 +00:00
|
|
|
|
* Appends an event after the specified event, or if it isn’t in
|
2008-07-18 13:03:42 +00:00
|
|
|
|
* the queue, onto the tail of the event queue.
|
|
|
|
|
*/
|
2019-02-05 15:05:06 +00:00
|
|
|
|
void
|
2008-07-18 13:03:42 +00:00
|
|
|
|
_gdk_event_queue_insert_after (GdkDisplay *display,
|
|
|
|
|
GdkEvent *sibling,
|
|
|
|
|
GdkEvent *event)
|
|
|
|
|
{
|
2019-02-05 15:05:06 +00:00
|
|
|
|
GList *prev = g_queue_find (&display->queued_events, sibling);
|
|
|
|
|
|
|
|
|
|
if (prev)
|
|
|
|
|
g_queue_insert_after (&display->queued_events, prev, event);
|
2008-07-18 13:03:42 +00:00
|
|
|
|
else
|
2019-02-05 15:05:06 +00:00
|
|
|
|
g_queue_push_tail (&display->queued_events, event);
|
2008-07-18 13:03:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2012-04-13 00:07:28 +00:00
|
|
|
|
* _gdk_event_queue_insert_before:
|
2008-07-18 13:03:42 +00:00
|
|
|
|
* @display: a #GdkDisplay
|
2012-04-13 00:07:28 +00:00
|
|
|
|
* @sibling: Append before this event
|
|
|
|
|
* @event: Event to prepend
|
2008-07-18 13:03:42 +00:00
|
|
|
|
*
|
2014-02-07 18:32:47 +00:00
|
|
|
|
* Prepends an event before the specified event, or if it isn’t in
|
2012-04-13 00:07:28 +00:00
|
|
|
|
* the queue, onto the head of the event queue.
|
2008-07-18 13:03:42 +00:00
|
|
|
|
*
|
2012-04-13 00:07:28 +00:00
|
|
|
|
* Returns: the newly prepended list node.
|
2008-07-18 13:03:42 +00:00
|
|
|
|
*/
|
2019-02-05 15:05:06 +00:00
|
|
|
|
void
|
2008-07-18 13:03:42 +00:00
|
|
|
|
_gdk_event_queue_insert_before (GdkDisplay *display,
|
|
|
|
|
GdkEvent *sibling,
|
|
|
|
|
GdkEvent *event)
|
|
|
|
|
{
|
2019-02-05 15:05:06 +00:00
|
|
|
|
GList *next = g_queue_find (&display->queued_events, sibling);
|
|
|
|
|
|
2008-07-18 13:03:42 +00:00
|
|
|
|
if (next)
|
2019-02-05 15:05:06 +00:00
|
|
|
|
g_queue_insert_before (&display->queued_events, next, event);
|
2008-07-18 13:03:42 +00:00
|
|
|
|
else
|
2019-02-05 15:05:06 +00:00
|
|
|
|
g_queue_push_head (&display->queued_events, event);
|
2008-07-18 13:03:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-04-25 22:29:14 +00:00
|
|
|
|
/**
|
|
|
|
|
* _gdk_event_queue_remove_link:
|
|
|
|
|
* @display: a #GdkDisplay
|
|
|
|
|
* @node: node to remove
|
|
|
|
|
*
|
|
|
|
|
* Removes a specified list node from the event queue.
|
|
|
|
|
**/
|
1999-11-08 20:14:59 +00:00
|
|
|
|
void
|
2002-04-25 22:29:14 +00:00
|
|
|
|
_gdk_event_queue_remove_link (GdkDisplay *display,
|
|
|
|
|
GList *node)
|
1999-01-12 23:27:30 +00:00
|
|
|
|
{
|
2019-02-05 15:05:06 +00:00
|
|
|
|
g_queue_unlink (&display->queued_events, node);
|
1999-01-12 23:27:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-04-25 22:29:14 +00:00
|
|
|
|
/**
|
|
|
|
|
* _gdk_event_unqueue:
|
|
|
|
|
* @display: a #GdkDisplay
|
|
|
|
|
*
|
|
|
|
|
* Removes and returns the first event from the event
|
|
|
|
|
* queue that is not still being filled in.
|
|
|
|
|
*
|
2014-05-08 19:55:50 +00:00
|
|
|
|
* Returns: (nullable): the event, or %NULL. Ownership is transferred
|
2002-04-25 22:29:14 +00:00
|
|
|
|
* to the caller.
|
|
|
|
|
**/
|
|
|
|
|
GdkEvent*
|
|
|
|
|
_gdk_event_unqueue (GdkDisplay *display)
|
1999-01-12 23:27:30 +00:00
|
|
|
|
{
|
2002-04-25 22:29:14 +00:00
|
|
|
|
GdkEvent *event = NULL;
|
|
|
|
|
GList *tmp_list;
|
|
|
|
|
|
|
|
|
|
tmp_list = _gdk_event_queue_find_first (display);
|
|
|
|
|
|
|
|
|
|
if (tmp_list)
|
|
|
|
|
{
|
|
|
|
|
event = tmp_list->data;
|
|
|
|
|
_gdk_event_queue_remove_link (display, tmp_list);
|
|
|
|
|
g_list_free_1 (tmp_list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return event;
|
1998-12-15 13:54:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-31 11:37:50 +00:00
|
|
|
|
static void
|
2020-02-18 03:11:56 +00:00
|
|
|
|
gdk_event_push_history (GdkEvent *event,
|
|
|
|
|
GdkEvent *history_event)
|
2017-10-31 11:37:50 +00:00
|
|
|
|
{
|
|
|
|
|
GdkTimeCoord *hist;
|
|
|
|
|
GdkDevice *device;
|
|
|
|
|
gint i, n_axes;
|
|
|
|
|
|
|
|
|
|
g_assert (event->any.type == GDK_MOTION_NOTIFY);
|
|
|
|
|
g_assert (history_event->any.type == GDK_MOTION_NOTIFY);
|
|
|
|
|
|
|
|
|
|
hist = g_new0 (GdkTimeCoord, 1);
|
|
|
|
|
|
|
|
|
|
device = gdk_event_get_device (history_event);
|
|
|
|
|
n_axes = gdk_device_get_n_axes (device);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i <= MIN (n_axes, GDK_MAX_TIMECOORD_AXES); i++)
|
|
|
|
|
gdk_event_get_axis (history_event, i, &hist->axes[i]);
|
|
|
|
|
|
|
|
|
|
event->motion.history = g_list_prepend (event->motion.history, hist);
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-26 14:28:06 +00:00
|
|
|
|
void
|
|
|
|
|
_gdk_event_queue_handle_motion_compression (GdkDisplay *display)
|
|
|
|
|
{
|
|
|
|
|
GList *tmp_list;
|
|
|
|
|
GList *pending_motions = NULL;
|
2018-03-20 14:14:10 +00:00
|
|
|
|
GdkSurface *pending_motion_surface = NULL;
|
2013-02-14 19:51:33 +00:00
|
|
|
|
GdkDevice *pending_motion_device = NULL;
|
2017-10-31 11:37:50 +00:00
|
|
|
|
GdkEvent *last_motion = NULL;
|
2012-09-26 14:28:06 +00:00
|
|
|
|
|
|
|
|
|
/* If the last N events in the event queue are motion notify
|
2018-03-20 14:14:10 +00:00
|
|
|
|
* events for the same surface, drop all but the last */
|
2012-09-26 14:28:06 +00:00
|
|
|
|
|
2019-02-05 15:05:06 +00:00
|
|
|
|
tmp_list = g_queue_peek_tail_link (&display->queued_events);
|
2012-09-26 14:28:06 +00:00
|
|
|
|
|
|
|
|
|
while (tmp_list)
|
|
|
|
|
{
|
2017-10-11 06:42:41 +00:00
|
|
|
|
GdkEvent *event = tmp_list->data;
|
2012-09-26 14:28:06 +00:00
|
|
|
|
|
2017-10-11 06:42:41 +00:00
|
|
|
|
if (event->any.flags & GDK_EVENT_PENDING)
|
2012-09-26 14:28:06 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2017-10-11 06:42:41 +00:00
|
|
|
|
if (event->any.type != GDK_MOTION_NOTIFY)
|
2012-09-26 14:28:06 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
|
if (pending_motion_surface != NULL &&
|
|
|
|
|
pending_motion_surface != event->any.surface)
|
2012-09-26 14:28:06 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2013-02-14 19:51:33 +00:00
|
|
|
|
if (pending_motion_device != NULL &&
|
2017-10-11 06:42:41 +00:00
|
|
|
|
pending_motion_device != event->any.device)
|
2013-02-14 19:51:33 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2017-10-31 11:37:50 +00:00
|
|
|
|
if (!last_motion)
|
|
|
|
|
last_motion = event;
|
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
|
pending_motion_surface = event->any.surface;
|
2017-10-11 06:42:41 +00:00
|
|
|
|
pending_motion_device = event->any.device;
|
2012-09-26 14:28:06 +00:00
|
|
|
|
pending_motions = tmp_list;
|
|
|
|
|
|
|
|
|
|
tmp_list = tmp_list->prev;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (pending_motions && pending_motions->next != NULL)
|
|
|
|
|
{
|
|
|
|
|
GList *next = pending_motions->next;
|
2017-10-31 11:37:50 +00:00
|
|
|
|
|
|
|
|
|
if (last_motion &&
|
|
|
|
|
(last_motion->motion.state &
|
|
|
|
|
(GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK |
|
|
|
|
|
GDK_BUTTON4_MASK | GDK_BUTTON5_MASK)))
|
|
|
|
|
gdk_event_push_history (last_motion, pending_motions->data);
|
|
|
|
|
|
2020-02-15 20:07:24 +00:00
|
|
|
|
gdk_event_unref (pending_motions->data);
|
2019-02-05 15:05:06 +00:00
|
|
|
|
g_queue_delete_link (&display->queued_events, pending_motions);
|
2012-09-26 14:28:06 +00:00
|
|
|
|
pending_motions = next;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-05 15:05:06 +00:00
|
|
|
|
if (g_queue_get_length (&display->queued_events) == 1 &&
|
|
|
|
|
g_queue_peek_head_link (&display->queued_events) == pending_motions)
|
2012-09-26 14:28:06 +00:00
|
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
|
GdkFrameClock *clock = gdk_surface_get_frame_clock (pending_motion_surface);
|
|
|
|
|
if (clock) /* might be NULL if surface was destroyed */
|
2013-11-11 23:17:38 +00:00
|
|
|
|
gdk_frame_clock_request_phase (clock, GDK_FRAME_CLOCK_PHASE_FLUSH_EVENTS);
|
2012-09-26 14:28:06 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-11 23:04:34 +00:00
|
|
|
|
void
|
|
|
|
|
_gdk_event_queue_flush (GdkDisplay *display)
|
|
|
|
|
{
|
|
|
|
|
GList *tmp_list;
|
|
|
|
|
|
2019-02-05 15:05:06 +00:00
|
|
|
|
for (tmp_list = display->queued_events.head; tmp_list; tmp_list = tmp_list->next)
|
2013-11-11 23:04:34 +00:00
|
|
|
|
{
|
2017-10-11 06:42:41 +00:00
|
|
|
|
GdkEvent *event = tmp_list->data;
|
|
|
|
|
event->any.flags |= GDK_EVENT_FLUSHED;
|
2013-11-11 23:04:34 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* gdk_event_ref:
|
|
|
|
|
* @event: a #GdkEvent
|
|
|
|
|
*
|
|
|
|
|
* Increase the ref count of @event.
|
|
|
|
|
*
|
|
|
|
|
* Returns: @event
|
|
|
|
|
*/
|
2020-02-15 19:22:33 +00:00
|
|
|
|
GdkEvent *
|
|
|
|
|
gdk_event_ref (GdkEvent *event)
|
|
|
|
|
{
|
2020-02-15 20:40:03 +00:00
|
|
|
|
event->any.ref_count++;
|
|
|
|
|
return event;
|
2020-02-15 19:22:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-15 20:40:03 +00:00
|
|
|
|
static void gdk_event_free (GdkEvent *event);
|
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* gdk_event_unref:
|
|
|
|
|
* @event: a #GdkEvent
|
|
|
|
|
*
|
|
|
|
|
* Decrease the ref count of @event, and free it
|
|
|
|
|
* if the last reference is dropped.
|
|
|
|
|
*/
|
2020-02-15 19:22:33 +00:00
|
|
|
|
void
|
|
|
|
|
gdk_event_unref (GdkEvent *event)
|
|
|
|
|
{
|
2020-02-15 20:40:03 +00:00
|
|
|
|
event->any.ref_count--;
|
|
|
|
|
if (event->any.ref_count == 0)
|
|
|
|
|
gdk_event_free (event);
|
1998-12-15 13:54:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-05-10 19:22:35 +00:00
|
|
|
|
/**
|
|
|
|
|
* gdk_event_get_pointer_emulated:
|
2017-12-26 15:59:38 +00:00
|
|
|
|
* @event: a #GdkEvent
|
2016-05-10 19:22:35 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns whether this event is an 'emulated' pointer event (typically
|
|
|
|
|
* from a touch event), as opposed to a real one.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if this event is emulated
|
|
|
|
|
*/
|
2011-12-28 00:37:01 +00:00
|
|
|
|
gboolean
|
2016-05-10 19:16:45 +00:00
|
|
|
|
gdk_event_get_pointer_emulated (GdkEvent *event)
|
2011-12-28 00:37:01 +00:00
|
|
|
|
{
|
2020-02-18 04:08:44 +00:00
|
|
|
|
return event->any.pointer_emulated;
|
2011-12-28 00:37:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-29 19:54:47 +00:00
|
|
|
|
static void
|
2020-02-15 20:40:03 +00:00
|
|
|
|
gdk_event_free (GdkEvent *event)
|
2017-10-25 11:23:41 +00:00
|
|
|
|
{
|
|
|
|
|
GdkDisplay *display;
|
2015-08-03 15:22:29 +00:00
|
|
|
|
|
2017-10-06 19:19:42 +00:00
|
|
|
|
switch ((guint) event->any.type)
|
1998-12-15 13:54:20 +00:00
|
|
|
|
{
|
|
|
|
|
case GDK_ENTER_NOTIFY:
|
|
|
|
|
case GDK_LEAVE_NOTIFY:
|
2018-03-20 14:14:10 +00:00
|
|
|
|
g_clear_object (&event->crossing.child_surface);
|
1998-12-15 13:54:20 +00:00
|
|
|
|
break;
|
2017-10-11 06:42:41 +00:00
|
|
|
|
|
1998-12-15 13:54:20 +00:00
|
|
|
|
case GDK_DRAG_ENTER:
|
|
|
|
|
case GDK_DRAG_LEAVE:
|
|
|
|
|
case GDK_DRAG_MOTION:
|
|
|
|
|
case GDK_DROP_START:
|
2018-05-29 18:49:41 +00:00
|
|
|
|
g_clear_object (&event->dnd.drop);
|
1998-12-15 13:54:20 +00:00
|
|
|
|
break;
|
2000-07-03 19:00:23 +00:00
|
|
|
|
|
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
|
case GDK_BUTTON_RELEASE:
|
2017-10-11 06:42:41 +00:00
|
|
|
|
g_clear_object (&event->button.tool);
|
2007-03-09 21:57:37 +00:00
|
|
|
|
g_free (event->button.axes);
|
2000-07-03 19:00:23 +00:00
|
|
|
|
break;
|
2011-02-28 19:53:42 +00:00
|
|
|
|
|
|
|
|
|
case GDK_TOUCH_BEGIN:
|
|
|
|
|
case GDK_TOUCH_UPDATE:
|
|
|
|
|
case GDK_TOUCH_END:
|
|
|
|
|
case GDK_TOUCH_CANCEL:
|
|
|
|
|
g_free (event->touch.axes);
|
|
|
|
|
break;
|
|
|
|
|
|
2000-07-03 19:00:23 +00:00
|
|
|
|
case GDK_MOTION_NOTIFY:
|
2017-10-11 06:42:41 +00:00
|
|
|
|
g_clear_object (&event->motion.tool);
|
2007-03-09 21:57:37 +00:00
|
|
|
|
g_free (event->motion.axes);
|
2017-10-31 11:37:50 +00:00
|
|
|
|
g_list_free_full (event->motion.history, g_free);
|
2000-07-03 19:00:23 +00:00
|
|
|
|
break;
|
2011-01-31 05:43:18 +00:00
|
|
|
|
|
2020-02-14 21:46:43 +00:00
|
|
|
|
case GDK_PROXIMITY_IN:
|
|
|
|
|
case GDK_PROXIMITY_OUT:
|
|
|
|
|
g_clear_object (&event->proximity.tool);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GDK_SCROLL:
|
|
|
|
|
g_clear_object (&event->scroll.tool);
|
|
|
|
|
break;
|
|
|
|
|
|
1998-12-15 13:54:20 +00:00
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2002-10-02 21:39:09 +00:00
|
|
|
|
|
2017-12-12 23:35:16 +00:00
|
|
|
|
display = gdk_event_get_display (event);
|
2011-04-09 01:20:26 +00:00
|
|
|
|
if (display)
|
|
|
|
|
_gdk_display_event_data_free (display, event);
|
2008-05-06 21:00:06 +00:00
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
|
if (event->any.surface)
|
|
|
|
|
g_object_unref (event->any.surface);
|
2014-11-01 18:44:03 +00:00
|
|
|
|
|
2017-10-11 06:42:41 +00:00
|
|
|
|
g_clear_object (&event->any.device);
|
|
|
|
|
g_clear_object (&event->any.source_device);
|
|
|
|
|
|
2020-02-15 20:40:03 +00:00
|
|
|
|
g_free (event);
|
1998-12-15 13:54:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-09-10 10:20:28 +00:00
|
|
|
|
/**
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* gdk_event_get_axis:
|
2013-09-10 10:20:28 +00:00
|
|
|
|
* @event: a #GdkEvent
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* @axis_use: the axis use to look for
|
|
|
|
|
* @value: (out): location to store the value found
|
2013-09-10 10:20:28 +00:00
|
|
|
|
*
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* Extract the axis value for a particular axis use from
|
|
|
|
|
* an event structure.
|
2013-09-10 10:20:28 +00:00
|
|
|
|
*
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* Returns: %TRUE if the specified axis was found, otherwise %FALSE
|
|
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
gdk_event_get_axis (GdkEvent *event,
|
|
|
|
|
GdkAxisUse axis_use,
|
|
|
|
|
double *value)
|
2013-09-10 10:20:28 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
double *axes;
|
2013-09-10 10:20:28 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
if (axis_use == GDK_AXIS_X || axis_use == GDK_AXIS_Y)
|
|
|
|
|
{
|
|
|
|
|
gdouble x, y;
|
2013-09-10 10:20:28 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
switch ((guint) event->any.type)
|
|
|
|
|
{
|
|
|
|
|
case GDK_MOTION_NOTIFY:
|
|
|
|
|
x = event->motion.x;
|
|
|
|
|
y = event->motion.y;
|
|
|
|
|
break;
|
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
|
x = event->button.x;
|
|
|
|
|
y = event->button.y;
|
|
|
|
|
break;
|
|
|
|
|
case GDK_TOUCH_BEGIN:
|
|
|
|
|
case GDK_TOUCH_UPDATE:
|
|
|
|
|
case GDK_TOUCH_END:
|
|
|
|
|
case GDK_TOUCH_CANCEL:
|
|
|
|
|
x = event->touch.x;
|
|
|
|
|
y = event->touch.y;
|
|
|
|
|
break;
|
|
|
|
|
case GDK_ENTER_NOTIFY:
|
|
|
|
|
case GDK_LEAVE_NOTIFY:
|
|
|
|
|
x = event->crossing.x;
|
|
|
|
|
y = event->crossing.y;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (axis_use == GDK_AXIS_X && value)
|
|
|
|
|
*value = x;
|
|
|
|
|
if (axis_use == GDK_AXIS_Y && value)
|
|
|
|
|
*value = y;
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
else if (event->any.type == GDK_BUTTON_PRESS ||
|
|
|
|
|
event->any.type == GDK_BUTTON_RELEASE)
|
|
|
|
|
{
|
|
|
|
|
axes = event->button.axes;
|
|
|
|
|
}
|
|
|
|
|
else if (event->any.type == GDK_TOUCH_BEGIN ||
|
|
|
|
|
event->any.type == GDK_TOUCH_UPDATE ||
|
|
|
|
|
event->any.type == GDK_TOUCH_END ||
|
|
|
|
|
event->any.type == GDK_TOUCH_CANCEL)
|
|
|
|
|
{
|
|
|
|
|
axes = event->touch.axes;
|
|
|
|
|
}
|
|
|
|
|
else if (event->any.type == GDK_MOTION_NOTIFY)
|
|
|
|
|
{
|
|
|
|
|
axes = event->motion.axes;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
return gdk_device_get_axis (event->any.device, axes, axis_use, value);
|
1998-12-15 13:54:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
Port to GObject, can go back in gdk-pixbuf after setting up a
2000-12-16 Havoc Pennington <hp@pobox.com>
* gtk/gdk-pixbuf-loader.h, gtk/gdk-pixbuf-loader.c:
Port to GObject, can go back in gdk-pixbuf after setting up
a gdk-pixbuf-marshal.h header over there.
* gtk/gtktreeview.c: s/SEPERATOR/SEPARATOR/g;
(gtk_tree_view_class_init): specify GTK_TYPE_ADJUSTMENT for signal
args
(gtk_tree_view_init): don't unset GTK_NO_WINDOW, it shouldn't be
set
(gtk_tree_view_realize_buttons): don't gtk_widget_show() buttons
here, do it when we create the buttons later
(gtk_tree_view_realize_buttons): add some g_return_if_fail
(gtk_tree_view_map): paranoia checks that column->button is shown
and unmapped
(gtk_tree_view_size_request): only request visible children.
Move header size calculation in here, for cleanliness, and
to maintain invariants for child widgets if we eventually
let users set different children inside the buttons
(gtk_tree_view_map_buttons): factor out code to map buttons,
since it was being called several times
(gtk_tree_view_size_allocate_buttons): move_resize the drag
windows instead of just moving them; their height may change
if we allow random widgets in there, or the theme changes.
(gtk_tree_view_size_allocate): move button size allocation
above emitting the scroll signals, to ensure a sane state when we
hit user code
(gtk_tree_view_button_release): remove queue_resize after
tree_view_set_size(), set_size() will handle any resize queuing
that's needed
(gtk_tree_view_focus_in): just queue a draw, don't fool with
draw_focus goo
(gtk_tree_view_focus): use gtk_get_current_event() and
gdk_event_get_state()
(gtk_tree_view_deleted): don't queue_resize() after calling set_size()
(gtk_tree_view_build_tree): fix a "if (foo); {}" bug - i.e. remove
semicolon
(gtk_tree_view_create_button): show the button here
(gtk_tree_view_button_clicked): actually emit the clicked signal
on the column
(_gtk_tree_view_set_size): return right away if the size is
unchanged, as a cheesy optimization
(gtk_tree_view_setup_model): rename set_model_realized to
setup_model to match the flag that indicates whether we've
called it
(gtk_tree_view_get_hadjustment): create adjustment if it doesn't
exist, because set_scroll_adjustment does that and it shouldn't
matter what order you call these in
(gtk_tree_view_get_vadjustment): ditto
(gtk_tree_view_set_headers_visible): canonicalize the bool,
for paranoia
(gtk_tree_view_set_headers_visible): call
gtk_tree_view_map_buttons() instead of using cut-and-paste code
(gtk_tree_view_append_column): clarify whether the return value
is the count of columns before or after, and do the increment
separately from the return statement so you can tell from the code.
(gtk_tree_view_remove_column): ditto
(gtk_tree_view_insert_column): ditto
(gtk_tree_view_get_column): remove g_return_if_fail for columns
outside the existing range, the docs say that outside-range
columns are allowed, so we handle them as documented. (Presumably
this allows a nice loop with column != NULL as test.)
(gtk_tree_view_move_to): document what 0.0, 0.5, 1.0 alignments
mean (left/right/center etc.).
(gtk_tree_view_collapse_all): only queue a draw if we're mapped
(gtk_tree_view_expand_row): add docs
(gtk_tree_view_collapse_row): add docs
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_clicked): new
function to emit the clicked signal on a column
* gdk/gdkevents.c (gdk_event_get_state): new function, to get the
state of an event
(gdk_event_get_time): don't treat GDK_SCROLL
as a button event, remove default case from switch so gcc
will whine if we don't explicitly handle all event types
* gtk/gtktreeselection.h: added some FIXME
* gtk/gtktreeprivate.h (struct _GtkTreeViewPrivate): rename
"columns" to "n_columns" and "column" to "columns" for clarity
2000-12-17 23:50:00 +00:00
|
|
|
|
/**
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* gdk_event_triggers_context_menu:
|
|
|
|
|
* @event: a #GdkEvent, currently only button events are meaningful values
|
2017-12-26 15:59:38 +00:00
|
|
|
|
*
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* This function returns whether a #GdkEventButton should trigger a
|
|
|
|
|
* context menu, according to platform conventions. The right mouse
|
|
|
|
|
* button always triggers context menus. Additionally, if
|
|
|
|
|
* gdk_keymap_get_modifier_mask() returns a non-0 mask for
|
|
|
|
|
* %GDK_MODIFIER_INTENT_CONTEXT_MENU, then the left mouse button will
|
|
|
|
|
* also trigger a context menu if this modifier is pressed.
|
2017-12-26 15:59:38 +00:00
|
|
|
|
*
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* This function should always be used instead of simply checking for
|
|
|
|
|
* event->button == %GDK_BUTTON_SECONDARY.
|
2017-12-26 15:59:38 +00:00
|
|
|
|
*
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* Returns: %TRUE if the event should trigger a context menu.
|
Port to GObject, can go back in gdk-pixbuf after setting up a
2000-12-16 Havoc Pennington <hp@pobox.com>
* gtk/gdk-pixbuf-loader.h, gtk/gdk-pixbuf-loader.c:
Port to GObject, can go back in gdk-pixbuf after setting up
a gdk-pixbuf-marshal.h header over there.
* gtk/gtktreeview.c: s/SEPERATOR/SEPARATOR/g;
(gtk_tree_view_class_init): specify GTK_TYPE_ADJUSTMENT for signal
args
(gtk_tree_view_init): don't unset GTK_NO_WINDOW, it shouldn't be
set
(gtk_tree_view_realize_buttons): don't gtk_widget_show() buttons
here, do it when we create the buttons later
(gtk_tree_view_realize_buttons): add some g_return_if_fail
(gtk_tree_view_map): paranoia checks that column->button is shown
and unmapped
(gtk_tree_view_size_request): only request visible children.
Move header size calculation in here, for cleanliness, and
to maintain invariants for child widgets if we eventually
let users set different children inside the buttons
(gtk_tree_view_map_buttons): factor out code to map buttons,
since it was being called several times
(gtk_tree_view_size_allocate_buttons): move_resize the drag
windows instead of just moving them; their height may change
if we allow random widgets in there, or the theme changes.
(gtk_tree_view_size_allocate): move button size allocation
above emitting the scroll signals, to ensure a sane state when we
hit user code
(gtk_tree_view_button_release): remove queue_resize after
tree_view_set_size(), set_size() will handle any resize queuing
that's needed
(gtk_tree_view_focus_in): just queue a draw, don't fool with
draw_focus goo
(gtk_tree_view_focus): use gtk_get_current_event() and
gdk_event_get_state()
(gtk_tree_view_deleted): don't queue_resize() after calling set_size()
(gtk_tree_view_build_tree): fix a "if (foo); {}" bug - i.e. remove
semicolon
(gtk_tree_view_create_button): show the button here
(gtk_tree_view_button_clicked): actually emit the clicked signal
on the column
(_gtk_tree_view_set_size): return right away if the size is
unchanged, as a cheesy optimization
(gtk_tree_view_setup_model): rename set_model_realized to
setup_model to match the flag that indicates whether we've
called it
(gtk_tree_view_get_hadjustment): create adjustment if it doesn't
exist, because set_scroll_adjustment does that and it shouldn't
matter what order you call these in
(gtk_tree_view_get_vadjustment): ditto
(gtk_tree_view_set_headers_visible): canonicalize the bool,
for paranoia
(gtk_tree_view_set_headers_visible): call
gtk_tree_view_map_buttons() instead of using cut-and-paste code
(gtk_tree_view_append_column): clarify whether the return value
is the count of columns before or after, and do the increment
separately from the return statement so you can tell from the code.
(gtk_tree_view_remove_column): ditto
(gtk_tree_view_insert_column): ditto
(gtk_tree_view_get_column): remove g_return_if_fail for columns
outside the existing range, the docs say that outside-range
columns are allowed, so we handle them as documented. (Presumably
this allows a nice loop with column != NULL as test.)
(gtk_tree_view_move_to): document what 0.0, 0.5, 1.0 alignments
mean (left/right/center etc.).
(gtk_tree_view_collapse_all): only queue a draw if we're mapped
(gtk_tree_view_expand_row): add docs
(gtk_tree_view_collapse_row): add docs
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_clicked): new
function to emit the clicked signal on a column
* gdk/gdkevents.c (gdk_event_get_state): new function, to get the
state of an event
(gdk_event_get_time): don't treat GDK_SCROLL
as a button event, remove default case from switch so gcc
will whine if we don't explicitly handle all event types
* gtk/gtktreeselection.h: added some FIXME
* gtk/gtktreeprivate.h (struct _GtkTreeViewPrivate): rename
"columns" to "n_columns" and "column" to "columns" for clarity
2000-12-17 23:50:00 +00:00
|
|
|
|
**/
|
|
|
|
|
gboolean
|
2020-02-18 03:11:56 +00:00
|
|
|
|
gdk_event_triggers_context_menu (GdkEvent *event)
|
Port to GObject, can go back in gdk-pixbuf after setting up a
2000-12-16 Havoc Pennington <hp@pobox.com>
* gtk/gdk-pixbuf-loader.h, gtk/gdk-pixbuf-loader.c:
Port to GObject, can go back in gdk-pixbuf after setting up
a gdk-pixbuf-marshal.h header over there.
* gtk/gtktreeview.c: s/SEPERATOR/SEPARATOR/g;
(gtk_tree_view_class_init): specify GTK_TYPE_ADJUSTMENT for signal
args
(gtk_tree_view_init): don't unset GTK_NO_WINDOW, it shouldn't be
set
(gtk_tree_view_realize_buttons): don't gtk_widget_show() buttons
here, do it when we create the buttons later
(gtk_tree_view_realize_buttons): add some g_return_if_fail
(gtk_tree_view_map): paranoia checks that column->button is shown
and unmapped
(gtk_tree_view_size_request): only request visible children.
Move header size calculation in here, for cleanliness, and
to maintain invariants for child widgets if we eventually
let users set different children inside the buttons
(gtk_tree_view_map_buttons): factor out code to map buttons,
since it was being called several times
(gtk_tree_view_size_allocate_buttons): move_resize the drag
windows instead of just moving them; their height may change
if we allow random widgets in there, or the theme changes.
(gtk_tree_view_size_allocate): move button size allocation
above emitting the scroll signals, to ensure a sane state when we
hit user code
(gtk_tree_view_button_release): remove queue_resize after
tree_view_set_size(), set_size() will handle any resize queuing
that's needed
(gtk_tree_view_focus_in): just queue a draw, don't fool with
draw_focus goo
(gtk_tree_view_focus): use gtk_get_current_event() and
gdk_event_get_state()
(gtk_tree_view_deleted): don't queue_resize() after calling set_size()
(gtk_tree_view_build_tree): fix a "if (foo); {}" bug - i.e. remove
semicolon
(gtk_tree_view_create_button): show the button here
(gtk_tree_view_button_clicked): actually emit the clicked signal
on the column
(_gtk_tree_view_set_size): return right away if the size is
unchanged, as a cheesy optimization
(gtk_tree_view_setup_model): rename set_model_realized to
setup_model to match the flag that indicates whether we've
called it
(gtk_tree_view_get_hadjustment): create adjustment if it doesn't
exist, because set_scroll_adjustment does that and it shouldn't
matter what order you call these in
(gtk_tree_view_get_vadjustment): ditto
(gtk_tree_view_set_headers_visible): canonicalize the bool,
for paranoia
(gtk_tree_view_set_headers_visible): call
gtk_tree_view_map_buttons() instead of using cut-and-paste code
(gtk_tree_view_append_column): clarify whether the return value
is the count of columns before or after, and do the increment
separately from the return statement so you can tell from the code.
(gtk_tree_view_remove_column): ditto
(gtk_tree_view_insert_column): ditto
(gtk_tree_view_get_column): remove g_return_if_fail for columns
outside the existing range, the docs say that outside-range
columns are allowed, so we handle them as documented. (Presumably
this allows a nice loop with column != NULL as test.)
(gtk_tree_view_move_to): document what 0.0, 0.5, 1.0 alignments
mean (left/right/center etc.).
(gtk_tree_view_collapse_all): only queue a draw if we're mapped
(gtk_tree_view_expand_row): add docs
(gtk_tree_view_collapse_row): add docs
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_clicked): new
function to emit the clicked signal on a column
* gdk/gdkevents.c (gdk_event_get_state): new function, to get the
state of an event
(gdk_event_get_time): don't treat GDK_SCROLL
as a button event, remove default case from switch so gcc
will whine if we don't explicitly handle all event types
* gtk/gtktreeselection.h: added some FIXME
* gtk/gtktreeprivate.h (struct _GtkTreeViewPrivate): rename
"columns" to "n_columns" and "column" to "columns" for clarity
2000-12-17 23:50:00 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
g_return_val_if_fail (event != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
if (event->any.type == GDK_BUTTON_PRESS)
|
|
|
|
|
{
|
|
|
|
|
GdkEventButton *bevent = (GdkEventButton *) event;
|
|
|
|
|
GdkDisplay *display;
|
|
|
|
|
GdkModifierType modifier;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GDK_IS_SURFACE (bevent->any.surface), FALSE);
|
|
|
|
|
|
|
|
|
|
if (bevent->button == GDK_BUTTON_SECONDARY &&
|
|
|
|
|
! (bevent->state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK)))
|
2000-12-18 19:12:35 +00:00
|
|
|
|
return TRUE;
|
2020-02-18 03:11:56 +00:00
|
|
|
|
|
|
|
|
|
display = gdk_surface_get_display (bevent->any.surface);
|
|
|
|
|
|
|
|
|
|
modifier = gdk_keymap_get_modifier_mask (gdk_display_get_keymap (display),
|
|
|
|
|
GDK_MODIFIER_INTENT_CONTEXT_MENU);
|
|
|
|
|
|
|
|
|
|
if (modifier != 0 &&
|
|
|
|
|
bevent->button == GDK_BUTTON_PRIMARY &&
|
|
|
|
|
! (bevent->state & (GDK_BUTTON2_MASK | GDK_BUTTON3_MASK)) &&
|
|
|
|
|
(bevent->state & modifier))
|
2000-12-18 19:12:35 +00:00
|
|
|
|
return TRUE;
|
2020-02-18 03:11:56 +00:00
|
|
|
|
}
|
Port to GObject, can go back in gdk-pixbuf after setting up a
2000-12-16 Havoc Pennington <hp@pobox.com>
* gtk/gdk-pixbuf-loader.h, gtk/gdk-pixbuf-loader.c:
Port to GObject, can go back in gdk-pixbuf after setting up
a gdk-pixbuf-marshal.h header over there.
* gtk/gtktreeview.c: s/SEPERATOR/SEPARATOR/g;
(gtk_tree_view_class_init): specify GTK_TYPE_ADJUSTMENT for signal
args
(gtk_tree_view_init): don't unset GTK_NO_WINDOW, it shouldn't be
set
(gtk_tree_view_realize_buttons): don't gtk_widget_show() buttons
here, do it when we create the buttons later
(gtk_tree_view_realize_buttons): add some g_return_if_fail
(gtk_tree_view_map): paranoia checks that column->button is shown
and unmapped
(gtk_tree_view_size_request): only request visible children.
Move header size calculation in here, for cleanliness, and
to maintain invariants for child widgets if we eventually
let users set different children inside the buttons
(gtk_tree_view_map_buttons): factor out code to map buttons,
since it was being called several times
(gtk_tree_view_size_allocate_buttons): move_resize the drag
windows instead of just moving them; their height may change
if we allow random widgets in there, or the theme changes.
(gtk_tree_view_size_allocate): move button size allocation
above emitting the scroll signals, to ensure a sane state when we
hit user code
(gtk_tree_view_button_release): remove queue_resize after
tree_view_set_size(), set_size() will handle any resize queuing
that's needed
(gtk_tree_view_focus_in): just queue a draw, don't fool with
draw_focus goo
(gtk_tree_view_focus): use gtk_get_current_event() and
gdk_event_get_state()
(gtk_tree_view_deleted): don't queue_resize() after calling set_size()
(gtk_tree_view_build_tree): fix a "if (foo); {}" bug - i.e. remove
semicolon
(gtk_tree_view_create_button): show the button here
(gtk_tree_view_button_clicked): actually emit the clicked signal
on the column
(_gtk_tree_view_set_size): return right away if the size is
unchanged, as a cheesy optimization
(gtk_tree_view_setup_model): rename set_model_realized to
setup_model to match the flag that indicates whether we've
called it
(gtk_tree_view_get_hadjustment): create adjustment if it doesn't
exist, because set_scroll_adjustment does that and it shouldn't
matter what order you call these in
(gtk_tree_view_get_vadjustment): ditto
(gtk_tree_view_set_headers_visible): canonicalize the bool,
for paranoia
(gtk_tree_view_set_headers_visible): call
gtk_tree_view_map_buttons() instead of using cut-and-paste code
(gtk_tree_view_append_column): clarify whether the return value
is the count of columns before or after, and do the increment
separately from the return statement so you can tell from the code.
(gtk_tree_view_remove_column): ditto
(gtk_tree_view_insert_column): ditto
(gtk_tree_view_get_column): remove g_return_if_fail for columns
outside the existing range, the docs say that outside-range
columns are allowed, so we handle them as documented. (Presumably
this allows a nice loop with column != NULL as test.)
(gtk_tree_view_move_to): document what 0.0, 0.5, 1.0 alignments
mean (left/right/center etc.).
(gtk_tree_view_collapse_all): only queue a draw if we're mapped
(gtk_tree_view_expand_row): add docs
(gtk_tree_view_collapse_row): add docs
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_clicked): new
function to emit the clicked signal on a column
* gdk/gdkevents.c (gdk_event_get_state): new function, to get the
state of an event
(gdk_event_get_time): don't treat GDK_SCROLL
as a button event, remove default case from switch so gcc
will whine if we don't explicitly handle all event types
* gtk/gtktreeselection.h: added some FIXME
* gtk/gtktreeprivate.h (struct _GtkTreeViewPrivate): rename
"columns" to "n_columns" and "column" to "columns" for clarity
2000-12-17 23:50:00 +00:00
|
|
|
|
|
2000-12-18 19:12:35 +00:00
|
|
|
|
return FALSE;
|
Port to GObject, can go back in gdk-pixbuf after setting up a
2000-12-16 Havoc Pennington <hp@pobox.com>
* gtk/gdk-pixbuf-loader.h, gtk/gdk-pixbuf-loader.c:
Port to GObject, can go back in gdk-pixbuf after setting up
a gdk-pixbuf-marshal.h header over there.
* gtk/gtktreeview.c: s/SEPERATOR/SEPARATOR/g;
(gtk_tree_view_class_init): specify GTK_TYPE_ADJUSTMENT for signal
args
(gtk_tree_view_init): don't unset GTK_NO_WINDOW, it shouldn't be
set
(gtk_tree_view_realize_buttons): don't gtk_widget_show() buttons
here, do it when we create the buttons later
(gtk_tree_view_realize_buttons): add some g_return_if_fail
(gtk_tree_view_map): paranoia checks that column->button is shown
and unmapped
(gtk_tree_view_size_request): only request visible children.
Move header size calculation in here, for cleanliness, and
to maintain invariants for child widgets if we eventually
let users set different children inside the buttons
(gtk_tree_view_map_buttons): factor out code to map buttons,
since it was being called several times
(gtk_tree_view_size_allocate_buttons): move_resize the drag
windows instead of just moving them; their height may change
if we allow random widgets in there, or the theme changes.
(gtk_tree_view_size_allocate): move button size allocation
above emitting the scroll signals, to ensure a sane state when we
hit user code
(gtk_tree_view_button_release): remove queue_resize after
tree_view_set_size(), set_size() will handle any resize queuing
that's needed
(gtk_tree_view_focus_in): just queue a draw, don't fool with
draw_focus goo
(gtk_tree_view_focus): use gtk_get_current_event() and
gdk_event_get_state()
(gtk_tree_view_deleted): don't queue_resize() after calling set_size()
(gtk_tree_view_build_tree): fix a "if (foo); {}" bug - i.e. remove
semicolon
(gtk_tree_view_create_button): show the button here
(gtk_tree_view_button_clicked): actually emit the clicked signal
on the column
(_gtk_tree_view_set_size): return right away if the size is
unchanged, as a cheesy optimization
(gtk_tree_view_setup_model): rename set_model_realized to
setup_model to match the flag that indicates whether we've
called it
(gtk_tree_view_get_hadjustment): create adjustment if it doesn't
exist, because set_scroll_adjustment does that and it shouldn't
matter what order you call these in
(gtk_tree_view_get_vadjustment): ditto
(gtk_tree_view_set_headers_visible): canonicalize the bool,
for paranoia
(gtk_tree_view_set_headers_visible): call
gtk_tree_view_map_buttons() instead of using cut-and-paste code
(gtk_tree_view_append_column): clarify whether the return value
is the count of columns before or after, and do the increment
separately from the return statement so you can tell from the code.
(gtk_tree_view_remove_column): ditto
(gtk_tree_view_insert_column): ditto
(gtk_tree_view_get_column): remove g_return_if_fail for columns
outside the existing range, the docs say that outside-range
columns are allowed, so we handle them as documented. (Presumably
this allows a nice loop with column != NULL as test.)
(gtk_tree_view_move_to): document what 0.0, 0.5, 1.0 alignments
mean (left/right/center etc.).
(gtk_tree_view_collapse_all): only queue a draw if we're mapped
(gtk_tree_view_expand_row): add docs
(gtk_tree_view_collapse_row): add docs
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_clicked): new
function to emit the clicked signal on a column
* gdk/gdkevents.c (gdk_event_get_state): new function, to get the
state of an event
(gdk_event_get_time): don't treat GDK_SCROLL
as a button event, remove default case from switch so gcc
will whine if we don't explicitly handle all event types
* gtk/gtktreeselection.h: added some FIXME
* gtk/gtktreeprivate.h (struct _GtkTreeViewPrivate): rename
"columns" to "n_columns" and "column" to "columns" for clarity
2000-12-17 23:50:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gdk_events_get_axis_distances (GdkEvent *event1,
|
|
|
|
|
GdkEvent *event2,
|
|
|
|
|
gdouble *x_distance,
|
|
|
|
|
gdouble *y_distance,
|
|
|
|
|
gdouble *distance)
|
2001-06-28 22:49:20 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
gdouble x1, x2, y1, y2;
|
|
|
|
|
gdouble xd, yd;
|
2017-12-26 15:59:38 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
if (!gdk_event_get_position (event1, &x1, &y1) ||
|
|
|
|
|
!gdk_event_get_position (event2, &x2, &y2))
|
|
|
|
|
return FALSE;
|
2001-06-28 22:49:20 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
xd = x2 - x1;
|
|
|
|
|
yd = y2 - y1;
|
|
|
|
|
|
|
|
|
|
if (x_distance)
|
|
|
|
|
*x_distance = xd;
|
2001-06-28 22:49:20 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
if (y_distance)
|
|
|
|
|
*y_distance = yd;
|
|
|
|
|
|
|
|
|
|
if (distance)
|
|
|
|
|
*distance = sqrt ((xd * xd) + (yd * yd));
|
2001-06-28 22:49:20 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
return TRUE;
|
2001-06-28 22:49:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-08-28 19:26:47 +00:00
|
|
|
|
/**
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* gdk_events_get_distance:
|
|
|
|
|
* @event1: first #GdkEvent
|
|
|
|
|
* @event2: second #GdkEvent
|
|
|
|
|
* @distance: (out): return location for the distance
|
2011-08-28 19:26:47 +00:00
|
|
|
|
*
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* If both events have X/Y information, the distance between both coordinates
|
|
|
|
|
* (as in a straight line going from @event1 to @event2) will be returned.
|
2011-08-28 19:26:47 +00:00
|
|
|
|
*
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* Returns: %TRUE if the distance could be calculated.
|
2011-08-28 19:26:47 +00:00
|
|
|
|
**/
|
|
|
|
|
gboolean
|
2020-02-18 03:11:56 +00:00
|
|
|
|
gdk_events_get_distance (GdkEvent *event1,
|
|
|
|
|
GdkEvent *event2,
|
|
|
|
|
gdouble *distance)
|
2011-08-28 19:26:47 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
return gdk_events_get_axis_distances (event1, event2,
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
distance);
|
2011-08-28 19:26:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* gdk_events_get_angle:
|
|
|
|
|
* @event1: first #GdkEvent
|
|
|
|
|
* @event2: second #GdkEvent
|
|
|
|
|
* @angle: (out): return location for the relative angle between both events
|
2011-08-28 19:26:47 +00:00
|
|
|
|
*
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* If both events contain X/Y information, this function will return %TRUE
|
|
|
|
|
* and return in @angle the relative angle from @event1 to @event2. The rotation
|
|
|
|
|
* direction for positive angles is from the positive X axis towards the positive
|
|
|
|
|
* Y axis.
|
2011-08-28 19:26:47 +00:00
|
|
|
|
*
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* Returns: %TRUE if the angle could be calculated.
|
|
|
|
|
**/
|
2011-08-28 19:26:47 +00:00
|
|
|
|
gboolean
|
2020-02-18 03:11:56 +00:00
|
|
|
|
gdk_events_get_angle (GdkEvent *event1,
|
|
|
|
|
GdkEvent *event2,
|
|
|
|
|
gdouble *angle)
|
2011-08-28 19:26:47 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
gdouble x_distance, y_distance, distance;
|
2011-08-28 19:26:47 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
if (!gdk_events_get_axis_distances (event1, event2,
|
|
|
|
|
&x_distance, &y_distance,
|
|
|
|
|
&distance))
|
|
|
|
|
return FALSE;
|
2011-08-28 19:26:47 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
if (angle)
|
2011-08-28 19:26:47 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
*angle = atan2 (x_distance, y_distance);
|
2011-08-28 19:26:47 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
/* Invert angle */
|
|
|
|
|
*angle = (2 * G_PI) - *angle;
|
2011-08-28 19:26:47 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
/* Shift it 90° */
|
|
|
|
|
*angle += G_PI / 2;
|
2011-08-28 19:26:47 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
/* And constraint it to 0°-360° */
|
|
|
|
|
*angle = fmod (*angle, 2 * G_PI);
|
2011-08-28 19:26:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
return TRUE;
|
2011-08-28 19:26:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-21 12:07:11 +00:00
|
|
|
|
/**
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* gdk_events_get_center:
|
|
|
|
|
* @event1: first #GdkEvent
|
|
|
|
|
* @event2: second #GdkEvent
|
|
|
|
|
* @x: (out): return location for the X coordinate of the center
|
|
|
|
|
* @y: (out): return location for the Y coordinate of the center
|
2017-12-26 15:59:38 +00:00
|
|
|
|
*
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* If both events contain X/Y information, the center of both coordinates
|
|
|
|
|
* will be returned in @x and @y.
|
2017-12-26 15:59:38 +00:00
|
|
|
|
*
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* Returns: %TRUE if the center could be calculated.
|
2017-09-21 12:07:11 +00:00
|
|
|
|
**/
|
2017-08-26 02:50:52 +00:00
|
|
|
|
gboolean
|
2020-02-18 03:11:56 +00:00
|
|
|
|
gdk_events_get_center (GdkEvent *event1,
|
|
|
|
|
GdkEvent *event2,
|
|
|
|
|
gdouble *x,
|
|
|
|
|
gdouble *y)
|
2017-08-26 02:50:52 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
gdouble x1, x2, y1, y2;
|
2017-08-26 02:50:52 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
if (!gdk_event_get_position (event1, &x1, &y1) ||
|
|
|
|
|
!gdk_event_get_position (event2, &x2, &y2))
|
|
|
|
|
return FALSE;
|
2017-08-26 02:50:52 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
if (x)
|
|
|
|
|
*x = (x2 + x1) / 2;
|
2017-08-26 02:50:52 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
if (y)
|
|
|
|
|
*y = (y2 + y1) / 2;
|
2017-08-26 02:50:52 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
return TRUE;
|
2017-08-26 02:50:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
static GdkEventSequence *
|
|
|
|
|
gdk_event_sequence_copy (GdkEventSequence *sequence)
|
2011-08-28 19:26:47 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
return sequence;
|
2011-08-28 19:26:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_event_sequence_free (GdkEventSequence *sequence)
|
2012-01-23 22:37:44 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
/* Nothing to free here */
|
|
|
|
|
}
|
2012-01-23 22:37:44 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
G_DEFINE_BOXED_TYPE (GdkEventSequence, gdk_event_sequence,
|
|
|
|
|
gdk_event_sequence_copy,
|
|
|
|
|
gdk_event_sequence_free)
|
2012-01-23 22:37:44 +00:00
|
|
|
|
|
|
|
|
|
|
2015-10-21 00:14:40 +00:00
|
|
|
|
|
2000-07-03 19:00:23 +00:00
|
|
|
|
/**
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* gdk_event_get_axes:
|
2000-07-03 19:00:23 +00:00
|
|
|
|
* @event: a #GdkEvent
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* @axes: (transfer none) (out) (array length=n_axes): the array of values for all axes
|
|
|
|
|
* @n_axes: (out): the length of array
|
2017-12-26 15:59:38 +00:00
|
|
|
|
*
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* Extracts all axis values from an event.
|
2017-12-26 15:59:38 +00:00
|
|
|
|
*
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* Returns: %TRUE on success, otherwise %FALSE
|
2000-07-03 19:00:23 +00:00
|
|
|
|
**/
|
|
|
|
|
gboolean
|
2020-02-18 03:11:56 +00:00
|
|
|
|
gdk_event_get_axes (GdkEvent *event,
|
|
|
|
|
double **axes,
|
|
|
|
|
guint *n_axes)
|
2000-07-03 19:00:23 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
GdkDevice *source_device;
|
2017-12-26 15:59:38 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
if (!event)
|
|
|
|
|
return FALSE;
|
2017-12-26 15:59:38 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
source_device = gdk_event_get_source_device (event);
|
2000-07-03 19:00:23 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
if (!source_device)
|
|
|
|
|
return FALSE;
|
2000-07-03 19:00:23 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
if (event->any.type == GDK_MOTION_NOTIFY)
|
|
|
|
|
{
|
|
|
|
|
*axes = event->motion.axes;
|
|
|
|
|
*n_axes = gdk_device_get_n_axes (source_device);
|
2000-07-03 19:00:23 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2017-10-11 13:55:19 +00:00
|
|
|
|
else if (event->any.type == GDK_BUTTON_PRESS ||
|
2020-02-18 03:11:56 +00:00
|
|
|
|
event->any.type == GDK_BUTTON_RELEASE)
|
2000-07-03 19:00:23 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
*axes = event->button.axes;
|
|
|
|
|
*n_axes = gdk_device_get_n_axes (source_device);
|
|
|
|
|
return TRUE;
|
2000-07-03 19:00:23 +00:00
|
|
|
|
}
|
2017-10-11 13:55:19 +00:00
|
|
|
|
else if (event->any.type == GDK_TOUCH_BEGIN ||
|
|
|
|
|
event->any.type == GDK_TOUCH_UPDATE ||
|
|
|
|
|
event->any.type == GDK_TOUCH_END ||
|
|
|
|
|
event->any.type == GDK_TOUCH_CANCEL)
|
2011-02-28 19:53:42 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
*axes = event->touch.axes;
|
|
|
|
|
*n_axes = gdk_device_get_n_axes (source_device);
|
|
|
|
|
return TRUE;
|
2000-07-03 19:00:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
return FALSE;
|
2000-07-03 19:00:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
|
/**
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* gdk_event_get_motion_history:
|
|
|
|
|
* @event: a #GdkEvent of type %GDK_MOTION_NOTIFY
|
2010-05-25 22:38:44 +00:00
|
|
|
|
*
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* Retrieves the history of the @event motion, as a list of time and
|
|
|
|
|
* coordinates.
|
2010-05-25 22:38:44 +00:00
|
|
|
|
*
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* Returns: (transfer container) (element-type GdkTimeCoord) (nullable): a list
|
|
|
|
|
* of time and coordinates
|
|
|
|
|
*/
|
|
|
|
|
GList *
|
|
|
|
|
gdk_event_get_motion_history (GdkEvent *event)
|
2010-05-25 22:38:44 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
if (event->any.type != GDK_MOTION_NOTIFY)
|
|
|
|
|
return NULL;
|
|
|
|
|
return g_list_reverse (g_list_copy (event->motion.history));
|
2010-05-25 22:38:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
GdkEvent *
|
|
|
|
|
gdk_event_button_new (GdkEventType type,
|
|
|
|
|
GdkSurface *surface,
|
|
|
|
|
GdkDevice *device,
|
|
|
|
|
GdkDevice *source_device,
|
|
|
|
|
GdkDeviceTool *tool,
|
|
|
|
|
guint32 time,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
guint button,
|
|
|
|
|
double x,
|
|
|
|
|
double y,
|
|
|
|
|
double *axes)
|
2010-12-13 01:12:43 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
GdkEventButton *event;
|
2010-12-13 01:12:43 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
g_return_val_if_fail (type == GDK_BUTTON_PRESS ||
|
|
|
|
|
type == GDK_BUTTON_RELEASE, NULL);
|
|
|
|
|
|
|
|
|
|
event = g_new0 (GdkEventButton, 1);
|
|
|
|
|
event->any.ref_count = 1;
|
|
|
|
|
event->any.type = type;
|
2020-02-18 04:08:44 +00:00
|
|
|
|
event->any.time = time;
|
2020-02-18 03:11:56 +00:00
|
|
|
|
event->any.surface = g_object_ref (surface);
|
|
|
|
|
event->any.device = g_object_ref (device);
|
|
|
|
|
event->any.source_device = g_object_ref (source_device);
|
|
|
|
|
event->tool = tool ? g_object_ref (tool) : NULL;
|
|
|
|
|
event->axes = NULL;
|
|
|
|
|
event->state = state;
|
|
|
|
|
event->button = button;
|
|
|
|
|
event->x = x;
|
|
|
|
|
event->y = y;
|
|
|
|
|
event->axes = axes;
|
2010-12-13 01:12:43 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
return (GdkEvent *)event;
|
2010-12-13 01:12:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
GdkEvent *
|
|
|
|
|
gdk_event_motion_new (GdkSurface *surface,
|
|
|
|
|
GdkDevice *device,
|
|
|
|
|
GdkDevice *source_device,
|
|
|
|
|
GdkDeviceTool *tool,
|
|
|
|
|
guint32 time,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
double x,
|
|
|
|
|
double y,
|
|
|
|
|
double *axes)
|
2011-09-27 13:37:28 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
GdkEventMotion *event = g_new0 (GdkEventMotion, 1);
|
2011-09-27 13:37:28 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
event->any.ref_count = 1;
|
|
|
|
|
event->any.type = GDK_MOTION_NOTIFY;
|
2020-02-18 04:08:44 +00:00
|
|
|
|
event->any.time = time;
|
2020-02-18 03:11:56 +00:00
|
|
|
|
event->any.surface = g_object_ref (surface);
|
|
|
|
|
event->any.device = g_object_ref (device);
|
|
|
|
|
event->any.source_device = g_object_ref (source_device);
|
|
|
|
|
event->tool = tool ? g_object_ref (tool) : NULL;
|
|
|
|
|
event->state = state;
|
|
|
|
|
event->x = x;
|
|
|
|
|
event->y = y;
|
|
|
|
|
event->axes = axes;
|
|
|
|
|
event->state = state;
|
2011-09-27 13:37:28 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
return (GdkEvent *)event;
|
|
|
|
|
}
|
2011-09-27 13:37:28 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
GdkEvent *
|
|
|
|
|
gdk_event_crossing_new (GdkEventType type,
|
|
|
|
|
GdkSurface *surface,
|
|
|
|
|
GdkDevice *device,
|
|
|
|
|
GdkDevice *source_device,
|
|
|
|
|
guint32 time,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
double x,
|
|
|
|
|
double y,
|
|
|
|
|
GdkCrossingMode mode,
|
|
|
|
|
GdkNotifyType detail)
|
|
|
|
|
{
|
|
|
|
|
GdkEventCrossing *event;
|
2011-09-27 13:37:28 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
g_return_val_if_fail (type == GDK_ENTER_NOTIFY ||
|
|
|
|
|
type == GDK_LEAVE_NOTIFY, NULL);
|
2011-09-27 13:37:28 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
event = g_new0 (GdkEventCrossing, 1);
|
2011-09-27 13:37:28 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
event->any.ref_count = 1;
|
|
|
|
|
event->any.type = type;
|
2020-02-18 04:08:44 +00:00
|
|
|
|
event->any.time = time;
|
2020-02-18 03:11:56 +00:00
|
|
|
|
event->any.surface = g_object_ref (surface);
|
|
|
|
|
event->any.device = g_object_ref (device);
|
|
|
|
|
event->any.source_device = g_object_ref (source_device);
|
|
|
|
|
event->state = state;
|
|
|
|
|
event->x = x;
|
|
|
|
|
event->y = y;
|
|
|
|
|
event->mode = mode;
|
|
|
|
|
event->detail = detail;
|
2011-09-27 13:37:28 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
return (GdkEvent *)event;
|
2011-09-27 13:37:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
GdkEvent *
|
|
|
|
|
gdk_event_proximity_new (GdkEventType type,
|
|
|
|
|
GdkSurface *surface,
|
|
|
|
|
GdkDevice *device,
|
|
|
|
|
GdkDevice *source_device,
|
|
|
|
|
GdkDeviceTool *tool,
|
|
|
|
|
guint32 time)
|
2010-05-25 22:38:44 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
GdkEventProximity *event;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
g_return_val_if_fail (type == GDK_PROXIMITY_IN ||
|
|
|
|
|
type == GDK_PROXIMITY_OUT, NULL);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
event = g_new0 (GdkEventProximity, 1);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
event->any.ref_count = 1;
|
|
|
|
|
event->any.type = type;
|
2020-02-18 04:08:44 +00:00
|
|
|
|
event->any.time = time;
|
2020-02-18 03:11:56 +00:00
|
|
|
|
event->any.surface = g_object_ref (surface);
|
|
|
|
|
event->any.device = g_object_ref (device);
|
|
|
|
|
event->any.source_device = g_object_ref (source_device);
|
|
|
|
|
event->tool = tool ? g_object_ref (tool) : NULL;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
return (GdkEvent *)event;
|
|
|
|
|
}
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
GdkEvent *
|
|
|
|
|
gdk_event_key_new (GdkEventType type,
|
|
|
|
|
GdkSurface *surface,
|
|
|
|
|
GdkDevice *device,
|
|
|
|
|
GdkDevice *source_device,
|
|
|
|
|
guint32 time,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
guint keyval,
|
|
|
|
|
guint16 keycode,
|
|
|
|
|
guint16 scancode,
|
|
|
|
|
guint8 group,
|
|
|
|
|
gboolean is_modifier)
|
|
|
|
|
{
|
|
|
|
|
GdkEventKey *event;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
g_return_val_if_fail (type == GDK_KEY_PRESS ||
|
|
|
|
|
type == GDK_KEY_RELEASE, NULL);
|
|
|
|
|
|
|
|
|
|
event = g_new0 (GdkEventKey, 1);
|
|
|
|
|
|
|
|
|
|
event->any.ref_count = 1;
|
|
|
|
|
event->any.type = type;
|
2020-02-18 04:08:44 +00:00
|
|
|
|
event->any.time = time;
|
2020-02-18 03:11:56 +00:00
|
|
|
|
event->any.surface = g_object_ref (surface);
|
|
|
|
|
event->any.device = g_object_ref (device);
|
|
|
|
|
event->any.source_device = g_object_ref (source_device);
|
|
|
|
|
event->state = state;
|
|
|
|
|
event->keyval = keyval;
|
|
|
|
|
event->hardware_keycode = keycode;
|
|
|
|
|
event->key_scancode = scancode;
|
|
|
|
|
event->group = group;
|
2020-02-18 04:08:44 +00:00
|
|
|
|
event->any.key_is_modifier = is_modifier;
|
2020-02-18 03:11:56 +00:00
|
|
|
|
|
|
|
|
|
return (GdkEvent *)event;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
GdkEvent *
|
|
|
|
|
gdk_event_configure_new (GdkSurface *surface,
|
|
|
|
|
int width,
|
|
|
|
|
int height)
|
2010-05-25 22:38:44 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
GdkEventConfigure *event = g_new0 (GdkEventConfigure, 1);
|
|
|
|
|
|
|
|
|
|
event->any.ref_count = 1;
|
|
|
|
|
event->any.type = GDK_CONFIGURE;
|
2020-02-18 04:08:44 +00:00
|
|
|
|
event->any.time = GDK_CURRENT_TIME;
|
2020-02-18 03:11:56 +00:00
|
|
|
|
event->any.surface = g_object_ref (surface);
|
|
|
|
|
event->width = width;
|
|
|
|
|
event->height = height;
|
|
|
|
|
|
|
|
|
|
return (GdkEvent *)event;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
GdkEvent *
|
|
|
|
|
gdk_event_delete_new (GdkSurface *surface)
|
2010-05-25 22:38:44 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
GdkEventAny *event = g_new0 (GdkEventAny, 1);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
event->ref_count = 1;
|
|
|
|
|
event->type = GDK_DELETE;
|
2020-02-18 04:08:44 +00:00
|
|
|
|
event->time = GDK_CURRENT_TIME;
|
2020-02-18 03:11:56 +00:00
|
|
|
|
event->surface = g_object_ref (surface);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
return (GdkEvent *)event;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
GdkEvent *
|
|
|
|
|
gdk_event_focus_new (GdkSurface *surface,
|
|
|
|
|
GdkDevice *device,
|
|
|
|
|
GdkDevice *source_device,
|
|
|
|
|
gboolean focus_in)
|
2010-05-25 22:38:44 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
GdkEventFocus *event = g_new0 (GdkEventFocus, 1);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
event->any.ref_count = 1;
|
|
|
|
|
event->any.type = GDK_FOCUS_CHANGE;
|
2020-02-18 04:08:44 +00:00
|
|
|
|
event->any.time = GDK_CURRENT_TIME;
|
2020-02-18 03:11:56 +00:00
|
|
|
|
event->any.surface = g_object_ref (surface);
|
|
|
|
|
event->any.device = g_object_ref (device);
|
|
|
|
|
event->any.source_device = g_object_ref (source_device);
|
2020-02-18 04:08:44 +00:00
|
|
|
|
event->any.focus_in = focus_in;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
return (GdkEvent *)event;
|
2007-02-06 14:53:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
GdkEvent *
|
|
|
|
|
gdk_event_scroll_new (GdkSurface *surface,
|
|
|
|
|
GdkDevice *device,
|
|
|
|
|
GdkDevice *source_device,
|
|
|
|
|
GdkDeviceTool *tool,
|
|
|
|
|
guint32 time,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
double delta_x,
|
|
|
|
|
double delta_y,
|
|
|
|
|
gboolean is_stop)
|
2002-10-02 21:39:09 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
GdkEventScroll *event = g_new0 (GdkEventScroll, 1);
|
2002-10-02 21:39:09 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
event->any.ref_count = 1;
|
|
|
|
|
event->any.type = GDK_SCROLL;
|
2020-02-18 04:08:44 +00:00
|
|
|
|
event->any.time = time;
|
2020-02-18 03:11:56 +00:00
|
|
|
|
event->any.surface = g_object_ref (surface);
|
|
|
|
|
event->any.device = g_object_ref (device);
|
|
|
|
|
event->any.source_device = g_object_ref (source_device);
|
|
|
|
|
event->tool = tool ? g_object_ref (tool) : NULL;
|
|
|
|
|
event->state = state;
|
|
|
|
|
event->x = NAN;
|
|
|
|
|
event->y = NAN;
|
|
|
|
|
event->direction = GDK_SCROLL_SMOOTH;
|
|
|
|
|
event->delta_x = delta_x;
|
|
|
|
|
event->delta_y = delta_y;
|
2020-02-18 04:08:44 +00:00
|
|
|
|
event->any.scroll_is_stop = is_stop;
|
2002-10-02 21:39:09 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
return (GdkEvent *)event;
|
2002-10-02 21:39:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
GdkEvent *
|
|
|
|
|
gdk_event_discrete_scroll_new (GdkSurface *surface,
|
|
|
|
|
GdkDevice *device,
|
|
|
|
|
GdkDevice *source_device,
|
|
|
|
|
GdkDeviceTool *tool,
|
|
|
|
|
guint32 time,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
GdkScrollDirection direction,
|
|
|
|
|
gboolean emulated)
|
2011-03-01 07:36:54 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
GdkEventScroll *event = g_new0 (GdkEventScroll, 1);
|
2011-03-01 07:36:54 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
event->any.ref_count = 1;
|
|
|
|
|
event->any.type = GDK_SCROLL;
|
2020-02-18 04:08:44 +00:00
|
|
|
|
event->any.time = time;
|
2020-02-18 03:11:56 +00:00
|
|
|
|
event->any.surface = g_object_ref (surface);
|
|
|
|
|
event->any.device = g_object_ref (device);
|
|
|
|
|
event->any.source_device = g_object_ref (source_device);
|
|
|
|
|
event->tool = tool ? g_object_ref (tool) : NULL;
|
|
|
|
|
event->state = state;
|
|
|
|
|
event->x = NAN;
|
|
|
|
|
event->y = NAN;
|
|
|
|
|
event->direction = direction;
|
2020-02-18 04:08:44 +00:00
|
|
|
|
event->any.pointer_emulated = emulated;
|
2011-02-28 19:53:42 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
return (GdkEvent *)event;
|
2011-03-01 07:36:54 +00:00
|
|
|
|
}
|
1998-12-15 13:54:20 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
GdkEvent *
|
|
|
|
|
gdk_event_touch_new (GdkEventType type,
|
|
|
|
|
GdkEventSequence *sequence,
|
|
|
|
|
GdkSurface *surface,
|
|
|
|
|
GdkDevice *device,
|
|
|
|
|
GdkDevice *source_device,
|
|
|
|
|
guint32 time,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
double x,
|
|
|
|
|
double y,
|
|
|
|
|
double *axes,
|
|
|
|
|
gboolean emulating)
|
2014-05-20 12:07:16 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
GdkEventTouch *event;
|
2014-05-20 12:07:16 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
g_return_val_if_fail (type == GDK_TOUCH_BEGIN ||
|
|
|
|
|
type == GDK_TOUCH_END ||
|
|
|
|
|
type == GDK_TOUCH_UPDATE ||
|
|
|
|
|
type == GDK_TOUCH_CANCEL, NULL);
|
2014-05-20 12:07:16 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
event = g_new0 (GdkEventTouch, 1);
|
2014-05-20 12:07:16 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
event->any.ref_count = 1;
|
|
|
|
|
event->any.type = type;
|
2020-02-18 04:08:44 +00:00
|
|
|
|
event->any.time = time;
|
2020-02-18 03:11:56 +00:00
|
|
|
|
event->any.surface = g_object_ref (surface);
|
|
|
|
|
event->any.device = g_object_ref (device);
|
|
|
|
|
event->any.source_device = g_object_ref (source_device);
|
|
|
|
|
event->sequence = sequence;
|
|
|
|
|
event->state = state;
|
|
|
|
|
event->x = x;
|
|
|
|
|
event->y = y;
|
|
|
|
|
event->axes = axes;
|
2020-02-18 04:08:44 +00:00
|
|
|
|
event->any.touch_emulating = emulating;
|
|
|
|
|
event->any.pointer_emulated = emulating;
|
2013-08-13 23:06:48 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
return (GdkEvent *)event;
|
2013-08-13 23:06:48 +00:00
|
|
|
|
}
|
2015-11-26 18:53:09 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
GdkEvent *
|
|
|
|
|
gdk_event_touchpad_swipe_new (GdkSurface *surface,
|
|
|
|
|
GdkDevice *device,
|
|
|
|
|
GdkDevice *source_device,
|
|
|
|
|
guint32 time,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
GdkTouchpadGesturePhase phase,
|
|
|
|
|
double x,
|
|
|
|
|
double y,
|
|
|
|
|
int n_fingers,
|
|
|
|
|
double dx,
|
|
|
|
|
double dy)
|
2015-11-26 18:53:09 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
GdkEventTouchpadSwipe *event = g_new0 (GdkEventTouchpadSwipe, 1);
|
2015-11-26 18:53:09 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
event->any.ref_count = 1;
|
|
|
|
|
event->any.type = GDK_TOUCHPAD_SWIPE;
|
2020-02-18 04:08:44 +00:00
|
|
|
|
event->any.time = time;
|
2020-02-18 03:11:56 +00:00
|
|
|
|
event->any.surface = g_object_ref (surface);
|
|
|
|
|
event->any.device = g_object_ref (device);
|
|
|
|
|
event->any.source_device = g_object_ref (source_device);
|
|
|
|
|
event->state = state;
|
|
|
|
|
event->phase = phase;
|
|
|
|
|
event->x = x;
|
|
|
|
|
event->y = y;
|
|
|
|
|
event->dx = dx;
|
|
|
|
|
event->dy = dy;
|
|
|
|
|
event->n_fingers = n_fingers;
|
2015-12-16 18:00:39 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
return (GdkEvent *)event;
|
2015-11-26 18:53:09 +00:00
|
|
|
|
}
|
2015-01-06 13:52:42 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
GdkEvent *
|
|
|
|
|
gdk_event_touchpad_pinch_new (GdkSurface *surface,
|
|
|
|
|
GdkDevice *device,
|
|
|
|
|
GdkDevice *source_device,
|
|
|
|
|
guint32 time,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
GdkTouchpadGesturePhase phase,
|
|
|
|
|
double x,
|
|
|
|
|
double y,
|
|
|
|
|
int n_fingers,
|
|
|
|
|
double dx,
|
|
|
|
|
double dy,
|
|
|
|
|
double scale,
|
|
|
|
|
double angle_delta)
|
|
|
|
|
{
|
|
|
|
|
GdkEventTouchpadPinch *event = g_new0 (GdkEventTouchpadPinch, 1);
|
|
|
|
|
|
|
|
|
|
event->any.ref_count = 1;
|
|
|
|
|
event->any.type = GDK_TOUCHPAD_PINCH;
|
2020-02-18 04:08:44 +00:00
|
|
|
|
event->any.time = time;
|
2020-02-18 03:11:56 +00:00
|
|
|
|
event->any.surface = g_object_ref (surface);
|
|
|
|
|
event->any.device = g_object_ref (device);
|
|
|
|
|
event->any.source_device = g_object_ref (source_device);
|
|
|
|
|
event->state = state;
|
|
|
|
|
event->phase = phase;
|
|
|
|
|
event->x = x;
|
|
|
|
|
event->y = y;
|
|
|
|
|
event->dx = dx;
|
|
|
|
|
event->dy = dy;
|
|
|
|
|
event->n_fingers = n_fingers;
|
|
|
|
|
event->scale = scale;
|
|
|
|
|
event->angle_delta = angle_delta;
|
|
|
|
|
|
|
|
|
|
return (GdkEvent *)event;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GdkEvent *
|
|
|
|
|
gdk_event_pad_ring_new (GdkSurface *surface,
|
|
|
|
|
GdkDevice *device,
|
|
|
|
|
GdkDevice *source_device,
|
|
|
|
|
guint32 time,
|
|
|
|
|
guint group,
|
|
|
|
|
guint index,
|
|
|
|
|
guint mode,
|
|
|
|
|
double value)
|
|
|
|
|
{
|
|
|
|
|
GdkEventPadAxis *event = g_new0 (GdkEventPadAxis, 1);
|
|
|
|
|
|
|
|
|
|
event->any.ref_count = 1;
|
|
|
|
|
event->any.type = GDK_PAD_RING;
|
2020-02-18 04:08:44 +00:00
|
|
|
|
event->any.time = time;
|
2020-02-18 03:11:56 +00:00
|
|
|
|
event->any.surface = g_object_ref (surface);
|
|
|
|
|
event->any.device = g_object_ref (device);
|
|
|
|
|
event->any.source_device = g_object_ref (source_device);
|
|
|
|
|
event->group = group;
|
|
|
|
|
event->index = index;
|
|
|
|
|
event->mode = mode;
|
|
|
|
|
event->value = value;
|
|
|
|
|
|
|
|
|
|
return (GdkEvent *)event;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GdkEvent *
|
|
|
|
|
gdk_event_pad_strip_new (GdkSurface *surface,
|
|
|
|
|
GdkDevice *device,
|
|
|
|
|
GdkDevice *source_device,
|
|
|
|
|
guint32 time,
|
|
|
|
|
guint group,
|
|
|
|
|
guint index,
|
|
|
|
|
guint mode,
|
|
|
|
|
double value)
|
|
|
|
|
{
|
|
|
|
|
GdkEventPadAxis *event = g_new0 (GdkEventPadAxis, 1);
|
|
|
|
|
|
|
|
|
|
event->any.ref_count = 1;
|
|
|
|
|
event->any.type = GDK_PAD_STRIP;
|
2020-02-18 04:08:44 +00:00
|
|
|
|
event->any.time = time;
|
2020-02-18 03:11:56 +00:00
|
|
|
|
event->any.surface = g_object_ref (surface);
|
|
|
|
|
event->any.device = g_object_ref (device);
|
|
|
|
|
event->any.source_device = g_object_ref (source_device);
|
|
|
|
|
event->group = group;
|
|
|
|
|
event->index = index;
|
|
|
|
|
event->mode = mode;
|
|
|
|
|
event->value = value;
|
|
|
|
|
|
|
|
|
|
return (GdkEvent *)event;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GdkEvent *
|
|
|
|
|
gdk_event_pad_button_new (GdkEventType type,
|
|
|
|
|
GdkSurface *surface,
|
|
|
|
|
GdkDevice *device,
|
|
|
|
|
GdkDevice *source_device,
|
|
|
|
|
guint32 time,
|
|
|
|
|
guint group,
|
|
|
|
|
guint button,
|
|
|
|
|
guint mode)
|
|
|
|
|
{
|
|
|
|
|
GdkEventPadButton *event;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (type == GDK_PAD_BUTTON_PRESS ||
|
|
|
|
|
type == GDK_PAD_BUTTON_RELEASE, NULL);
|
|
|
|
|
|
|
|
|
|
event = g_new0 (GdkEventPadButton, 1);
|
|
|
|
|
|
|
|
|
|
event->any.ref_count = 1;
|
|
|
|
|
event->any.type = type;
|
2020-02-18 04:08:44 +00:00
|
|
|
|
event->any.time = time;
|
2020-02-18 03:11:56 +00:00
|
|
|
|
event->any.surface = g_object_ref (surface);
|
|
|
|
|
event->any.device = g_object_ref (device);
|
|
|
|
|
event->any.source_device = g_object_ref (source_device);
|
|
|
|
|
event->group = group;
|
|
|
|
|
event->button = button;
|
|
|
|
|
event->mode = mode;
|
|
|
|
|
|
|
|
|
|
return (GdkEvent *)event;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GdkEvent *
|
|
|
|
|
gdk_event_pad_group_mode_new (GdkSurface *surface,
|
|
|
|
|
GdkDevice *device,
|
|
|
|
|
GdkDevice *source_device,
|
|
|
|
|
guint32 time,
|
|
|
|
|
guint group,
|
|
|
|
|
guint mode)
|
|
|
|
|
{
|
|
|
|
|
GdkEventPadGroupMode *event = g_new0 (GdkEventPadGroupMode, 1);
|
|
|
|
|
|
|
|
|
|
event->any.ref_count = 1;
|
|
|
|
|
event->any.type = GDK_PAD_GROUP_MODE;
|
2020-02-18 04:08:44 +00:00
|
|
|
|
event->any.time = time;
|
2020-02-18 03:11:56 +00:00
|
|
|
|
event->any.surface = g_object_ref (surface);
|
|
|
|
|
event->any.device = g_object_ref (device);
|
|
|
|
|
event->any.source_device = g_object_ref (source_device);
|
|
|
|
|
event->group = group;
|
|
|
|
|
event->mode = mode;
|
|
|
|
|
|
|
|
|
|
return (GdkEvent *)event;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GdkEvent *
|
|
|
|
|
gdk_event_drag_new (GdkEventType type,
|
|
|
|
|
GdkSurface *surface,
|
|
|
|
|
GdkDevice *device,
|
|
|
|
|
GdkDrop *drop,
|
|
|
|
|
guint32 time,
|
|
|
|
|
double x,
|
|
|
|
|
double y)
|
|
|
|
|
{
|
|
|
|
|
GdkEventDND *event;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (type == GDK_DRAG_ENTER ||
|
|
|
|
|
type == GDK_DRAG_MOTION ||
|
|
|
|
|
type == GDK_DRAG_LEAVE ||
|
|
|
|
|
type == GDK_DROP_START, NULL);
|
|
|
|
|
|
|
|
|
|
event = g_new0 (GdkEventDND, 1);
|
|
|
|
|
|
|
|
|
|
event->any.ref_count = 1;
|
|
|
|
|
event->any.type = type;
|
2020-02-18 04:08:44 +00:00
|
|
|
|
event->any.time = time;
|
2020-02-18 03:11:56 +00:00
|
|
|
|
event->any.surface = g_object_ref (surface);
|
|
|
|
|
event->any.device = g_object_ref (device);
|
|
|
|
|
event->drop = g_object_ref (drop);
|
|
|
|
|
event->x = x;
|
|
|
|
|
event->y = y;
|
|
|
|
|
|
|
|
|
|
return (GdkEvent *)event;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GdkEvent *
|
|
|
|
|
gdk_event_grab_broken_new (GdkSurface *surface,
|
|
|
|
|
GdkDevice *device,
|
|
|
|
|
GdkDevice *source_device,
|
|
|
|
|
GdkSurface *grab_surface,
|
|
|
|
|
gboolean implicit)
|
|
|
|
|
{
|
|
|
|
|
GdkEventGrabBroken *event = g_new0 (GdkEventGrabBroken, 1);
|
|
|
|
|
|
|
|
|
|
event->any.ref_count = 1;
|
|
|
|
|
event->any.type = GDK_GRAB_BROKEN;
|
2020-02-18 04:08:44 +00:00
|
|
|
|
event->any.time = GDK_CURRENT_TIME;
|
2020-02-18 03:11:56 +00:00
|
|
|
|
event->any.surface = g_object_ref (surface);
|
|
|
|
|
event->any.device = g_object_ref (device);
|
|
|
|
|
event->any.source_device = g_object_ref (source_device);
|
|
|
|
|
event->grab_surface = grab_surface;
|
|
|
|
|
event->implicit = implicit;
|
|
|
|
|
event->keyboard = gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD;
|
|
|
|
|
|
|
|
|
|
return (GdkEvent *)event;
|
2015-01-06 13:52:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-04-21 13:30:58 +00:00
|
|
|
|
/**
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* gdk_event_get_event_type:
|
2016-04-21 13:30:58 +00:00
|
|
|
|
* @event: a #GdkEvent
|
|
|
|
|
*
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* Retrieves the type of the event.
|
2016-04-21 13:30:58 +00:00
|
|
|
|
*
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* Returns: a #GdkEventType
|
|
|
|
|
*/
|
|
|
|
|
GdkEventType
|
|
|
|
|
gdk_event_get_event_type (GdkEvent *event)
|
2016-04-21 13:30:58 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
return event->any.type;
|
2016-04-21 13:30:58 +00:00
|
|
|
|
}
|
2017-05-04 11:41:29 +00:00
|
|
|
|
|
2017-12-26 15:30:50 +00:00
|
|
|
|
/**
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* gdk_event_get_surface:
|
2017-12-26 15:30:50 +00:00
|
|
|
|
* @event: a #GdkEvent
|
|
|
|
|
*
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* Extracts the #GdkSurface associated with an event.
|
2017-12-26 15:30:50 +00:00
|
|
|
|
*
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* Returns: (transfer none): The #GdkSurface associated with the event
|
2017-12-26 15:30:50 +00:00
|
|
|
|
*/
|
2020-02-18 03:11:56 +00:00
|
|
|
|
GdkSurface *
|
|
|
|
|
gdk_event_get_surface (GdkEvent *event)
|
2017-08-26 02:50:52 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
return event->any.surface;
|
2017-08-26 02:50:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-21 12:07:11 +00:00
|
|
|
|
/**
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* gdk_event_get_device:
|
|
|
|
|
* @event: a #GdkEvent.
|
2017-12-26 15:59:38 +00:00
|
|
|
|
*
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* Returns the device of an event.
|
2017-12-26 15:59:38 +00:00
|
|
|
|
*
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* Returns: (nullable) (transfer none): a #GdkDevice, or %NULL.
|
2017-09-21 12:07:11 +00:00
|
|
|
|
**/
|
2020-02-18 03:11:56 +00:00
|
|
|
|
GdkDevice *
|
|
|
|
|
gdk_event_get_device (GdkEvent *event)
|
2017-08-26 02:50:52 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
return event->any.device;
|
2017-08-26 02:50:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-21 12:07:11 +00:00
|
|
|
|
/**
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* gdk_event_get_source_device:
|
2017-09-21 12:07:11 +00:00
|
|
|
|
* @event: a #GdkEvent
|
2017-12-26 15:59:38 +00:00
|
|
|
|
*
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* This function returns the hardware (slave) #GdkDevice that has
|
|
|
|
|
* triggered the event, falling back to the virtual (master) device
|
|
|
|
|
* (as in gdk_event_get_device()) if the event wasn’t caused by
|
|
|
|
|
* interaction with a hardware device. This may happen for example
|
|
|
|
|
* in synthesized crossing events after a #GdkSurface updates its
|
|
|
|
|
* geometry or a grab is acquired/released.
|
2017-12-26 15:59:38 +00:00
|
|
|
|
*
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* If the event does not contain a device field, this function will
|
|
|
|
|
* return %NULL.
|
|
|
|
|
*
|
|
|
|
|
* Returns: (nullable) (transfer none): a #GdkDevice, or %NULL.
|
2017-09-21 12:07:11 +00:00
|
|
|
|
**/
|
2020-02-18 03:11:56 +00:00
|
|
|
|
GdkDevice *
|
|
|
|
|
gdk_event_get_source_device (GdkEvent *event)
|
2017-08-26 02:50:52 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
if (event->any.source_device)
|
|
|
|
|
return event->any.source_device;
|
2017-08-26 02:50:52 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
return event->any.device;
|
2017-08-26 02:50:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-21 12:07:11 +00:00
|
|
|
|
/**
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* gdk_event_get_device_tool:
|
2017-09-21 12:07:11 +00:00
|
|
|
|
* @event: a #GdkEvent
|
2017-12-26 15:59:38 +00:00
|
|
|
|
*
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* If the event was generated by a device that supports
|
|
|
|
|
* different tools (eg. a tablet), this function will
|
|
|
|
|
* return a #GdkDeviceTool representing the tool that
|
|
|
|
|
* caused the event. Otherwise, %NULL will be returned.
|
2017-12-26 15:59:38 +00:00
|
|
|
|
*
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* Note: the #GdkDeviceTools will be constant during
|
|
|
|
|
* the application lifetime, if settings must be stored
|
|
|
|
|
* persistently across runs, see gdk_device_tool_get_serial()
|
2017-12-26 15:59:38 +00:00
|
|
|
|
*
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* Returns: (transfer none): The current device tool, or %NULL
|
2017-09-21 12:07:11 +00:00
|
|
|
|
**/
|
2020-02-18 03:11:56 +00:00
|
|
|
|
GdkDeviceTool *
|
|
|
|
|
gdk_event_get_device_tool (GdkEvent *event)
|
2017-08-26 14:50:15 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
if (event->any.type == GDK_BUTTON_PRESS ||
|
|
|
|
|
event->any.type == GDK_BUTTON_RELEASE)
|
|
|
|
|
return event->button.tool;
|
|
|
|
|
else if (event->any.type == GDK_MOTION_NOTIFY)
|
|
|
|
|
return event->motion.tool;
|
|
|
|
|
else if (event->any.type == GDK_PROXIMITY_IN ||
|
|
|
|
|
event->any.type == GDK_PROXIMITY_OUT)
|
|
|
|
|
return event->proximity.tool;
|
|
|
|
|
else if (event->any.type == GDK_SCROLL)
|
|
|
|
|
return event->scroll.tool;
|
2017-08-26 14:50:15 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
return NULL;
|
2017-08-26 14:50:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-21 12:07:11 +00:00
|
|
|
|
/**
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* gdk_event_get_time:
|
2017-09-21 12:07:11 +00:00
|
|
|
|
* @event: a #GdkEvent
|
2020-02-18 03:11:56 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns the time stamp from @event, if there is one; otherwise
|
|
|
|
|
* returns #GDK_CURRENT_TIME.
|
|
|
|
|
*
|
|
|
|
|
* Returns: time stamp field from @event
|
2017-09-21 12:07:11 +00:00
|
|
|
|
**/
|
2020-02-18 03:11:56 +00:00
|
|
|
|
guint32
|
|
|
|
|
gdk_event_get_time (GdkEvent *event)
|
2017-08-26 14:50:15 +00:00
|
|
|
|
{
|
2020-02-18 04:08:44 +00:00
|
|
|
|
return event->any.time;
|
2017-08-26 14:50:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-21 12:07:11 +00:00
|
|
|
|
/**
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* gdk_event_get_display:
|
2017-09-21 12:07:11 +00:00
|
|
|
|
* @event: a #GdkEvent
|
2017-12-26 15:59:38 +00:00
|
|
|
|
*
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* Retrieves the #GdkDisplay associated to the @event.
|
2017-12-26 15:59:38 +00:00
|
|
|
|
*
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* Returns: (transfer none) (nullable): a #GdkDisplay
|
|
|
|
|
*/
|
|
|
|
|
GdkDisplay *
|
|
|
|
|
gdk_event_get_display (GdkEvent *event)
|
2017-08-26 14:50:15 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
if (event->any.surface)
|
|
|
|
|
return gdk_surface_get_display (event->any.surface);
|
2017-08-26 14:50:15 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
return NULL;
|
2017-08-26 14:50:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-21 12:07:11 +00:00
|
|
|
|
/**
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* gdk_event_get_event_sequence:
|
2017-09-21 12:07:11 +00:00
|
|
|
|
* @event: a #GdkEvent
|
2017-12-26 15:59:38 +00:00
|
|
|
|
*
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* If @event is a touch event, returns the #GdkEventSequence
|
|
|
|
|
* to which the event belongs. Otherwise, return %NULL.
|
2017-12-26 15:59:38 +00:00
|
|
|
|
*
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* Returns: (transfer none): the event sequence that the event belongs to
|
|
|
|
|
*/
|
|
|
|
|
GdkEventSequence *
|
|
|
|
|
gdk_event_get_event_sequence (GdkEvent *event)
|
2017-08-26 14:50:15 +00:00
|
|
|
|
{
|
2020-02-19 03:43:03 +00:00
|
|
|
|
switch ((int) event->any.type)
|
|
|
|
|
{
|
|
|
|
|
case GDK_TOUCH_BEGIN:
|
|
|
|
|
case GDK_TOUCH_UPDATE:
|
|
|
|
|
case GDK_TOUCH_END:
|
|
|
|
|
case GDK_TOUCH_CANCEL:
|
|
|
|
|
return event->touch.sequence;
|
2017-08-26 14:50:15 +00:00
|
|
|
|
|
2020-02-19 03:43:03 +00:00
|
|
|
|
case GDK_DRAG_ENTER:
|
|
|
|
|
case GDK_DRAG_LEAVE:
|
|
|
|
|
case GDK_DRAG_MOTION:
|
|
|
|
|
case GDK_DROP_START:
|
|
|
|
|
return (GdkEventSequence *) event->dnd.drop;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2017-08-26 14:50:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-21 12:07:11 +00:00
|
|
|
|
/**
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* gdk_event_get_modifier_state:
|
2017-09-21 12:07:11 +00:00
|
|
|
|
* @event: a #GdkEvent
|
2017-12-26 15:59:38 +00:00
|
|
|
|
*
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* Returns the modifier state field of an event.
|
2017-12-26 15:59:38 +00:00
|
|
|
|
*
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* Returns: the modifier state of @event
|
2017-09-21 12:07:11 +00:00
|
|
|
|
**/
|
2020-02-18 03:11:56 +00:00
|
|
|
|
GdkModifierType
|
|
|
|
|
gdk_event_get_modifier_state (GdkEvent *event)
|
|
|
|
|
{
|
|
|
|
|
#if 0
|
|
|
|
|
g_return_val_if_fail (event->any.type == GDK_ENTER_NOTIFY ||
|
|
|
|
|
event->any.type == GDK_LEAVE_NOTIFY ||
|
|
|
|
|
event->any.type == GDK_BUTTON_PRESS ||
|
|
|
|
|
event->any.type == GDK_BUTTON_RELEASE ||
|
|
|
|
|
event->any.type == GDK_MOTION_NOTIFY ||
|
|
|
|
|
event->any.type == GDK_TOUCH_BEGIN ||
|
|
|
|
|
event->any.type == GDK_TOUCH_UPDATE ||
|
|
|
|
|
event->any.type == GDK_TOUCH_END ||
|
|
|
|
|
event->any.type == GDK_TOUCH_CANCEL ||
|
|
|
|
|
event->any.type == GDK_TOUCHPAD_SWIPE ||
|
|
|
|
|
event->any.type == GDK_TOUCHPAD_PINCH||
|
|
|
|
|
event->any.type == GDK_SCROLL ||
|
|
|
|
|
event->any.type == GDK_KEY_PRESS ||
|
|
|
|
|
event->any.type == GDK_KEY_RELEASE, 0);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
switch ((int)event->any.type)
|
2017-08-26 14:50:15 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
case GDK_ENTER_NOTIFY:
|
|
|
|
|
case GDK_LEAVE_NOTIFY:
|
|
|
|
|
return event->crossing.state;
|
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
|
return event->button.state;
|
|
|
|
|
case GDK_MOTION_NOTIFY:
|
|
|
|
|
return event->motion.state;
|
|
|
|
|
case GDK_TOUCH_BEGIN:
|
|
|
|
|
case GDK_TOUCH_UPDATE:
|
|
|
|
|
case GDK_TOUCH_END:
|
|
|
|
|
case GDK_TOUCH_CANCEL:
|
|
|
|
|
return event->touch.state;
|
|
|
|
|
case GDK_TOUCHPAD_SWIPE:
|
|
|
|
|
return event->touchpad_swipe.state;
|
|
|
|
|
case GDK_TOUCHPAD_PINCH:
|
|
|
|
|
return event->touchpad_pinch.state;
|
|
|
|
|
case GDK_SCROLL:
|
|
|
|
|
return event->scroll.state;
|
|
|
|
|
case GDK_KEY_PRESS:
|
|
|
|
|
case GDK_KEY_RELEASE:
|
|
|
|
|
return event->key.state;
|
|
|
|
|
default:
|
|
|
|
|
/* no state field */
|
|
|
|
|
break;
|
2017-08-26 14:50:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
return 0;
|
2017-08-26 14:50:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-21 12:07:11 +00:00
|
|
|
|
/**
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* gdk_event_get_position:
|
2017-09-21 12:07:11 +00:00
|
|
|
|
* @event: a #GdkEvent
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* @x: (out): location to put event surface x coordinate
|
|
|
|
|
* @y: (out): location to put event surface y coordinate
|
2017-12-26 15:59:38 +00:00
|
|
|
|
*
|
2020-02-18 03:11:56 +00:00
|
|
|
|
* Extract the event surface relative x/y coordinates from an event.
|
2017-09-21 12:07:11 +00:00
|
|
|
|
**/
|
2017-08-26 14:50:15 +00:00
|
|
|
|
gboolean
|
2020-02-18 03:11:56 +00:00
|
|
|
|
gdk_event_get_position (GdkEvent *event,
|
|
|
|
|
double *x,
|
|
|
|
|
double *y)
|
|
|
|
|
{
|
|
|
|
|
#if 0
|
|
|
|
|
g_return_if_fail (event->any.type == GDK_ENTER_NOTIFY ||
|
|
|
|
|
event->any.type == GDK_LEAVE_NOTIFY ||
|
|
|
|
|
event->any.type == GDK_BUTTON_PRESS ||
|
|
|
|
|
event->any.type == GDK_BUTTON_RELEASE ||
|
|
|
|
|
event->any.type == GDK_MOTION_NOTIFY ||
|
|
|
|
|
event->any.type == GDK_TOUCH_BEGIN ||
|
|
|
|
|
event->any.type == GDK_TOUCH_UPDATE ||
|
|
|
|
|
event->any.type == GDK_TOUCH_END ||
|
|
|
|
|
event->any.type == GDK_TOUCH_CANCEL ||
|
|
|
|
|
event->any.type == GDK_TOUCHPAD_SWIPE ||
|
|
|
|
|
event->any.type == GDK_TOUCHPAD_PINCH||
|
|
|
|
|
event->any.type == GDK_DRAG_ENTER ||
|
|
|
|
|
event->any.type == GDK_DRAG_LEAVE ||
|
|
|
|
|
event->any.type == GDK_DRAG_MOTION ||
|
|
|
|
|
event->any.type == GDK_DROP_START);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
switch ((int)event->any.type)
|
2017-08-26 14:50:15 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
case GDK_ENTER_NOTIFY:
|
|
|
|
|
case GDK_LEAVE_NOTIFY:
|
|
|
|
|
*x = event->crossing.x;
|
|
|
|
|
*y = event->crossing.y;
|
|
|
|
|
break;
|
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
|
*x = event->button.x;
|
|
|
|
|
*y = event->button.y;
|
|
|
|
|
break;
|
|
|
|
|
case GDK_MOTION_NOTIFY:
|
|
|
|
|
*x = event->motion.x;
|
|
|
|
|
*y = event->motion.y;
|
|
|
|
|
break;
|
|
|
|
|
case GDK_TOUCH_BEGIN:
|
|
|
|
|
case GDK_TOUCH_UPDATE:
|
|
|
|
|
case GDK_TOUCH_END:
|
|
|
|
|
case GDK_TOUCH_CANCEL:
|
|
|
|
|
*x = event->touch.x;
|
|
|
|
|
*y = event->touch.y;
|
|
|
|
|
break;
|
|
|
|
|
case GDK_TOUCHPAD_SWIPE:
|
|
|
|
|
*x = event->touchpad_swipe.x;
|
|
|
|
|
*y = event->touchpad_swipe.y;
|
|
|
|
|
break;
|
|
|
|
|
case GDK_TOUCHPAD_PINCH:
|
|
|
|
|
*x = event->touchpad_pinch.x;
|
|
|
|
|
*y = event->touchpad_pinch.y;
|
|
|
|
|
break;
|
|
|
|
|
case GDK_DRAG_ENTER:
|
|
|
|
|
case GDK_DRAG_LEAVE:
|
|
|
|
|
case GDK_DRAG_MOTION:
|
|
|
|
|
case GDK_DROP_START:
|
|
|
|
|
*x = event->dnd.x;
|
|
|
|
|
*y = event->dnd.y;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
/* no position */
|
|
|
|
|
*x = NAN;
|
|
|
|
|
*y = NAN;
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2020-02-14 13:09:59 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2020-02-14 13:09:59 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* gdk_button_event_get_button:
|
|
|
|
|
* @event: a button event
|
|
|
|
|
*
|
|
|
|
|
* Extract the button number from a button event.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the button of @event
|
|
|
|
|
**/
|
|
|
|
|
guint
|
|
|
|
|
gdk_button_event_get_button (GdkEvent *event)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (event->any.type == GDK_BUTTON_PRESS ||
|
|
|
|
|
event->any.type == GDK_BUTTON_RELEASE, 0);
|
2020-02-14 13:09:59 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
return event->button.button;
|
2020-02-14 13:09:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* gdk_key_event_get_keyval:
|
|
|
|
|
* @event: a key event
|
|
|
|
|
*
|
|
|
|
|
* Extracts the keyval from a key event.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the keyval of @event
|
|
|
|
|
*/
|
|
|
|
|
guint
|
|
|
|
|
gdk_key_event_get_keyval (GdkEvent *event)
|
2020-02-14 13:09:59 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
g_return_val_if_fail (event->any.type == GDK_KEY_PRESS ||
|
|
|
|
|
event->any.type == GDK_KEY_RELEASE, 0);
|
2020-02-14 13:09:59 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
return event->key.keyval;
|
2020-02-14 13:09:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* gdk_key_event_get_keycode:
|
|
|
|
|
* @event: a key event
|
|
|
|
|
*
|
|
|
|
|
* Extracts the keycode from a key event.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the keycode of @event
|
|
|
|
|
*/
|
|
|
|
|
guint
|
|
|
|
|
gdk_key_event_get_keycode (GdkEvent *event)
|
2020-02-14 13:09:59 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
g_return_val_if_fail (event->any.type == GDK_KEY_PRESS ||
|
|
|
|
|
event->any.type == GDK_KEY_RELEASE, 0);
|
2020-02-14 13:09:59 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
return event->key.hardware_keycode;
|
2020-02-14 13:09:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* gdk_key_event_get_scancode:
|
|
|
|
|
* @event: a key event
|
|
|
|
|
*
|
|
|
|
|
* Extracts the scancode from a key event.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the scancode of @event
|
|
|
|
|
*/
|
|
|
|
|
guint
|
|
|
|
|
gdk_key_event_get_scancode (GdkEvent *event)
|
2020-02-14 13:09:59 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
g_return_val_if_fail (event->any.type == GDK_KEY_PRESS ||
|
|
|
|
|
event->any.type == GDK_KEY_RELEASE, 0);
|
2020-02-14 13:09:59 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
return event->key.key_scancode;
|
2020-02-14 13:09:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* gdk_key_event_get_group:
|
|
|
|
|
* @event: a key event
|
|
|
|
|
*
|
|
|
|
|
* Extracts the group from a key event.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the group of @event
|
|
|
|
|
*/
|
|
|
|
|
guint
|
|
|
|
|
gdk_key_event_get_group (GdkEvent *event)
|
2020-02-14 13:09:59 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
g_return_val_if_fail (event->any.type == GDK_KEY_PRESS ||
|
|
|
|
|
event->any.type == GDK_KEY_RELEASE, 0);
|
2020-02-14 13:09:59 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
return event->key.group;
|
2020-02-14 13:09:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* gdk_key_event_is_modifier:
|
|
|
|
|
* @event: a key event
|
|
|
|
|
*
|
|
|
|
|
* Extracts whether the key event is for a modifier key.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the @event is for a modifier key
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
gdk_key_event_is_modifier (GdkEvent *event)
|
2020-02-14 13:09:59 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
g_return_val_if_fail (event->any.type == GDK_KEY_PRESS ||
|
|
|
|
|
event->any.type == GDK_KEY_RELEASE, FALSE);
|
2020-02-14 13:09:59 +00:00
|
|
|
|
|
2020-02-18 04:08:44 +00:00
|
|
|
|
return event->any.key_is_modifier;
|
2020-02-14 13:09:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* gdk_configure_event_get_size:
|
|
|
|
|
* @event: a configure event
|
|
|
|
|
* @width: (out): return location for surface width
|
|
|
|
|
* @height: (out): return location for surface height
|
|
|
|
|
*
|
|
|
|
|
* Extracts the surface size from a configure event.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gdk_configure_event_get_size (GdkEvent *event,
|
|
|
|
|
int *width,
|
|
|
|
|
int *height)
|
2020-02-14 13:09:59 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
g_return_if_fail (event->any.type == GDK_CONFIGURE);
|
2020-02-14 13:09:59 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
*width = event->configure.width;
|
|
|
|
|
*height = event->configure.height;
|
|
|
|
|
}
|
2020-02-14 13:09:59 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* gdk_touch_event_get_emulating_pointer:
|
|
|
|
|
* @event: a touch event
|
|
|
|
|
*
|
|
|
|
|
* Extracts whether a touch event is emulating a pointer event.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if @event is emulating
|
|
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
gdk_touch_event_get_emulating_pointer (GdkEvent *event)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (event->any.type == GDK_TOUCH_BEGIN ||
|
|
|
|
|
event->any.type == GDK_TOUCH_UPDATE ||
|
|
|
|
|
event->any.type == GDK_TOUCH_END ||
|
|
|
|
|
event->any.type == GDK_TOUCH_CANCEL, FALSE);
|
2020-02-14 13:09:59 +00:00
|
|
|
|
|
2020-02-18 04:08:44 +00:00
|
|
|
|
return event->any.touch_emulating;
|
2020-02-14 13:09:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* gdk_crossing_event_get_mode:
|
|
|
|
|
* @event: a crossing event
|
|
|
|
|
*
|
|
|
|
|
* Extracts the crossing mode from a crossing event.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the mode of @event
|
|
|
|
|
*/
|
|
|
|
|
GdkCrossingMode
|
|
|
|
|
gdk_crossing_event_get_mode (GdkEvent *event)
|
2020-02-14 13:09:59 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
g_return_val_if_fail (event->any.type == GDK_ENTER_NOTIFY ||
|
|
|
|
|
event->any.type == GDK_LEAVE_NOTIFY, 0);
|
2020-02-14 13:09:59 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
return event->crossing.mode;
|
|
|
|
|
}
|
2020-02-14 13:09:59 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* gdk_crossing_event_get_detail:
|
|
|
|
|
* @event: a crossing event
|
|
|
|
|
*
|
|
|
|
|
* Extracts the notify detail from a crossing event.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the notify detail of @event
|
|
|
|
|
*/
|
|
|
|
|
GdkNotifyType
|
|
|
|
|
gdk_crossing_event_get_detail (GdkEvent *event)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (event->any.type == GDK_ENTER_NOTIFY ||
|
|
|
|
|
event->any.type == GDK_LEAVE_NOTIFY, 0);
|
|
|
|
|
|
|
|
|
|
return event->crossing.detail;
|
2020-02-14 13:09:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* gdk_focus_event_get_in:
|
|
|
|
|
* @event: a focus change event
|
|
|
|
|
*
|
|
|
|
|
* Extracts whether this event is about focus entering or
|
|
|
|
|
* leaving the surface.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE of the focus is entering
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
gdk_focus_event_get_in (GdkEvent *event)
|
2020-02-14 13:09:59 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
g_return_val_if_fail (event->any.type == GDK_FOCUS_CHANGE, FALSE);
|
2020-02-14 13:09:59 +00:00
|
|
|
|
|
2020-02-18 04:08:44 +00:00
|
|
|
|
return event->any.focus_in;
|
2020-02-18 03:11:56 +00:00
|
|
|
|
}
|
2020-02-14 13:09:59 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* gdk_scroll_event_get_direction:
|
|
|
|
|
* @event: a scroll event
|
|
|
|
|
*
|
|
|
|
|
* Extracts the direction of a scroll event.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the scroll direction of @event
|
|
|
|
|
*/
|
|
|
|
|
GdkScrollDirection
|
|
|
|
|
gdk_scroll_event_get_direction (GdkEvent *event)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (event->any.type == GDK_SCROLL, 0);
|
|
|
|
|
|
|
|
|
|
return event->scroll.direction;
|
2020-02-14 13:09:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* gdk_scroll_event_get_deltas:
|
|
|
|
|
* @event: a scroll event
|
|
|
|
|
* @delta_x: (out): return location for x scroll delta
|
|
|
|
|
* @delta_y: (out): return location for y scroll delta
|
|
|
|
|
*
|
|
|
|
|
* Extracts the scroll deltas of a scroll event.
|
|
|
|
|
*
|
|
|
|
|
* The deltas will be zero unless the scroll direction
|
|
|
|
|
* is %GDK_SCROLL_SMOOTH.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gdk_scroll_event_get_deltas (GdkEvent *event,
|
|
|
|
|
double *delta_x,
|
|
|
|
|
double *delta_y)
|
2020-02-14 13:09:59 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
g_return_if_fail (event->any.type == GDK_SCROLL);
|
2020-02-14 13:09:59 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
*delta_x = event->scroll.delta_x;
|
|
|
|
|
*delta_y = event->scroll.delta_y;
|
|
|
|
|
}
|
2020-02-14 13:09:59 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* gdk_scroll_event_is_stop:
|
|
|
|
|
* @event: a scroll event
|
|
|
|
|
*
|
|
|
|
|
* Check whether a scroll event is a stop scroll event. Scroll sequences
|
|
|
|
|
* with smooth scroll information may provide a stop scroll event once the
|
|
|
|
|
* interaction with the device finishes, e.g. by lifting a finger. This
|
|
|
|
|
* stop scroll event is the signal that a widget may trigger kinetic
|
|
|
|
|
* scrolling based on the current velocity.
|
|
|
|
|
*
|
|
|
|
|
* Stop scroll events always have a delta of 0/0.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the event is a scroll stop event
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
gdk_scroll_event_is_stop (GdkEvent *event)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (event->any.type == GDK_SCROLL, FALSE);
|
|
|
|
|
|
2020-02-18 04:08:44 +00:00
|
|
|
|
return event->any.scroll_is_stop;
|
2020-02-14 13:09:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* gdk_touchpad_event_get_gesture_phase:
|
|
|
|
|
* @event: a touchpad #GdkEvent
|
|
|
|
|
*
|
|
|
|
|
* Extracts the touchpad gesture phase from a touchpad event.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the gesture phase of @event
|
|
|
|
|
**/
|
|
|
|
|
GdkTouchpadGesturePhase
|
|
|
|
|
gdk_touchpad_event_get_gesture_phase (GdkEvent *event)
|
2020-02-14 13:09:59 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
g_return_val_if_fail (event->any.type == GDK_TOUCHPAD_PINCH ||
|
|
|
|
|
event->any.type == GDK_TOUCHPAD_SWIPE, 0);
|
2020-02-14 13:09:59 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
if (event->any.type == GDK_TOUCHPAD_PINCH)
|
|
|
|
|
return event->touchpad_pinch.phase;
|
|
|
|
|
else if (event->any.type == GDK_TOUCHPAD_SWIPE)
|
|
|
|
|
return event->touchpad_swipe.phase;
|
2020-02-14 13:09:59 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
return 0;
|
2020-02-14 13:09:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* gdk_touchpad_event_get_n_fingers:
|
|
|
|
|
* @event: a touchpad event
|
|
|
|
|
*
|
|
|
|
|
* Extracts the number of fingers from a touchpad event.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the number of fingers for @event
|
|
|
|
|
**/
|
|
|
|
|
guint
|
|
|
|
|
gdk_touchpad_event_get_n_fingers (GdkEvent *event)
|
2020-02-14 13:09:59 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
g_return_val_if_fail (event->any.type == GDK_TOUCHPAD_PINCH ||
|
|
|
|
|
event->any.type == GDK_TOUCHPAD_SWIPE, 0);
|
2020-02-14 13:09:59 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
if (event->any.type == GDK_TOUCHPAD_PINCH)
|
|
|
|
|
return event->touchpad_pinch.n_fingers;
|
|
|
|
|
else if (event->any.type == GDK_TOUCHPAD_SWIPE)
|
|
|
|
|
return event->touchpad_swipe.n_fingers;
|
2020-02-14 13:09:59 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
2020-02-14 13:09:59 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* gdk_touchpad_event_get_deltas:
|
|
|
|
|
* @event: a touchpad event
|
|
|
|
|
* @dx: (out): return location for x
|
|
|
|
|
* @dy: (out): return location for y
|
|
|
|
|
*
|
|
|
|
|
* Extracts delta information from a touchpad event.
|
|
|
|
|
**/
|
|
|
|
|
void
|
|
|
|
|
gdk_touchpad_event_get_deltas (GdkEvent *event,
|
|
|
|
|
double *dx,
|
|
|
|
|
double *dy)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (event->any.type == GDK_TOUCHPAD_PINCH ||
|
|
|
|
|
event->any.type == GDK_TOUCHPAD_SWIPE);
|
2020-02-14 13:09:59 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
if (event->any.type == GDK_TOUCHPAD_PINCH)
|
|
|
|
|
{
|
|
|
|
|
*dx = event->touchpad_pinch.dx;
|
|
|
|
|
*dy = event->touchpad_pinch.dy;
|
|
|
|
|
}
|
|
|
|
|
else if (event->any.type == GDK_TOUCHPAD_SWIPE)
|
|
|
|
|
{
|
|
|
|
|
*dx = event->touchpad_swipe.dx;
|
|
|
|
|
*dy = event->touchpad_swipe.dy;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
*dx = NAN;
|
|
|
|
|
*dy = NAN;
|
|
|
|
|
}
|
2020-02-14 13:09:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* gdk_touchpad_pinch_event_get_angle_delta:
|
|
|
|
|
* @event: a touchpad pinch event
|
|
|
|
|
*
|
|
|
|
|
* Extracts the angle delta from a touchpad pinch event.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the angle delta of @event
|
|
|
|
|
*/
|
|
|
|
|
double
|
|
|
|
|
gdk_touchpad_pinch_event_get_angle_delta (GdkEvent *event)
|
2020-02-14 13:09:59 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
g_return_val_if_fail (event->any.type == GDK_TOUCHPAD_PINCH, 0);
|
2020-02-14 13:09:59 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
return event->touchpad_pinch.angle_delta;
|
|
|
|
|
}
|
2020-02-14 13:09:59 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* gdk_touchpad_pinch_event_get_scale:
|
|
|
|
|
* @event: a touchpad pinch event
|
|
|
|
|
*
|
|
|
|
|
* Extracts the scale from a touchpad pinch event.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the scale of @event
|
|
|
|
|
**/
|
|
|
|
|
double
|
|
|
|
|
gdk_touchpad_pinch_event_get_scale (GdkEvent *event)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (event->any.type == GDK_TOUCHPAD_PINCH, 0);
|
|
|
|
|
|
|
|
|
|
return event->touchpad_pinch.scale;
|
2020-02-14 13:09:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* gdk_pad_button_event_get_button:
|
|
|
|
|
* @event: a pad button event
|
|
|
|
|
*
|
|
|
|
|
* Extracts information about the pressed button from
|
|
|
|
|
* a pad event.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the button of @event
|
|
|
|
|
**/
|
|
|
|
|
guint
|
|
|
|
|
gdk_pad_button_event_get_button (GdkEvent *event)
|
2020-02-14 13:09:59 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
g_return_val_if_fail (event->any.type == GDK_PAD_BUTTON_PRESS ||
|
|
|
|
|
event->any.type == GDK_PAD_BUTTON_RELEASE, 0);
|
2020-02-14 13:09:59 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
return event->pad_button.button;
|
|
|
|
|
}
|
2020-02-14 13:09:59 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* gdk_pad_axis_event_get_value:
|
|
|
|
|
* @event: a pad strip or ring event
|
|
|
|
|
* @index: (out): Return location for the axis index
|
|
|
|
|
* @value: (out): Return location for the axis value
|
|
|
|
|
*
|
|
|
|
|
* Extracts the information from a pad strip or ring event.
|
|
|
|
|
**/
|
|
|
|
|
void
|
|
|
|
|
gdk_pad_axis_event_get_value (GdkEvent *event,
|
|
|
|
|
guint *index,
|
|
|
|
|
gdouble *value)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (event->any.type == GDK_PAD_RING ||
|
|
|
|
|
event->any.type == GDK_PAD_STRIP);
|
2020-02-14 13:09:59 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
*index = event->pad_axis.index;
|
|
|
|
|
*value = event->pad_axis.value;
|
|
|
|
|
}
|
2020-02-14 13:09:59 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* gdk_pad_event_get_group_mode:
|
|
|
|
|
* @event: a pad event
|
|
|
|
|
* @group: (out): return location for the group
|
|
|
|
|
* @mode: (out): return location for the mode
|
|
|
|
|
*
|
|
|
|
|
* Extracts group and mode information from a pad event.
|
|
|
|
|
**/
|
|
|
|
|
void
|
|
|
|
|
gdk_pad_event_get_group_mode (GdkEvent *event,
|
|
|
|
|
guint *group,
|
|
|
|
|
guint *mode)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (event->any.type == GDK_PAD_GROUP_MODE ||
|
|
|
|
|
event->any.type == GDK_PAD_BUTTON_PRESS ||
|
|
|
|
|
event->any.type == GDK_PAD_BUTTON_RELEASE ||
|
|
|
|
|
event->any.type == GDK_PAD_RING ||
|
|
|
|
|
event->any.type == GDK_PAD_STRIP);
|
|
|
|
|
|
|
|
|
|
switch ((guint)event->any.type)
|
|
|
|
|
{
|
|
|
|
|
case GDK_PAD_GROUP_MODE:
|
|
|
|
|
*group = event->pad_group_mode.group;
|
|
|
|
|
*mode = event->pad_group_mode.mode;
|
|
|
|
|
break;
|
|
|
|
|
case GDK_PAD_BUTTON_PRESS:
|
|
|
|
|
case GDK_PAD_BUTTON_RELEASE:
|
|
|
|
|
*group = event->pad_button.group;
|
|
|
|
|
*mode = event->pad_button.mode;
|
|
|
|
|
break;
|
|
|
|
|
case GDK_PAD_RING:
|
|
|
|
|
case GDK_PAD_STRIP:
|
|
|
|
|
*group = event->pad_axis.group;
|
|
|
|
|
*mode = event->pad_axis.mode;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
}
|
2020-02-14 13:09:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* gdk_drag_event_get_drop:
|
|
|
|
|
* @event: a DND event
|
|
|
|
|
*
|
|
|
|
|
* Gets the #GdkDrop from a DND event.
|
|
|
|
|
*
|
|
|
|
|
* Returns: (transfer none) (nullable): the drop
|
|
|
|
|
**/
|
|
|
|
|
GdkDrop *
|
|
|
|
|
gdk_drag_event_get_drop (GdkEvent *event)
|
2020-02-14 13:09:59 +00:00
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
|
g_return_val_if_fail (event->any.type == GDK_DRAG_ENTER ||
|
|
|
|
|
event->any.type == GDK_DRAG_LEAVE ||
|
|
|
|
|
event->any.type == GDK_DRAG_MOTION ||
|
|
|
|
|
event->any.type == GDK_DROP_START, NULL);
|
2020-02-14 13:09:59 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
return event->dnd.drop;
|
|
|
|
|
}
|
2020-02-14 13:09:59 +00:00
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* gdk_grab_broken_event_get_grab_surface:
|
|
|
|
|
* @event: a grab broken event
|
|
|
|
|
*
|
|
|
|
|
* Extracts the grab surface from a grab broken event.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the grab surface of @event
|
|
|
|
|
**/
|
|
|
|
|
GdkSurface *
|
|
|
|
|
gdk_grab_broken_event_get_grab_surface (GdkEvent *event)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (event->any.type == GDK_GRAB_BROKEN, NULL);
|
|
|
|
|
|
|
|
|
|
return event->grab_broken.grab_surface;
|
2020-02-14 13:09:59 +00:00
|
|
|
|
}
|