Commit bf2f0d5d authored by Carlos Garnacho's avatar Carlos Garnacho
Browse files

common: Add GsdDeviceMapper

This is an object attached to the default screen, meant to be used across
several g-s-d plugins. On one hand, it keeps track of monitors and their
layout/rotation/mode. On the other hand, g-s-d plugins tell GsdDeviceMapper
which GdkDevices will be handled by this object, so a monitor is chosen
to map the GdkDevice to, applying what we know about the input device.

The primary source to know the corresponding monitor is the configuration,
if an input device has a configured display in GSettings, and the monitor
is currently present, that will be the one the input device will map to.

When an input device has no settings, or an unconfigured monitor, multiple
things are checked in order to find out a good guess for the GdkDevice.
- System-integrated input devices go to the built-in output
- Several EDID checks are done for Wacom devices with a built-in screen
- Sanity checks are done on outputs with screen-integrated input devices,
  if a monitor already has a GdkDevice with similar capabilities (eg. a
  system-integrated pen), this output will be punted, so there is no
  accumulation of input devices.

If an output is found on some or other way, the GdkDevice will be
mapped to that output, and follow it if the display configuration
changes, or device left/right handedness changes.

https://bugzilla.gnome.org/show_bug.cgi?id=709600
parent b462e656
......@@ -281,6 +281,7 @@ case $host_os in
have_wacom=no
else
if test x$enable_gudev != xno; then
PKG_CHECK_MODULES(LIBWACOM, [libwacom >= $LIBWACOM_REQUIRED_VERSION])
PKG_CHECK_MODULES(WACOM, [libwacom >= $LIBWACOM_REQUIRED_VERSION x11 xi xtst gudev-1.0 gnome-desktop-3.0 >= $GNOME_DESKTOP_REQUIRED_VERSION xorg-wacom librsvg-2.0 >= $LIBRSVG_REQUIRED_VERSION libnotify >= $LIBNOTIFY_REQUIRED_VERSION pango >= $PANGO_REQUIRED_VERSION])
PKG_CHECK_MODULES(WACOM_OLED, [gudev-1.0])
else
......
......@@ -3,6 +3,8 @@ plugin_name = common
noinst_LTLIBRARIES = libcommon.la
libcommon_la_SOURCES = \
gsd-device-mapper.c \
gsd-device-mapper.h \
gsd-keygrab.c \
gsd-keygrab.h \
gsd-input-helper.c \
......@@ -13,12 +15,15 @@ libcommon_la_SOURCES = \
libcommon_la_CPPFLAGS = \
-I$(top_srcdir)/gnome-settings-daemon \
-I$(top_builddir)/gnome-settings-daemon \
-I$(top_srcdir)/data/ \
$(AM_CPPFLAGS)
libcommon_la_CFLAGS = \
$(PLUGIN_CFLAGS) \
$(SETTINGS_PLUGIN_CFLAGS) \
$(COMMON_CFLAGS) \
$(GNOME_DESKTOP_CFLAGS) \
$(LIBWACOM_CFLAGS) \
$(AM_CFLAGS)
libcommon_la_LDFLAGS = \
......@@ -26,6 +31,8 @@ libcommon_la_LDFLAGS = \
libcommon_la_LIBADD = \
$(SETTINGS_PLUGIN_LIBS) \
$(GNOME_DESKTOP_LIBS) \
$(LIBWACOM_LIBS) \
$(COMMON_LIBS)
libexec_PROGRAMS = gsd-test-input-helper
......
This diff is collapsed.
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2014 Carlos Garnacho <carlosg@gnome.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GSD_DEVICE_MAPPER_H__
#define __GSD_DEVICE_MAPPER_H__
#define GNOME_DESKTOP_USE_UNSTABLE_API
#include <libgnome-desktop/gnome-rr.h>
#undef GNOME_DESKTOP_USE_UNSTABLE_API
#include <gdk/gdk.h>
G_BEGIN_DECLS
#define GSD_TYPE_DEVICE_MAPPER (gsd_device_mapper_get_type ())
#define GSD_DEVICE_MAPPER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GSD_TYPE_DEVICE_MAPPER, GsdDeviceMapper))
#define GSD_DEVICE_MAPPER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GSD_TYPE_DEVICE_MAPPER, GsdDeviceMapperClass))
#define GSD_IS_DEVICE_MAPPER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSD_TYPE_DEVICE_MAPPER))
#define GSD_IS_DEVICE_MAPPER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GSD_TYPE_DEVICE_MAPPER))
#define GSD_DEVICE_MAPPER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GSD_TYPE_DEVICE_MAPPER, GsdDeviceMapperClass))
typedef struct _GsdDeviceMapper GsdDeviceMapper;
typedef struct _GsdDeviceMapperClass GsdDeviceMapperClass;
GType gsd_device_mapper_get_type (void) G_GNUC_CONST;
GsdDeviceMapper * gsd_device_mapper_get (void);
void gsd_device_mapper_add_input (GsdDeviceMapper *mapper,
GdkDevice *device,
GSettings *settings);
void gsd_device_mapper_remove_input (GsdDeviceMapper *mapper,
GdkDevice *device);
void gsd_device_mapper_add_output (GsdDeviceMapper *mapper,
GnomeRROutput *output);
void gsd_device_mapper_remove_output (GsdDeviceMapper *mapper,
GnomeRROutput *output);
GnomeRROutput * gsd_device_mapper_get_device_output (GsdDeviceMapper *mapper,
GdkDevice *device);
void gsd_device_mapper_set_device_output (GsdDeviceMapper *mapper,
GdkDevice *device,
GnomeRROutput *output);
gint gsd_device_mapper_get_device_monitor (GsdDeviceMapper *mapper,
GdkDevice *device);
void gsd_device_mapper_set_device_monitor (GsdDeviceMapper *mapper,
GdkDevice *device,
gint monitor_num);
G_END_DECLS
#endif /* __GSD_DEVICE_MAPPER_H__ */
......@@ -575,3 +575,38 @@ get_disabled_devices (GdkDeviceManager *manager)
return ret;
}
const char *
xdevice_get_wacom_tool_type (int deviceid)
{
unsigned long nitems, bytes_after;
unsigned char *data = NULL;
Atom prop, realtype, tool;
GdkDisplay *display;
int realformat, rc;
const gchar *ret = NULL;
gdk_error_trap_push ();
display = gdk_display_get_default ();
prop = gdk_x11_get_xatom_by_name ("Wacom Tool Type");
rc = XIGetProperty (GDK_DISPLAY_XDISPLAY (display),
deviceid, prop, 0, 1, False,
XA_ATOM, &realtype, &realformat, &nitems,
&bytes_after, &data);
gdk_error_trap_pop_ignored ();
if (rc != Success || nitems == 0)
return NULL;
if (realtype == XA_ATOM) {
tool = *((Atom*) data);
ret = gdk_x11_get_xatom_name (tool);
}
XFree (data);
return ret;
}
......@@ -81,6 +81,8 @@ GList * get_disabled_devices (GdkDeviceManager *manager);
char * xdevice_get_device_node (int deviceid);
int xdevice_get_last_tool_id (int deviceid);
const char * xdevice_get_wacom_tool_type (int deviceid);
G_END_DECLS
#endif /* __GSD_INPUT_HELPER_H */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment