input-settings: Minor structural cleanup

Let the backend implementations create their own input settings
backend, as is done with other backend specific special purpose
backends. Also use the macro for declaring the GType.

https://bugzilla.gnome.org/show_bug.cgi?id=782152
This commit is contained in:
Jonas Ådahl 2017-04-10 17:31:50 +08:00
parent 755755a2f3
commit 81e99c2680
7 changed files with 34 additions and 42 deletions

View File

@ -59,6 +59,7 @@ struct _MetaBackendClass
MetaMonitorManager * (* create_monitor_manager) (MetaBackend *backend);
MetaCursorRenderer * (* create_cursor_renderer) (MetaBackend *backend);
MetaRenderer * (* create_renderer) (MetaBackend *backend);
MetaInputSettings * (* create_input_settings) (MetaBackend *backend);
gboolean (* grab_device) (MetaBackend *backend,
int device_id,

View File

@ -403,6 +403,12 @@ set_initial_pointer_visibility (MetaBackend *backend,
!has_touchscreen);
}
static MetaInputSettings *
meta_backend_create_input_settings (MetaBackend *backend)
{
return META_BACKEND_GET_CLASS (backend)->create_input_settings (backend);
}
static void
meta_backend_real_post_init (MetaBackend *backend)
{
@ -434,7 +440,7 @@ meta_backend_real_post_init (MetaBackend *backend)
set_initial_pointer_visibility (backend, device_manager);
priv->input_settings = meta_input_settings_create ();
priv->input_settings = meta_backend_create_input_settings (backend);
center_pointer (backend);
}

View File

@ -31,20 +31,9 @@
#include <libwacom/libwacom.h>
#endif
#define META_TYPE_INPUT_SETTINGS (meta_input_settings_get_type ())
#define META_INPUT_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_INPUT_SETTINGS, MetaInputSettings))
#define META_INPUT_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), META_TYPE_INPUT_SETTINGS, MetaInputSettingsClass))
#define META_IS_INPUT_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), META_TYPE_INPUT_SETTINGS))
#define META_IS_INPUT_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), META_TYPE_INPUT_SETTINGS))
#define META_INPUT_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), META_TYPE_INPUT_SETTINGS, MetaInputSettingsClass))
typedef struct _MetaInputSettings MetaInputSettings;
typedef struct _MetaInputSettingsClass MetaInputSettingsClass;
struct _MetaInputSettings
{
GObject parent_instance;
};
#define META_TYPE_INPUT_SETTINGS (meta_input_settings_get_type ())
G_DECLARE_DERIVABLE_TYPE (MetaInputSettings, meta_input_settings,
META, INPUT_SETTINGS, GObject)
struct _MetaInputSettingsClass
{
@ -122,10 +111,6 @@ struct _MetaInputSettingsClass
ClutterInputDevice *device);
};
GType meta_input_settings_get_type (void) G_GNUC_CONST;
MetaInputSettings * meta_input_settings_create (void);
GSettings * meta_input_settings_get_tablet_settings (MetaInputSettings *settings,
ClutterInputDevice *device);
MetaLogicalMonitor * meta_input_settings_get_tablet_logical_monitor (MetaInputSettings *settings,

View File

@ -33,12 +33,6 @@
#include "meta-input-settings-private.h"
#include "backends/meta-logical-monitor.h"
#include "backends/meta-monitor.h"
#include "x11/meta-input-settings-x11.h"
#ifdef HAVE_NATIVE_BACKEND
#include "native/meta-backend-native.h"
#include "native/meta-input-settings-native.h"
#endif
#include <glib/gi18n-lib.h>
#include <meta/util.h>
@ -1478,23 +1472,6 @@ meta_input_settings_init (MetaInputSettings *settings)
priv->two_finger_devices = g_hash_table_new (NULL, NULL);
}
MetaInputSettings *
meta_input_settings_create (void)
{
#ifdef HAVE_NATIVE_BACKEND
MetaBackend *backend;
backend = meta_get_backend ();
if (META_IS_BACKEND_NATIVE (backend))
return g_object_new (META_TYPE_INPUT_SETTINGS_NATIVE, NULL);
#endif
if (!meta_is_wayland_compositor ())
return g_object_new (META_TYPE_INPUT_SETTINGS_X11, NULL);
return NULL;
}
GSettings *
meta_input_settings_get_tablet_settings (MetaInputSettings *settings,
ClutterInputDevice *device)

View File

@ -45,6 +45,7 @@
#include "backends/meta-pointer-constraint.h"
#include "backends/meta-stage.h"
#include "backends/native/meta-clutter-backend-native.h"
#include "backends/native/meta-input-settings-native.h"
#include "backends/native/meta-renderer-native.h"
#include "backends/native/meta-stage-native.h"
@ -431,6 +432,12 @@ meta_backend_native_create_renderer (MetaBackend *backend)
return META_RENDERER (renderer_native);
}
static MetaInputSettings *
meta_backend_native_create_input_settings (MetaBackend *backend)
{
return g_object_new (META_TYPE_INPUT_SETTINGS_NATIVE, NULL);
}
static void
meta_backend_native_warp_pointer (MetaBackend *backend,
int x,
@ -561,6 +568,7 @@ meta_backend_native_class_init (MetaBackendNativeClass *klass)
backend_class->create_monitor_manager = meta_backend_native_create_monitor_manager;
backend_class->create_cursor_renderer = meta_backend_native_create_cursor_renderer;
backend_class->create_renderer = meta_backend_native_create_renderer;
backend_class->create_input_settings = meta_backend_native_create_input_settings;
backend_class->warp_pointer = meta_backend_native_warp_pointer;

View File

@ -28,6 +28,7 @@
#include "backends/meta-backend-private.h"
#include "backends/x11/meta-cursor-renderer-x11.h"
#include "backends/x11/meta-input-settings-x11.h"
#include "backends/x11/meta-monitor-manager-xrandr.h"
#include "backends/x11/cm/meta-renderer-x11-cm.h"
@ -108,6 +109,12 @@ meta_backend_x11_cm_create_cursor_renderer (MetaBackend *backend)
return g_object_new (META_TYPE_CURSOR_RENDERER_X11, NULL);
}
static MetaInputSettings *
meta_backend_x11_cm_create_input_settings (MetaBackend *backend)
{
return g_object_new (META_TYPE_INPUT_SETTINGS_X11, NULL);
}
static void
meta_backend_x11_cm_update_screen_size (MetaBackend *backend,
int width,
@ -390,6 +397,7 @@ meta_backend_x11_cm_class_init (MetaBackendX11CmClass *klass)
backend_class->create_renderer = meta_backend_x11_cm_create_renderer;
backend_class->create_monitor_manager = meta_backend_x11_cm_create_monitor_manager;
backend_class->create_cursor_renderer = meta_backend_x11_cm_create_cursor_renderer;
backend_class->create_input_settings = meta_backend_x11_cm_create_input_settings;
backend_class->update_screen_size = meta_backend_x11_cm_update_screen_size;
backend_class->select_stage_events = meta_backend_x11_cm_select_stage_events;
backend_class->lock_layout_group = meta_backend_x11_cm_lock_layout_group;

View File

@ -49,6 +49,12 @@ meta_backend_x11_nested_create_cursor_renderer (MetaBackend *backend)
return g_object_new (META_TYPE_CURSOR_RENDERER_X11_NESTED, NULL);
}
static MetaInputSettings *
meta_backend_x11_nested_create_input_settings (MetaBackend *backend)
{
return NULL;
}
static void
meta_backend_x11_nested_update_screen_size (MetaBackend *backend,
int width,
@ -177,6 +183,7 @@ meta_backend_x11_nested_class_init (MetaBackendX11NestedClass *klass)
backend_class->create_renderer = meta_backend_x11_nested_create_renderer;
backend_class->create_monitor_manager = meta_backend_x11_nested_create_monitor_manager;
backend_class->create_cursor_renderer = meta_backend_x11_nested_create_cursor_renderer;
backend_class->create_input_settings = meta_backend_x11_nested_create_input_settings;
backend_class->update_screen_size = meta_backend_x11_nested_update_screen_size;
backend_class->select_stage_events = meta_backend_x11_nested_select_stage_events;
backend_class->lock_layout_group = meta_backend_x11_nested_lock_layout_group;