GdkDisplay: Add GdkSeat getters

https://bugzilla.gnome.org/show_bug.cgi?id=759309
This commit is contained in:
Carlos Garnacho 2015-11-26 19:52:23 +01:00
parent d24f63e9ce
commit 6f4edc091b
4 changed files with 98 additions and 0 deletions

View File

@ -156,6 +156,8 @@ gdk_display_supports_input_shapes
gdk_display_supports_composite
gdk_display_get_app_launch_context
gdk_display_notify_startup_complete
gdk_display_get_default_seat
gdk_display_list_seats
<SUBSECTION Standard>
GDK_DISPLAY

View File

@ -125,6 +125,15 @@ gdk_display_real_event_data_free (GdkDisplay *display,
{
}
static GdkSeat *
gdk_display_real_get_default_seat (GdkDisplay *display)
{
if (!display->seats)
return NULL;
return display->seats->data;
}
static void
gdk_display_class_init (GdkDisplayClass *class)
{
@ -140,6 +149,7 @@ gdk_display_class_init (GdkDisplayClass *class)
class->make_default = gdk_display_real_make_default;
class->event_data_copy = gdk_display_real_event_data_copy;
class->event_data_free = gdk_display_real_event_data_free;
class->get_default_seat = gdk_display_real_get_default_seat;
/**
* GdkDisplay::opened:
@ -2318,3 +2328,73 @@ gdk_display_get_debug_updates (GdkDisplay *display)
else
return _gdk_debug_updates;
}
void
gdk_display_add_seat (GdkDisplay *display,
GdkSeat *seat)
{
g_return_if_fail (GDK_IS_DISPLAY (display));
g_return_if_fail (GDK_IS_SEAT (seat));
display->seats = g_list_prepend (display->seats, g_object_ref (seat));
}
void
gdk_display_remove_seat (GdkDisplay *display,
GdkSeat *seat)
{
GList *link;
g_return_if_fail (GDK_IS_DISPLAY (display));
g_return_if_fail (GDK_IS_SEAT (seat));
link = g_list_find (display->seats, seat);
if (link)
{
display->seats = g_list_remove_link (display->seats, link);
g_object_unref (link->data);
g_list_free (link);
}
}
/**
* gdk_display_get_default_seat:
* @display: a #GdkDisplay
*
* Returns the default #GdkSeat for this display.
*
* Returns: (transfer none): the default seat.
*
* Since: 3.20
**/
GdkSeat *
gdk_display_get_default_seat (GdkDisplay *display)
{
GdkDisplayClass *display_class;
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
display_class = GDK_DISPLAY_GET_CLASS (display);
return display_class->get_default_seat (display);
}
/**
* gdk_display_list_seats:
* @display: a #GdkDisplay
*
* Returns the list of seats known to @display.
*
* Returns: (transfer container) (element-type GdkSeat): the
* list of seats known to the #GdkDisplay
*
* Since: 3.20
**/
GList *
gdk_display_list_seats (GdkDisplay *display)
{
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
return g_list_copy (display->seats);
}

View File

@ -30,6 +30,7 @@
#include <gdk/gdktypes.h>
#include <gdk/gdkevents.h>
#include <gdk/gdkdevicemanager.h>
#include <gdk/gdkseat.h>
G_BEGIN_DECLS
@ -171,6 +172,12 @@ GdkDeviceManager * gdk_display_get_device_manager (GdkDisplay *display);
GDK_AVAILABLE_IN_ALL
GdkAppLaunchContext *gdk_display_get_app_launch_context (GdkDisplay *display);
GDK_AVAILABLE_IN_3_20
GdkSeat * gdk_display_get_default_seat (GdkDisplay *display);
GDK_AVAILABLE_IN_3_20
GList * gdk_display_list_seats (GdkDisplay *display);
G_END_DECLS
#endif /* __GDK_DISPLAY_H__ */

View File

@ -125,6 +125,8 @@ struct _GdkDisplay
guint debug_updates_set : 1;
GdkRenderingMode rendering_mode;
GList *seats;
};
struct _GdkDisplayClass
@ -237,6 +239,8 @@ struct _GdkDisplayClass
gboolean (*make_gl_context_current) (GdkDisplay *display,
GdkGLContext *context);
GdkSeat * (*get_default_seat) (GdkDisplay *display);
/* Signals */
void (*opened) (GdkDisplay *display);
void (*closed) (GdkDisplay *display,
@ -318,6 +322,11 @@ GdkWindow * _gdk_display_create_window (GdkDisplay *display
gboolean gdk_display_make_gl_context_current (GdkDisplay *display,
GdkGLContext *context);
void gdk_display_add_seat (GdkDisplay *display,
GdkSeat *seat);
void gdk_display_remove_seat (GdkDisplay *display,
GdkSeat *seat);
G_END_DECLS
#endif /* __GDK_DISPLAY_PRIVATE_H__ */