mirror of
https://github.com/brl/mutter.git
synced 2025-02-09 01:54:10 +00:00
backends: Simplify MetaInputSettings vfunc
Rename the set_tablet_keep_aspect() vfunc into a set_tablet_aspect_ratio() one that takes an aspect ratio double, instead of leaking monitor info into subclasses to let them all figure out this number themselves. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
This commit is contained in:
parent
1dc534ea9e
commit
b56d31ef48
@ -93,10 +93,9 @@ struct _MetaInputSettingsClass
|
|||||||
void (* set_tablet_mapping) (MetaInputSettings *settings,
|
void (* set_tablet_mapping) (MetaInputSettings *settings,
|
||||||
ClutterInputDevice *device,
|
ClutterInputDevice *device,
|
||||||
GDesktopTabletMapping mapping);
|
GDesktopTabletMapping mapping);
|
||||||
void (* set_tablet_keep_aspect) (MetaInputSettings *settings,
|
void (* set_tablet_aspect_ratio) (MetaInputSettings *settings,
|
||||||
ClutterInputDevice *device,
|
ClutterInputDevice *device,
|
||||||
MetaLogicalMonitor *logical_monitor,
|
double ratio);
|
||||||
gboolean keep_aspect);
|
|
||||||
void (* set_tablet_area) (MetaInputSettings *settings,
|
void (* set_tablet_area) (MetaInputSettings *settings,
|
||||||
ClutterInputDevice *device,
|
ClutterInputDevice *device,
|
||||||
gdouble padding_left,
|
gdouble padding_left,
|
||||||
|
@ -1012,6 +1012,7 @@ update_tablet_keep_aspect (MetaInputSettings *input_settings,
|
|||||||
MetaInputSettingsClass *input_settings_class;
|
MetaInputSettingsClass *input_settings_class;
|
||||||
MetaLogicalMonitor *logical_monitor = NULL;
|
MetaLogicalMonitor *logical_monitor = NULL;
|
||||||
gboolean keep_aspect;
|
gboolean keep_aspect;
|
||||||
|
double aspect_ratio;
|
||||||
|
|
||||||
if (clutter_input_device_get_device_type (device) != CLUTTER_TABLET_DEVICE &&
|
if (clutter_input_device_get_device_type (device) != CLUTTER_TABLET_DEVICE &&
|
||||||
clutter_input_device_get_device_type (device) != CLUTTER_PEN_DEVICE &&
|
clutter_input_device_get_device_type (device) != CLUTTER_PEN_DEVICE &&
|
||||||
@ -1037,8 +1038,34 @@ update_tablet_keep_aspect (MetaInputSettings *input_settings,
|
|||||||
meta_input_settings_find_monitor (input_settings, settings, device,
|
meta_input_settings_find_monitor (input_settings, settings, device,
|
||||||
NULL, &logical_monitor);
|
NULL, &logical_monitor);
|
||||||
|
|
||||||
input_settings_class->set_tablet_keep_aspect (input_settings, device,
|
if (keep_aspect)
|
||||||
logical_monitor, keep_aspect);
|
{
|
||||||
|
int width, height;
|
||||||
|
|
||||||
|
if (logical_monitor)
|
||||||
|
{
|
||||||
|
width = logical_monitor->rect.width;
|
||||||
|
height = logical_monitor->rect.height;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MetaMonitorManager *monitor_manager;
|
||||||
|
MetaBackend *backend;
|
||||||
|
|
||||||
|
backend = meta_get_backend ();
|
||||||
|
monitor_manager = meta_backend_get_monitor_manager (backend);
|
||||||
|
meta_monitor_manager_get_screen_size (monitor_manager,
|
||||||
|
&width, &height);
|
||||||
|
}
|
||||||
|
|
||||||
|
aspect_ratio = (double) width / height;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
aspect_ratio = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
input_settings_class->set_tablet_aspect_ratio (input_settings, device, aspect_ratio);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
#include <linux/input-event-codes.h>
|
#include <linux/input-event-codes.h>
|
||||||
#include <libinput.h>
|
#include <libinput.h>
|
||||||
|
|
||||||
#include "backends/meta-logical-monitor.h"
|
|
||||||
#include "backends/native/meta-backend-native.h"
|
#include "backends/native/meta-backend-native.h"
|
||||||
#include "backends/native/meta-input-device-native.h"
|
#include "backends/native/meta-input-device-native.h"
|
||||||
#include "backends/native/meta-input-device-tool-native.h"
|
#include "backends/native/meta-input-device-tool-native.h"
|
||||||
@ -549,40 +548,13 @@ meta_input_settings_native_set_tablet_mapping (MetaInputSettings *settings,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_input_settings_native_set_tablet_keep_aspect (MetaInputSettings *settings,
|
meta_input_settings_native_set_tablet_aspect_ratio (MetaInputSettings *settings,
|
||||||
ClutterInputDevice *device,
|
ClutterInputDevice *device,
|
||||||
MetaLogicalMonitor *logical_monitor,
|
gdouble aspect_ratio)
|
||||||
gboolean keep_aspect)
|
|
||||||
{
|
{
|
||||||
double aspect_ratio = 0;
|
|
||||||
|
|
||||||
if (meta_input_device_native_get_mapping_mode (device) ==
|
if (meta_input_device_native_get_mapping_mode (device) ==
|
||||||
META_INPUT_DEVICE_MAPPING_RELATIVE)
|
META_INPUT_DEVICE_MAPPING_RELATIVE)
|
||||||
keep_aspect = FALSE;
|
aspect_ratio = 0;
|
||||||
|
|
||||||
if (keep_aspect)
|
|
||||||
{
|
|
||||||
int width, height;
|
|
||||||
|
|
||||||
if (logical_monitor)
|
|
||||||
{
|
|
||||||
width = logical_monitor->rect.width;
|
|
||||||
height = logical_monitor->rect.height;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MetaMonitorManager *monitor_manager;
|
|
||||||
MetaBackend *backend;
|
|
||||||
|
|
||||||
backend = meta_get_backend ();
|
|
||||||
monitor_manager = meta_backend_get_monitor_manager (backend);
|
|
||||||
meta_monitor_manager_get_screen_size (monitor_manager,
|
|
||||||
&width,
|
|
||||||
&height);
|
|
||||||
}
|
|
||||||
|
|
||||||
aspect_ratio = (double) width / height;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_object_set (device, "output-aspect-ratio", aspect_ratio, NULL);
|
g_object_set (device, "output-aspect-ratio", aspect_ratio, NULL);
|
||||||
}
|
}
|
||||||
@ -745,7 +717,7 @@ meta_input_settings_native_class_init (MetaInputSettingsNativeClass *klass)
|
|||||||
input_settings_class->set_disable_while_typing = meta_input_settings_native_set_disable_while_typing;
|
input_settings_class->set_disable_while_typing = meta_input_settings_native_set_disable_while_typing;
|
||||||
|
|
||||||
input_settings_class->set_tablet_mapping = meta_input_settings_native_set_tablet_mapping;
|
input_settings_class->set_tablet_mapping = meta_input_settings_native_set_tablet_mapping;
|
||||||
input_settings_class->set_tablet_keep_aspect = meta_input_settings_native_set_tablet_keep_aspect;
|
input_settings_class->set_tablet_aspect_ratio = meta_input_settings_native_set_tablet_aspect_ratio;
|
||||||
input_settings_class->set_tablet_area = meta_input_settings_native_set_tablet_area;
|
input_settings_class->set_tablet_area = meta_input_settings_native_set_tablet_area;
|
||||||
|
|
||||||
input_settings_class->set_mouse_accel_profile = meta_input_settings_native_set_mouse_accel_profile;
|
input_settings_class->set_mouse_accel_profile = meta_input_settings_native_set_mouse_accel_profile;
|
||||||
|
@ -35,7 +35,6 @@
|
|||||||
#include <gudev/gudev.h>
|
#include <gudev/gudev.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "backends/meta-logical-monitor.h"
|
|
||||||
#include "backends/x11/meta-backend-x11.h"
|
#include "backends/x11/meta-backend-x11.h"
|
||||||
#include "backends/x11/meta-input-device-x11.h"
|
#include "backends/x11/meta-input-device-x11.h"
|
||||||
#include "core/display-private.h"
|
#include "core/display-private.h"
|
||||||
@ -735,37 +734,19 @@ meta_input_settings_x11_set_tablet_area (MetaInputSettings *settings,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_input_settings_x11_set_tablet_keep_aspect (MetaInputSettings *settings,
|
meta_input_settings_x11_set_tablet_aspect_ratio (MetaInputSettings *settings,
|
||||||
ClutterInputDevice *device,
|
ClutterInputDevice *device,
|
||||||
MetaLogicalMonitor *logical_monitor,
|
gdouble aspect_ratio)
|
||||||
gboolean keep_aspect)
|
|
||||||
{
|
{
|
||||||
gint32 width, height, dev_x, dev_y, dev_width, dev_height, area[4] = { 0 };
|
int32_t dev_x, dev_y, dev_width, dev_height, area[4] = { 0 };
|
||||||
|
|
||||||
if (!device_query_area (device, &dev_x, &dev_y, &dev_width, &dev_height))
|
if (!device_query_area (device, &dev_x, &dev_y, &dev_width, &dev_height))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (keep_aspect)
|
if (aspect_ratio > 0)
|
||||||
{
|
{
|
||||||
double aspect_ratio, dev_aspect;
|
double dev_aspect;
|
||||||
|
|
||||||
if (logical_monitor)
|
|
||||||
{
|
|
||||||
width = logical_monitor->rect.width;
|
|
||||||
height = logical_monitor->rect.height;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MetaMonitorManager *monitor_manager;
|
|
||||||
MetaBackend *backend;
|
|
||||||
|
|
||||||
backend = meta_get_backend ();
|
|
||||||
monitor_manager = meta_backend_get_monitor_manager (backend);
|
|
||||||
meta_monitor_manager_get_screen_size (monitor_manager,
|
|
||||||
&width, &height);
|
|
||||||
}
|
|
||||||
|
|
||||||
aspect_ratio = (double) width / height;
|
|
||||||
dev_aspect = (double) dev_width / dev_height;
|
dev_aspect = (double) dev_width / dev_height;
|
||||||
|
|
||||||
if (dev_aspect > aspect_ratio)
|
if (dev_aspect > aspect_ratio)
|
||||||
@ -937,7 +918,7 @@ meta_input_settings_x11_class_init (MetaInputSettingsX11Class *klass)
|
|||||||
input_settings_class->set_keyboard_repeat = meta_input_settings_x11_set_keyboard_repeat;
|
input_settings_class->set_keyboard_repeat = meta_input_settings_x11_set_keyboard_repeat;
|
||||||
|
|
||||||
input_settings_class->set_tablet_mapping = meta_input_settings_x11_set_tablet_mapping;
|
input_settings_class->set_tablet_mapping = meta_input_settings_x11_set_tablet_mapping;
|
||||||
input_settings_class->set_tablet_keep_aspect = meta_input_settings_x11_set_tablet_keep_aspect;
|
input_settings_class->set_tablet_aspect_ratio = meta_input_settings_x11_set_tablet_aspect_ratio;
|
||||||
input_settings_class->set_tablet_area = meta_input_settings_x11_set_tablet_area;
|
input_settings_class->set_tablet_area = meta_input_settings_x11_set_tablet_area;
|
||||||
|
|
||||||
input_settings_class->set_mouse_accel_profile = meta_input_settings_x11_set_mouse_accel_profile;
|
input_settings_class->set_mouse_accel_profile = meta_input_settings_x11_set_mouse_accel_profile;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user