aboutsummaryrefslogtreecommitdiffstats
path: root/swaybar/render.c
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-01-10 12:43:10 -0500
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-01-10 12:43:10 -0500
commit3d6440ec26f2b39c54fd03aa3a3c822a8a2bbc72 (patch)
tree05e5dddd092b3d3ba16166a3784a49923e9f3de2 /swaybar/render.c
parentMerge pull request #3400 from ianyfan/config-brace (diff)
downloadsway-3d6440ec26f2b39c54fd03aa3a3c822a8a2bbc72.tar.gz
sway-3d6440ec26f2b39c54fd03aa3a3c822a8a2bbc72.tar.zst
sway-3d6440ec26f2b39c54fd03aa3a3c822a8a2bbc72.zip
bar_cmd_bind: utilize mouse button helpers
This modifies `bar_cmd_bindsym` to use `get_mouse_bindsym` for parsing mouse buttons. This also introduces `cmd_bar_bindcode`, which will use `get_mouse_bindcode` for parsing mouse buttons. Like sway bindings, the two commands are encapsulated in a single file with shared code. This also modifies swaybar to operate off of event codes rather than x11 button numbers, which allows for any mouse button to be used. This introduces two new IPC properties: - For `get_bar_config`, `event_code` has been added to the `bindings` section and will include to event code for the button. If the event code can be mapped to a x11 button, `input_code` will still be the x11 button number. Otherwise, `input_code` will be `0`. - Likewise for `click_events`, `event` has been added and will include the event code for the button clicked. If the event code can be mapped to a x11 button, `button` will still be the x11 button number. Otherwise, `button` will be `0`.
Diffstat (limited to 'swaybar/render.c')
-rw-r--r--swaybar/render.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/swaybar/render.c b/swaybar/render.c
index 7cbcea07..670e8e74 100644
--- a/swaybar/render.c
+++ b/swaybar/render.c
@@ -1,5 +1,6 @@
1#define _POSIX_C_SOURCE 200809L 1#define _POSIX_C_SOURCE 200809L
2#include <assert.h> 2#include <assert.h>
3#include <linux/input-event-codes.h>
3#include <limits.h> 4#include <limits.h>
4#include <stdlib.h> 5#include <stdlib.h>
5#include <stdint.h> 6#include <stdint.h>
@@ -126,13 +127,13 @@ static void render_sharp_line(cairo_t *cairo, uint32_t color,
126 } 127 }
127} 128}
128 129
129static enum hotspot_event_handling block_hotspot_callback(struct swaybar_output *output, 130static enum hotspot_event_handling block_hotspot_callback(
130 struct swaybar_hotspot *hotspot, 131 struct swaybar_output *output, struct swaybar_hotspot *hotspot,
131 int x, int y, enum x11_button button, void *data) { 132 int x, int y, uint32_t button, void *data) {
132 struct i3bar_block *block = data; 133 struct i3bar_block *block = data;
133 struct status_line *status = output->bar->status; 134 struct status_line *status = output->bar->status;
134 return i3bar_block_send_click(status, block, x, y, x - hotspot->x, y - hotspot->y, 135 return i3bar_block_send_click(status, block, x, y, x - hotspot->x,
135 hotspot->width, hotspot->height, button); 136 y - hotspot->y, hotspot->width, hotspot->height, button);
136} 137}
137 138
138static void i3bar_block_unref_callback(void *data) { 139static void i3bar_block_unref_callback(void *data) {
@@ -360,10 +361,10 @@ static uint32_t render_binding_mode_indicator(cairo_t *cairo,
360 return output->height; 361 return output->height;
361} 362}
362 363
363static enum hotspot_event_handling workspace_hotspot_callback(struct swaybar_output *output, 364static enum hotspot_event_handling workspace_hotspot_callback(
364 struct swaybar_hotspot *hotspot, 365 struct swaybar_output *output, struct swaybar_hotspot *hotspot,
365 int x, int y, enum x11_button button, void *data) { 366 int x, int y, uint32_t button, void *data) {
366 if (button != LEFT) { 367 if (button != BTN_LEFT) {
367 return HOTSPOT_PROCESS; 368 return HOTSPOT_PROCESS;
368 } 369 }
369 ipc_send_workspace_command(output->bar, (const char *)data); 370 ipc_send_workspace_command(output->bar, (const char *)data);