1
1
Fork 0
mirror of https://github.com/swaywm/sway synced 2024-05-09 11:46:03 +02:00

Compare commits

...

34 Commits

Author SHA1 Message Date
jlo62 a31ff9d025
Merge 81cecd3b04 into 646019cad9 2024-04-24 12:21:29 +02:00
Kenny Levinsen 646019cad9 desktop/output: Fix check if config should be stored
We want to check if a config_head existed for the current
matched_output_config, so we should check cfg->output. sway_output is a
temporary variable from a previous wl_list_for_each, and does not
contain anything useful to us.

Fixes: https://github.com/swaywm/sway/issues/8128
2024-04-23 13:31:30 +02:00
Kenny Levinsen ffcde7a70c server: Use wlr_renderer_get_texture_formats
wlr_renderer_get_{dmabuf|shm}_texture_formats have been replaced by a
unified wlr_renderer_get_texture_formats interface using buffer caps.

References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4644
2024-04-21 17:19:33 +02:00
jlo62 81cecd3b04
Merge branch 'master' into sensitivity 2023-12-01 09:29:22 +01:00
jlo62 fecd2cb323
Merge branch 'master' into sensitivity 2023-11-21 14:31:13 +01:00
jlo62 92df8b03df
Merge branch 'swaywm:master' into sensitivity 2023-11-21 08:22:19 +01:00
jlo62 2fef636f74
Merge branch 'master' into sensitivity 2023-11-07 15:31:45 +01:00
jlo62 539cf9f3e8
Merge branch 'master' into sensitivity 2023-10-31 14:38:19 +01:00
jlo62 8ff53f9094
Merge branch 'master' into sensitivity 2023-10-24 20:53:58 +02:00
jlo62 55a02c7d6b
Merge branch 'master' into sensitivity 2023-10-05 06:27:19 +02:00
jlo62 026b3a6324
Update ipc-json.c 2023-09-18 18:14:14 +02:00
jlo62 a441c20a46 Revert "Update ipc-json.c"
This reverts commit 48c0c0b9d6.
2023-09-18 18:03:14 +02:00
jlo62 db98bdd4d2 Revert "Update ipc-json.c"
This reverts commit 3149f533fe.
2023-09-18 18:02:56 +02:00
jlo62 3149f533fe
Update ipc-json.c 2023-09-18 12:37:18 +02:00
jlo62 48c0c0b9d6
Update ipc-json.c 2023-09-18 12:13:47 +02:00
jlo62 475e289226
Update input.c 2023-09-18 11:56:41 +02:00
jlo62 47ac4cd87e
Update cursor.c 2023-09-17 20:35:06 +02:00
jlo62 bda7f681e7
Update cursor.c 2023-09-17 20:32:36 +02:00
jlo62 23ad8be535
Update cursor.c 2023-09-17 20:31:03 +02:00
jlo62 3996e54dfb
Update cursor.c 2023-09-17 20:29:11 +02:00
jlo62 a2c9e8f7e1
Update cursor.c 2023-09-17 20:27:32 +02:00
jlo62 f2ebfc25b7
Update cursor.c 2023-09-17 20:26:44 +02:00
jlo62 094c0004a6
Update cursor.c 2023-09-17 20:20:38 +02:00
jlo62 9932197d16
Update sway-ipc.7.scd 2023-09-17 19:37:18 +02:00
jlo62 ec7e1681fc
Update sway-input.5.scd 2023-09-17 19:36:27 +02:00
jlo62 4f5753dd6b
Update meson.build 2023-09-17 19:35:38 +02:00
jlo62 62266d5da7
Update ipc-json.c 2023-09-17 19:35:00 +02:00
jlo62 5305ccab0a
Update input-manager.c 2023-09-17 19:30:03 +02:00
jlo62 ec3e47df91
Update cursor.c 2023-09-17 19:29:09 +02:00
jlo62 4d87b7ba9e
Update input.c 2023-09-17 08:04:46 +02:00
jlo62 0bb8dd8c85
Create sensitivity.c 2023-09-17 07:41:16 +02:00
jlo62 fef41686d6
Update input-manager.h 2023-09-17 07:39:19 +02:00
jlo62 919ea1531a
Update config.h 2023-09-17 07:37:55 +02:00
jlo62 84dd73d021
Update commands.h 2023-09-17 07:34:03 +02:00
14 changed files with 75 additions and 15 deletions

View File

@ -261,6 +261,7 @@ sway_cmd input_cmd_map_to_region;
sway_cmd input_cmd_middle_emulation;
sway_cmd input_cmd_natural_scroll;
sway_cmd input_cmd_pointer_accel;
sway_cmd input_cmd_sensitivity;
sway_cmd input_cmd_rotation_angle;
sway_cmd input_cmd_scroll_factor;
sway_cmd input_cmd_repeat_delay;

View File

@ -156,6 +156,7 @@ struct input_config {
int middle_emulation;
int natural_scroll;
float pointer_accel;
float sensitivity;
float rotation_angle;
float scroll_factor;
int repeat_delay;

View File

@ -75,4 +75,6 @@ char *input_device_get_identifier(struct wlr_input_device *device);
const char *input_device_get_type(struct sway_input_device *device);
struct sway_input_device *input_sway_device_from_wlr(struct wlr_input_device *device);
#endif

View File

@ -30,6 +30,7 @@ static const struct cmd_handler input_handlers[] = {
{ "scroll_button_lock", input_cmd_scroll_button_lock },
{ "scroll_factor", input_cmd_scroll_factor },
{ "scroll_method", input_cmd_scroll_method },
{ "sensitivity", input_cmd_sensitivity },
{ "tap", input_cmd_tap },
{ "tap_button_map", input_cmd_tap_button_map },
{ "tool_mode", input_cmd_tool_mode },

View File

@ -0,0 +1,30 @@
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include "sway/config.h"
#include "sway/commands.h"
#include "sway/input/input-manager.h"
#include "util.h"
struct cmd_results *input_cmd_sensitivity(int argc, char **argv) {
struct cmd_results *error = NULL;
if ((error = checkarg(argc, "sensitivity", EXPECTED_AT_LEAST, 1))) {
return error;
}
struct input_config *ic = config->handler_context.input_config;
if (!ic) {
return cmd_results_new(CMD_FAILURE, "No input device defined.");
}
float sensitivity = parse_float(argv[0]);
if (isnan(sensitivity)) {
return cmd_results_new(CMD_INVALID,
"Invalid sensitivity; expected float.");
} else if (sensitivity < 0) {
return cmd_results_new(CMD_INVALID,
"Sensitivity cannot be negative.");
}
ic->sensitivity = sensitivity;
return cmd_results_new(CMD_SUCCESS, NULL);
}

View File

@ -32,6 +32,7 @@ struct input_config *new_input_config(const char* identifier) {
input->accel_profile = INT_MIN;
input->rotation_angle = FLT_MIN;
input->pointer_accel = FLT_MIN;
input->sensitivity = FLT_MIN;
input->scroll_factor = FLT_MIN;
input->scroll_button = INT_MIN;
input->scroll_button_lock = INT_MIN;
@ -81,6 +82,9 @@ void merge_input_config(struct input_config *dst, struct input_config *src) {
if (src->pointer_accel != FLT_MIN) {
dst->pointer_accel = src->pointer_accel;
}
if (src->sensitivity != FLT_MIN) {
dst->sensitivity = src->sensitivity;
}
if (src->scroll_factor != FLT_MIN) {
dst->scroll_factor = src->scroll_factor;
}

View File

@ -619,7 +619,7 @@ static void output_manager_apply(struct sway_server *server,
if (!test_only && ok) {
struct wlr_output_configuration_head_v1 *config_head;
wl_list_for_each(config_head, &config->heads, link) {
if (config_head->state.output == sway_output->wlr_output) {
if (config_head->state.output == cfg->output->wlr_output) {
store_config = true;
break;
}

View File

@ -1,5 +1,6 @@
#include <assert.h>
#include <math.h>
#include <float.h>
#include <libevdev/libevdev.h>
#include <linux/input-event-codes.h>
#include <errno.h>
@ -20,6 +21,7 @@
#include "util.h"
#include "sway/commands.h"
#include "sway/input/cursor.h"
#include "sway/input/input-manager.h"
#include "sway/input/keyboard.h"
#include "sway/input/tablet.h"
#include "sway/layers.h"
@ -29,7 +31,8 @@
#include "sway/tree/root.h"
#include "sway/tree/view.h"
#include "sway/tree/workspace.h"
#include "wlr-layer-shell-unstable-v1-protocol.h"
#include "sway/commands.h"
#include "sway/config.h"
static uint32_t get_current_time_msec(void) {
struct timespec now;
@ -330,10 +333,15 @@ static void handle_pointer_motion_relative(
struct wl_listener *listener, void *data) {
struct sway_cursor *cursor = wl_container_of(listener, cursor, motion);
struct wlr_pointer_motion_event *e = data;
struct sway_input_device *sid = input_sway_device_from_wlr(&e->pointer->base);
struct input_config *ic = sid ? input_device_get_config(sid) : NULL;
float sensitivity = (ic && ic->sensitivity != FLT_MIN) ? ic->sensitivity : 1.0f;
cursor_handle_activity_from_device(cursor, &e->pointer->base);
pointer_motion(cursor, e->time_msec, &e->pointer->base, e->delta_x,
e->delta_y, e->unaccel_dx, e->unaccel_dy);
pointer_motion(cursor, e->time_msec, &e->pointer->base, e->delta_x * sensitivity,
e->delta_y * sensitivity, e->unaccel_dx, e->unaccel_dy);
}
static void handle_pointer_motion_absolute(

View File

@ -161,7 +161,7 @@ static void apply_input_type_config(struct sway_input_device *input_device) {
}
}
static struct sway_input_device *input_sway_device_from_wlr(
struct sway_input_device *input_sway_device_from_wlr(
struct wlr_input_device *device) {
struct sway_input_device *input_device = NULL;
wl_list_for_each(input_device, &server.input->devices, link) {

View File

@ -1136,12 +1136,18 @@ json_object *ipc_json_describe_input(struct sway_input_device *device) {
if (device->wlr_device->type == WLR_INPUT_DEVICE_POINTER) {
struct input_config *ic = input_device_get_config(device);
float scroll_factor = 1.0f;
if (ic != NULL && !isnan(ic->scroll_factor) &&
ic->scroll_factor != FLT_MIN) {
scroll_factor = ic->scroll_factor;
float sensitivity = 1.0f;
(void)scroll_factor;
(void)sensitivity;
if (ic != NULL) {
if (!isnan(ic->scroll_factor) && ic->scroll_factor != FLT_MIN) {
scroll_factor = ic->scroll_factor;
}
if (!isnan(ic->sensitivity) && ic->sensitivity != FLT_MIN) {
sensitivity = ic->sensitivity;
}
}
json_object_object_add(object, "scroll_factor",
json_object_new_double(scroll_factor));
}
#if WLR_HAS_LIBINPUT_BACKEND

View File

@ -166,6 +166,7 @@ sway_sources = files(
'commands/input/middle_emulation.c',
'commands/input/natural_scroll.c',
'commands/input/pointer_accel.c',
'commands/input/sensitivity.c',
'commands/input/rotation_angle.c',
'commands/input/repeat_delay.c',
'commands/input/repeat_rate.c',

View File

@ -240,13 +240,12 @@ bool server_init(struct sway_server *server) {
wlr_renderer_init_wl_shm(server->renderer, server->wl_display);
if (wlr_renderer_get_dmabuf_texture_formats(server->renderer) != NULL) {
if (wlr_renderer_get_texture_formats(server->renderer, WLR_BUFFER_CAP_DMABUF) != NULL) {
server->linux_dmabuf_v1 = wlr_linux_dmabuf_v1_create_with_renderer(
server->wl_display, 4, server->renderer);
}
if (wlr_renderer_get_dmabuf_texture_formats(server->renderer) != NULL &&
debug.legacy_wl_drm) {
wlr_drm_create(server->wl_display, server->renderer);
if (debug.legacy_wl_drm) {
wlr_drm_create(server->wl_display, server->renderer);
}
}
server->allocator = wlr_allocator_autocreate(server->backend,

View File

@ -180,6 +180,10 @@ The following commands may only be used in the configuration file.
*input* <identifier> pointer_accel [<-1|1>]
Changes the pointer acceleration for the specified input device.
*input* <identifier> sensitivity <floating point value>
Multiplies the sensitivity of a relative pointing input device. Has no
effect on absolute pointing devices.
*input* <identifier> rotation_angle <angle>
Sets the rotation angle of the device to the given clockwise angle in
degrees. The angle must be between 0.0 (inclusive) and 360.0 (exclusive).

View File

@ -1144,6 +1144,9 @@ following properties:
|- scroll_factor
: floating
: (Only pointers) Multiplier applied on scroll event values.
|- sensitivity
: floating
: (Only pointers) Multiplier applied on relative pointer movements.
|- libinput
: object
: (Only libinput devices) An object describing the current device settings.