home: mobile patches for mako and rofi-wayland
This commit is contained in:
parent
319538d866
commit
bd0f0b2720
|
@ -34,6 +34,7 @@ audioPrev = pkgs.writeShellScript "playerctl-prev" ''
|
|||
${pkgs.playerctl}/bin/playerctl play
|
||||
fi
|
||||
'';
|
||||
# TODO: only unidle mako when unlocked
|
||||
swaylock =
|
||||
if config.phone.enable
|
||||
then "${pkgs.schlock}/bin/schlock -fp /secrets/schlock.pin"
|
||||
|
@ -44,10 +45,12 @@ swaylock-start = pkgs.writeShellScript "swaylock-start" ''
|
|||
dpms-off = pkgs.writeShellScript "sway-dpms-off" ''
|
||||
${config.wayland.windowManager.sway.package}/bin/swaymsg output "*" power off
|
||||
${config.wayland.windowManager.sway.package}/bin/swaymsg input type:touch events disabled
|
||||
${config.services.mako.package}/bin/makoctl mode -a idle
|
||||
'';
|
||||
dpms-on = pkgs.writeShellScript "sway-dpms-on" ''
|
||||
${config.wayland.windowManager.sway.package}/bin/swaymsg output "*" power on
|
||||
${config.wayland.windowManager.sway.package}/bin/swaymsg input type:touch events enabled
|
||||
${config.services.mako.package}/bin/makoctl mode -r idle
|
||||
'';
|
||||
lock-script = pkgs.writeShellScript "lock-start" ''
|
||||
${swaylock-start}
|
||||
|
@ -229,9 +232,17 @@ in
|
|||
};
|
||||
services.mako = {
|
||||
enable = lib.mkDefault config.wayland.windowManager.sway.enable;
|
||||
# ms
|
||||
defaultTimeout = 7500;
|
||||
package = pkgs.mako.overrideAttrs (old: {
|
||||
patches = old.patches or []
|
||||
++ (lib.mapAttrsToList (k: v: ../../pkgs/mako/${k}) (builtins.readDir ../../pkgs/mako));
|
||||
});
|
||||
defaultTimeout = 10000;
|
||||
font = "Noto Sans Mono 12";
|
||||
extraConfig = ''
|
||||
max-history=50
|
||||
[mode=idle]
|
||||
freeze=1
|
||||
'';
|
||||
};
|
||||
xsession.windowManager.i3 = {
|
||||
config = let i3Config = {
|
||||
|
@ -279,9 +290,9 @@ in
|
|||
sha256 = "sha256-XgkysduhHbmprE334yeL65txpK0HNXeCmgCZMxpwsgU=";
|
||||
})*/
|
||||
] ++ lib.optionals config.phone.enable
|
||||
(map
|
||||
(x: ../../pkgs/sway/${x})
|
||||
(builtins.filter (lib.hasInfix "-mobile-") (builtins.attrNames (builtins.readDir ../../pkgs/sway))));
|
||||
(lib.mapAttrsToList
|
||||
(k: v: ../../pkgs/sway/${k})
|
||||
(lib.filterAttrs (k: v: lib.hasInfix "-mobile-" k) (builtins.readDir ../../pkgs/sway)));
|
||||
});
|
||||
inherit (cfg) extraSessionCommands extraOptions;
|
||||
withBaseWrapper = cfg.wrapperFeatures.base;
|
||||
|
@ -511,7 +522,12 @@ in
|
|||
programs.rofi = {
|
||||
enable = true;
|
||||
font = "Noto Sans Mono 16";
|
||||
package = lib.mkIf config.wayland.windowManager.sway.enable pkgs.rofi-wayland;
|
||||
package = lib.mkIf config.wayland.windowManager.sway.enable (pkgs.rofi-wayland.override {
|
||||
rofi-unwrapped = pkgs.rofi-wayland-unwrapped.overrideAttrs (old: {
|
||||
patches = old.patches or []
|
||||
++ (lib.mapAttrsToList (k: v: ../../pkgs/rofi-wayland/${k}) (builtins.readDir ../../pkgs/rofi-wayland));
|
||||
});
|
||||
});
|
||||
plugins = with pkgs; [
|
||||
rofi-calc
|
||||
];
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
, xorg
|
||||
, xvfb-run
|
||||
, dbus
|
||||
, gnome
|
||||
, adwaita-icon-theme
|
||||
, alsa-lib
|
||||
, glib
|
||||
, glib-networking
|
||||
|
@ -89,7 +89,7 @@ in gimp.overrideAttrs (old: rec {
|
|||
json-glib
|
||||
python
|
||||
xorg.libXmu
|
||||
gnome.adwaita-icon-theme
|
||||
adwaita-icon-theme
|
||||
(luajit.withPackages (ps: [ ps.lgi ]))
|
||||
alsa-lib
|
||||
gjs
|
||||
|
@ -130,7 +130,7 @@ in gimp.overrideAttrs (old: rec {
|
|||
preFixup = ''
|
||||
gappsWrapperArgs+=(\
|
||||
--prefix PATH : "${lib.makeBinPath [ graphviz ]}:$out/bin" \
|
||||
--suffix XDG_DATA_DIRS : "${gnome.adwaita-icon-theme}/share" \
|
||||
--suffix XDG_DATA_DIRS : "${adwaita-icon-theme}/share" \
|
||||
)
|
||||
'';
|
||||
postFixup = ''
|
||||
|
|
210
pkgs/mako/0001-add-on-long-touch-option.patch
Normal file
210
pkgs/mako/0001-add-on-long-touch-option.patch
Normal file
|
@ -0,0 +1,210 @@
|
|||
From 85bbcf7e18136f788cf76bb6f345ade84a5e536e Mon Sep 17 00:00:00 2001
|
||||
From: chayleaf <chayleaf-git@pavluk.org>
|
||||
Date: Sat, 24 Aug 2024 10:49:21 +0700
|
||||
Subject: [PATCH 1/5] add on-long-touch option
|
||||
|
||||
---
|
||||
config.c | 21 +++++++++++++++++++++
|
||||
doc/mako.5.scd | 15 ++++++++++++++-
|
||||
include/config.h | 7 ++++---
|
||||
include/notification.h | 2 +-
|
||||
include/wayland.h | 1 +
|
||||
notification.c | 8 ++++++--
|
||||
wayland.c | 3 ++-
|
||||
7 files changed, 49 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/config.c b/config.c
|
||||
index 70be717..87db932 100644
|
||||
--- a/config.c
|
||||
+++ b/config.c
|
||||
@@ -129,6 +129,9 @@ void init_default_style(struct mako_style *style) {
|
||||
style->button_bindings.right.action = MAKO_BINDING_DISMISS;
|
||||
style->button_bindings.middle.action = MAKO_BINDING_NONE;
|
||||
style->touch_binding.action = MAKO_BINDING_DISMISS;
|
||||
+ style->long_touch_binding.action = MAKO_BINDING_INVOKE_ACTION;
|
||||
+ style->long_touch_binding.action_name = strdup(DEFAULT_ACTION_KEY);
|
||||
+ style->long_press_duration = 500;
|
||||
|
||||
// Everything in the default config is explicitly specified.
|
||||
memset(&style->spec, true, sizeof(struct mako_style_spec));
|
||||
@@ -148,6 +151,7 @@ void finish_style(struct mako_style *style) {
|
||||
finish_binding(&style->button_bindings.middle);
|
||||
finish_binding(&style->button_bindings.right);
|
||||
finish_binding(&style->touch_binding);
|
||||
+ finish_binding(&style->long_touch_binding);
|
||||
finish_binding(&style->notify_binding);
|
||||
free(style->icon_path);
|
||||
free(style->font);
|
||||
@@ -385,6 +389,16 @@ bool apply_style(struct mako_style *target, const struct mako_style *style) {
|
||||
target->spec.touch_binding = true;
|
||||
}
|
||||
|
||||
+ if (style->spec.long_touch_binding) {
|
||||
+ copy_binding(&target->long_touch_binding, &style->long_touch_binding);
|
||||
+ target->spec.long_touch_binding = true;
|
||||
+ }
|
||||
+
|
||||
+ if (style->spec.long_press_duration) {
|
||||
+ target->long_press_duration = style->long_press_duration;
|
||||
+ target->spec.long_press_duration = true;
|
||||
+ }
|
||||
+
|
||||
if (style->spec.notify_binding) {
|
||||
copy_binding(&target->notify_binding, &style->notify_binding);
|
||||
target->spec.notify_binding = true;
|
||||
@@ -660,6 +674,8 @@ static bool apply_style_option(struct mako_style *style, const char *name,
|
||||
return true;
|
||||
} else if (strcmp(name, "anchor") == 0) {
|
||||
return spec->anchor = parse_anchor(value, &style->anchor);
|
||||
+ } else if (strcmp(name, "long-press-duration") == 0) {
|
||||
+ return spec->long_press_duration = parse_int_ge(value, &style->long_press_duration, 0);
|
||||
} else if (has_prefix(name, "on-")) {
|
||||
struct mako_binding binding = {0};
|
||||
if (strcmp(value, "none") == 0) {
|
||||
@@ -697,6 +713,9 @@ static bool apply_style_option(struct mako_style *style, const char *name,
|
||||
} else if (strcmp(name, "on-touch") == 0) {
|
||||
copy_binding(&style->touch_binding, &binding);
|
||||
style->spec.touch_binding = true;
|
||||
+ } else if (strcmp(name, "on-long-touch") == 0) {
|
||||
+ copy_binding(&style->long_touch_binding, &binding);
|
||||
+ style->spec.long_touch_binding = true;
|
||||
} else if (strcmp(name, "on-notify") == 0) {
|
||||
copy_binding(&style->notify_binding, &binding);
|
||||
style->spec.notify_binding = true;
|
||||
@@ -886,6 +905,8 @@ int parse_config_arguments(struct mako_config *config, int argc, char **argv) {
|
||||
{"on-button-right", required_argument, 0, 0},
|
||||
{"on-button-middle", required_argument, 0, 0},
|
||||
{"on-touch", required_argument, 0, 0},
|
||||
+ {"on-long-touch", required_argument, 0, 0},
|
||||
+ {"long-press-duration", required_argument, 0, 0},
|
||||
{0},
|
||||
};
|
||||
|
||||
diff --git a/doc/mako.5.scd b/doc/mako.5.scd
|
||||
index 91378ba..fff19ed 100644
|
||||
--- a/doc/mako.5.scd
|
||||
+++ b/doc/mako.5.scd
|
||||
@@ -57,10 +57,23 @@ Supported options:
|
||||
Default: dismiss
|
||||
|
||||
*on-touch*=_action_
|
||||
- Performs the action when tapped via a touch device.
|
||||
+ Performs the action when tapped via a touch device if the tap
|
||||
+ duration is less than *long-press-duration*.
|
||||
|
||||
Default: dismiss
|
||||
|
||||
+*on-long-touch*=_action_
|
||||
+ Performs the action when tapped via a touch device if the press
|
||||
+ duration is greater or equal to *long-press-duration*.
|
||||
+
|
||||
+ Default: invoke-default-action
|
||||
+
|
||||
+*long-press-duration*=_time_
|
||||
+ Specifies the cutoff time (in milliseconds) for a press to be
|
||||
+ considered a long press.
|
||||
+
|
||||
+ Default: 500
|
||||
+
|
||||
*on-notify*=_action_
|
||||
Performs the action when the notification is opened.
|
||||
|
||||
diff --git a/include/config.h b/include/config.h
|
||||
index 013923a..5ff541c 100644
|
||||
--- a/include/config.h
|
||||
+++ b/include/config.h
|
||||
@@ -42,14 +42,14 @@ struct mako_style_spec {
|
||||
bool width, height, outer_margin, margin, padding, border_size, border_radius, font,
|
||||
markup, format, text_alignment, actions, default_timeout, ignore_timeout,
|
||||
icons, max_icon_size, icon_path, group_criteria_spec, invisible, history,
|
||||
- icon_location, max_visible, layer, output, anchor;
|
||||
+ icon_location, max_visible, layer, output, anchor, long_press_duration;
|
||||
struct {
|
||||
bool background, text, border, progress;
|
||||
} colors;
|
||||
struct {
|
||||
bool left, right, middle;
|
||||
} button_bindings;
|
||||
- bool touch_binding, notify_binding;
|
||||
+ bool touch_binding, long_touch_binding, notify_binding;
|
||||
};
|
||||
|
||||
|
||||
@@ -98,7 +98,8 @@ struct mako_style {
|
||||
struct {
|
||||
struct mako_binding left, right, middle;
|
||||
} button_bindings;
|
||||
- struct mako_binding touch_binding, notify_binding;
|
||||
+ struct mako_binding touch_binding, long_touch_binding, notify_binding;
|
||||
+ int32_t long_press_duration;
|
||||
};
|
||||
|
||||
struct mako_config {
|
||||
diff --git a/include/notification.h b/include/notification.h
|
||||
index 9a395ba..a02d855 100644
|
||||
--- a/include/notification.h
|
||||
+++ b/include/notification.h
|
||||
@@ -101,7 +101,7 @@ size_t format_notification(struct mako_notification *notif, const char *format,
|
||||
void notification_handle_button(struct mako_notification *notif, uint32_t button,
|
||||
enum wl_pointer_button_state state, const struct mako_binding_context *ctx);
|
||||
void notification_handle_touch(struct mako_notification *notif,
|
||||
- const struct mako_binding_context *ctx);
|
||||
+ const struct mako_binding_context *ctx, int32_t duration_ms);
|
||||
void notification_execute_binding(struct mako_notification *notif,
|
||||
const struct mako_binding *binding, const struct mako_binding_context *ctx);
|
||||
void insert_notification(struct mako_state *state, struct mako_notification *notif);
|
||||
diff --git a/include/wayland.h b/include/wayland.h
|
||||
index cc00500..c8767be 100644
|
||||
--- a/include/wayland.h
|
||||
+++ b/include/wayland.h
|
||||
@@ -35,6 +35,7 @@ struct mako_seat {
|
||||
struct wl_touch *wl_touch;
|
||||
struct {
|
||||
int32_t x, y;
|
||||
+ uint32_t time;
|
||||
struct mako_surface *surface;
|
||||
} pts[MAX_TOUCHPOINTS];
|
||||
} touch;
|
||||
diff --git a/notification.c b/notification.c
|
||||
index 8c0c8a7..7d3db2f 100644
|
||||
--- a/notification.c
|
||||
+++ b/notification.c
|
||||
@@ -446,8 +446,12 @@ void notification_handle_button(struct mako_notification *notif, uint32_t button
|
||||
}
|
||||
|
||||
void notification_handle_touch(struct mako_notification *notif,
|
||||
- const struct mako_binding_context *ctx) {
|
||||
- notification_execute_binding(notif, ¬if->style.touch_binding, ctx);
|
||||
+ const struct mako_binding_context *ctx, int32_t duration_ms) {
|
||||
+ if (duration_ms >= notif->style.long_press_duration) {
|
||||
+ notification_execute_binding(notif, ¬if->style.long_touch_binding, ctx);
|
||||
+ } else {
|
||||
+ notification_execute_binding(notif, ¬if->style.touch_binding, ctx);
|
||||
+ }
|
||||
}
|
||||
|
||||
/*
|
||||
diff --git a/wayland.c b/wayland.c
|
||||
index eeefb30..d247779 100644
|
||||
--- a/wayland.c
|
||||
+++ b/wayland.c
|
||||
@@ -122,6 +122,7 @@ static void touch_handle_down(void *data, struct wl_touch *wl_touch,
|
||||
}
|
||||
seat->touch.pts[id].x = wl_fixed_to_int(surface_x);
|
||||
seat->touch.pts[id].y = wl_fixed_to_int(surface_y);
|
||||
+ seat->touch.pts[id].time = time;
|
||||
seat->touch.pts[id].surface = get_surface(seat->state, wl_surface);
|
||||
}
|
||||
|
||||
@@ -144,7 +145,7 @@ static void touch_handle_up(void *data, struct wl_touch *wl_touch,
|
||||
wl_list_for_each(notif, &state->notifications, link) {
|
||||
if (hotspot_at(¬if->hotspot, seat->touch.pts[id].x, seat->touch.pts[id].y)) {
|
||||
struct mako_surface *surface = notif->surface;
|
||||
- notification_handle_touch(notif, &ctx);
|
||||
+ notification_handle_touch(notif, &ctx, time - seat->touch.pts[id].time);
|
||||
set_dirty(surface);
|
||||
break;
|
||||
}
|
||||
--
|
||||
2.45.2
|
||||
|
|
@ -0,0 +1,151 @@
|
|||
From 7365261e130016e884371d2e288b83e16a9dcb48 Mon Sep 17 00:00:00 2001
|
||||
From: chayleaf <chayleaf-git@pavluk.org>
|
||||
Date: Sat, 24 Aug 2024 13:50:38 +0700
|
||||
Subject: [PATCH 2/5] consider long press done even before release
|
||||
|
||||
---
|
||||
include/notification.h | 16 ++++++++++------
|
||||
include/wayland.h | 1 +
|
||||
notification.c | 22 ++++++++++++++++++++++
|
||||
wayland.c | 15 ++++++++++++++-
|
||||
4 files changed, 47 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/include/notification.h b/include/notification.h
|
||||
index a02d855..b1482ec 100644
|
||||
--- a/include/notification.h
|
||||
+++ b/include/notification.h
|
||||
@@ -19,6 +19,12 @@ struct mako_hotspot {
|
||||
int32_t width, height;
|
||||
};
|
||||
|
||||
+struct mako_binding_context {
|
||||
+ struct mako_surface *surface;
|
||||
+ struct mako_seat *seat;
|
||||
+ uint32_t serial;
|
||||
+};
|
||||
+
|
||||
struct mako_notification {
|
||||
struct mako_state *state;
|
||||
struct mako_surface *surface;
|
||||
@@ -38,6 +44,8 @@ struct mako_notification {
|
||||
char *body;
|
||||
int32_t requested_timeout;
|
||||
struct wl_list actions; // mako_action::link
|
||||
+ struct mako_timer *long_press_timer;
|
||||
+ struct mako_binding_context long_press_ctx;
|
||||
|
||||
enum mako_notification_urgency urgency;
|
||||
char *category;
|
||||
@@ -70,12 +78,6 @@ struct mako_hidden_format_data {
|
||||
size_t count;
|
||||
};
|
||||
|
||||
-struct mako_binding_context {
|
||||
- struct mako_surface *surface;
|
||||
- struct mako_seat *seat;
|
||||
- uint32_t serial;
|
||||
-};
|
||||
-
|
||||
typedef char *(*mako_format_func_t)(char variable, bool *markup, void *data);
|
||||
|
||||
bool hotspot_at(struct mako_hotspot *hotspot, int32_t x, int32_t y);
|
||||
@@ -100,6 +102,8 @@ size_t format_notification(struct mako_notification *notif, const char *format,
|
||||
char *buf);
|
||||
void notification_handle_button(struct mako_notification *notif, uint32_t button,
|
||||
enum wl_pointer_button_state state, const struct mako_binding_context *ctx);
|
||||
+void notification_handle_touch_start(struct mako_notification *notif,
|
||||
+ const struct mako_binding_context *ctx);
|
||||
void notification_handle_touch(struct mako_notification *notif,
|
||||
const struct mako_binding_context *ctx, int32_t duration_ms);
|
||||
void notification_execute_binding(struct mako_notification *notif,
|
||||
diff --git a/include/wayland.h b/include/wayland.h
|
||||
index c8767be..d4d39c4 100644
|
||||
--- a/include/wayland.h
|
||||
+++ b/include/wayland.h
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <wayland-client-protocol.h>
|
||||
+#include "mako.h"
|
||||
|
||||
#define MAX_TOUCHPOINTS 10
|
||||
|
||||
diff --git a/notification.c b/notification.c
|
||||
index 7d3db2f..32e7f7b 100644
|
||||
--- a/notification.c
|
||||
+++ b/notification.c
|
||||
@@ -41,6 +41,8 @@ void reset_notification(struct mako_notification *notif) {
|
||||
|
||||
destroy_timer(notif->timer);
|
||||
notif->timer = NULL;
|
||||
+ destroy_timer(notif->long_press_timer);
|
||||
+ notif->long_press_timer = NULL;
|
||||
|
||||
free(notif->app_name);
|
||||
free(notif->app_icon);
|
||||
@@ -447,6 +449,8 @@ void notification_handle_button(struct mako_notification *notif, uint32_t button
|
||||
|
||||
void notification_handle_touch(struct mako_notification *notif,
|
||||
const struct mako_binding_context *ctx, int32_t duration_ms) {
|
||||
+ destroy_timer(notif->long_press_timer);
|
||||
+ notif->long_press_timer = NULL;
|
||||
if (duration_ms >= notif->style.long_press_duration) {
|
||||
notification_execute_binding(notif, ¬if->style.long_touch_binding, ctx);
|
||||
} else {
|
||||
@@ -454,6 +458,24 @@ void notification_handle_touch(struct mako_notification *notif,
|
||||
}
|
||||
}
|
||||
|
||||
+void handle_notification_touch_timer(void *data) {
|
||||
+ struct mako_notification *notif = data;
|
||||
+ notif->long_press_timer = NULL;
|
||||
+ struct mako_binding_context ctx = notif->long_press_ctx;
|
||||
+ notification_execute_binding(notif, ¬if->style.long_touch_binding, &ctx);
|
||||
+ set_dirty(ctx.surface);
|
||||
+}
|
||||
+
|
||||
+void notification_handle_touch_start(struct mako_notification *notif,
|
||||
+ const struct mako_binding_context *ctx) {
|
||||
+ if (notif->long_press_timer) {
|
||||
+ return;
|
||||
+ }
|
||||
+ notif->long_press_ctx = *ctx;
|
||||
+ notif->long_press_timer = add_event_loop_timer(¬if->state->event_loop, 500,
|
||||
+ handle_notification_touch_timer, notif);
|
||||
+}
|
||||
+
|
||||
/*
|
||||
* Searches through the notifications list and returns the next position at
|
||||
* which to insert. If no results for the specified urgency are found,
|
||||
diff --git a/wayland.c b/wayland.c
|
||||
index d247779..6d8b6ff 100644
|
||||
--- a/wayland.c
|
||||
+++ b/wayland.c
|
||||
@@ -120,10 +120,23 @@ static void touch_handle_down(void *data, struct wl_touch *wl_touch,
|
||||
if (id >= MAX_TOUCHPOINTS) {
|
||||
return;
|
||||
}
|
||||
+ struct mako_state *state = seat->state;
|
||||
seat->touch.pts[id].x = wl_fixed_to_int(surface_x);
|
||||
seat->touch.pts[id].y = wl_fixed_to_int(surface_y);
|
||||
seat->touch.pts[id].time = time;
|
||||
- seat->touch.pts[id].surface = get_surface(seat->state, wl_surface);
|
||||
+ seat->touch.pts[id].surface = get_surface(state, wl_surface);
|
||||
+
|
||||
+ struct mako_notification *notif;
|
||||
+ const struct mako_binding_context ctx = {
|
||||
+ .surface = seat->touch.pts[id].surface,
|
||||
+ .seat = seat,
|
||||
+ .serial = serial,
|
||||
+ };
|
||||
+ wl_list_for_each(notif, &state->notifications, link) {
|
||||
+ if (hotspot_at(¬if->hotspot, seat->touch.pts[id].x, seat->touch.pts[id].y)) {
|
||||
+ notification_handle_touch_start(notif, &ctx);
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
|
||||
static void touch_handle_up(void *data, struct wl_touch *wl_touch,
|
||||
--
|
||||
2.45.2
|
||||
|
284
pkgs/mako/0003-dynamic-timeouts.patch
Normal file
284
pkgs/mako/0003-dynamic-timeouts.patch
Normal file
|
@ -0,0 +1,284 @@
|
|||
From 0b53bc7fb9494bc7a804a1d088c6b4137d6eef6d Mon Sep 17 00:00:00 2001
|
||||
From: chayleaf <chayleaf-git@pavluk.org>
|
||||
Date: Sat, 24 Aug 2024 08:47:49 +0700
|
||||
Subject: [PATCH 3/5] dynamic timeouts
|
||||
|
||||
Compute notification timeouts on every config change, rather than only
|
||||
on notification creation.
|
||||
---
|
||||
criteria.c | 50 ++++++++++++++++++++++++++++++++++++++----
|
||||
dbus/mako.c | 2 +-
|
||||
dbus/xdg.c | 21 +-----------------
|
||||
event-loop.c | 22 +++----------------
|
||||
include/criteria.h | 4 ++--
|
||||
include/event-loop.h | 2 +-
|
||||
include/notification.h | 1 +
|
||||
notification.c | 2 ++
|
||||
render.c | 4 ++--
|
||||
9 files changed, 59 insertions(+), 49 deletions(-)
|
||||
|
||||
diff --git a/criteria.c b/criteria.c
|
||||
index 9db3966..3108a38 100644
|
||||
--- a/criteria.c
|
||||
+++ b/criteria.c
|
||||
@@ -418,15 +418,38 @@ struct mako_criteria *global_criteria(struct mako_config *config) {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
-// Iterate through `criteria_list`, applying the style from each matching
|
||||
+static void timespec_add(struct timespec *t, int delta_ms) {
|
||||
+ static const long ms = 1000000, s = 1000000000;
|
||||
+
|
||||
+ int delta_ms_low = delta_ms % 1000;
|
||||
+ int delta_s_high = delta_ms / 1000;
|
||||
+
|
||||
+ t->tv_sec += delta_s_high;
|
||||
+
|
||||
+ t->tv_nsec += (long)delta_ms_low * ms;
|
||||
+ if (t->tv_nsec >= s) {
|
||||
+ t->tv_nsec -= s;
|
||||
+ ++t->tv_sec;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void handle_notification_timer(void *data) {
|
||||
+ struct mako_notification *notif = data;
|
||||
+ struct mako_surface *surface = notif->surface;
|
||||
+ notif->timer = NULL;
|
||||
+
|
||||
+ close_notification(notif, MAKO_NOTIFICATION_CLOSE_EXPIRED, true);
|
||||
+ set_dirty(surface);
|
||||
+}
|
||||
+
|
||||
+// Iterate through the criteria list, applying the style from each matching
|
||||
// criteria to `notif`. Returns the number of criteria that matched, or -1 if
|
||||
// a failure occurs.
|
||||
-ssize_t apply_each_criteria(struct wl_list *criteria_list,
|
||||
- struct mako_notification *notif) {
|
||||
+ssize_t apply_each_criteria(struct mako_state *state, struct mako_notification *notif) {
|
||||
ssize_t match_count = 0;
|
||||
|
||||
struct mako_criteria *criteria;
|
||||
- wl_list_for_each(criteria, criteria_list, link) {
|
||||
+ wl_list_for_each(criteria, &state->config.criteria, link) {
|
||||
if (!match_criteria(criteria, notif)) {
|
||||
continue;
|
||||
}
|
||||
@@ -447,6 +470,25 @@ ssize_t apply_each_criteria(struct wl_list *criteria_list,
|
||||
}
|
||||
}
|
||||
|
||||
+ int32_t expire_timeout = notif->requested_timeout;
|
||||
+ if (expire_timeout < 0 || notif->style.ignore_timeout) {
|
||||
+ expire_timeout = notif->style.default_timeout;
|
||||
+ }
|
||||
+
|
||||
+ if (expire_timeout > 0) {
|
||||
+ struct timespec at = notif->at;
|
||||
+ timespec_add(&at, expire_timeout);
|
||||
+ if (notif->timer) {
|
||||
+ notif->timer->at = at;
|
||||
+ } else {
|
||||
+ notif->timer = add_event_loop_timer(&state->event_loop, &at,
|
||||
+ handle_notification_timer, notif);
|
||||
+ }
|
||||
+ } else if (notif->timer) {
|
||||
+ destroy_timer(notif->timer);
|
||||
+ notif->timer = NULL;
|
||||
+ }
|
||||
+
|
||||
if (!notif->surface) {
|
||||
notif->surface = create_surface(notif->state, notif->style.output,
|
||||
notif->style.layer, notif->style.anchor);
|
||||
diff --git a/dbus/mako.c b/dbus/mako.c
|
||||
index 4c95881..8f3c874 100644
|
||||
--- a/dbus/mako.c
|
||||
+++ b/dbus/mako.c
|
||||
@@ -305,7 +305,7 @@ static void reapply_config(struct mako_state *state) {
|
||||
|
||||
finish_style(¬if->style);
|
||||
init_empty_style(¬if->style);
|
||||
- apply_each_criteria(&state->config.criteria, notif);
|
||||
+ apply_each_criteria(state, notif);
|
||||
|
||||
// Having to do this for every single notification really hurts... but
|
||||
// it does do The Right Thing (tm).
|
||||
diff --git a/dbus/xdg.c b/dbus/xdg.c
|
||||
index 1f91431..650dff7 100644
|
||||
--- a/dbus/xdg.c
|
||||
+++ b/dbus/xdg.c
|
||||
@@ -81,15 +81,6 @@ static int handle_get_capabilities(sd_bus_message *msg, void *data,
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static void handle_notification_timer(void *data) {
|
||||
- struct mako_notification *notif = data;
|
||||
- struct mako_surface *surface = notif->surface;
|
||||
- notif->timer = NULL;
|
||||
-
|
||||
- close_notification(notif, MAKO_NOTIFICATION_CLOSE_EXPIRED, true);
|
||||
- set_dirty(surface);
|
||||
-}
|
||||
-
|
||||
static int handle_notify(sd_bus_message *msg, void *data,
|
||||
sd_bus_error *ret_error) {
|
||||
struct mako_state *state = data;
|
||||
@@ -382,7 +373,7 @@ static int handle_notify(sd_bus_message *msg, void *data,
|
||||
insert_notification(state, notif);
|
||||
}
|
||||
|
||||
- int match_count = apply_each_criteria(&state->config.criteria, notif);
|
||||
+ int match_count = apply_each_criteria(state, notif);
|
||||
if (match_count == -1) {
|
||||
// We encountered an allocation failure or similar while applying
|
||||
// criteria. The notification may be partially matched, but the worst
|
||||
@@ -398,16 +389,6 @@ static int handle_notify(sd_bus_message *msg, void *data,
|
||||
return -1;
|
||||
}
|
||||
|
||||
- int32_t expire_timeout = notif->requested_timeout;
|
||||
- if (expire_timeout < 0 || notif->style.ignore_timeout) {
|
||||
- expire_timeout = notif->style.default_timeout;
|
||||
- }
|
||||
-
|
||||
- if (expire_timeout > 0) {
|
||||
- notif->timer = add_event_loop_timer(&state->event_loop, expire_timeout,
|
||||
- handle_notification_timer, notif);
|
||||
- }
|
||||
-
|
||||
if (notif->style.icons) {
|
||||
notif->icon = create_icon(notif);
|
||||
}
|
||||
diff --git a/event-loop.c b/event-loop.c
|
||||
index 99c1f4a..92c627a 100644
|
||||
--- a/event-loop.c
|
||||
+++ b/event-loop.c
|
||||
@@ -74,21 +74,6 @@ void finish_event_loop(struct mako_event_loop *loop) {
|
||||
}
|
||||
}
|
||||
|
||||
-static void timespec_add(struct timespec *t, int delta_ms) {
|
||||
- static const long ms = 1000000, s = 1000000000;
|
||||
-
|
||||
- int delta_ms_low = delta_ms % 1000;
|
||||
- int delta_s_high = delta_ms / 1000;
|
||||
-
|
||||
- t->tv_sec += delta_s_high;
|
||||
-
|
||||
- t->tv_nsec += (long)delta_ms_low * ms;
|
||||
- if (t->tv_nsec >= s) {
|
||||
- t->tv_nsec -= s;
|
||||
- ++t->tv_sec;
|
||||
- }
|
||||
-}
|
||||
-
|
||||
static bool timespec_less(struct timespec *t1, struct timespec *t2) {
|
||||
if (t1->tv_sec != t2->tv_sec) {
|
||||
return t1->tv_sec < t2->tv_sec;
|
||||
@@ -124,7 +109,7 @@ static void update_event_loop_timer(struct mako_event_loop *loop) {
|
||||
}
|
||||
|
||||
struct mako_timer *add_event_loop_timer(struct mako_event_loop *loop,
|
||||
- int delay_ms, mako_event_loop_timer_func_t func, void *data) {
|
||||
+ struct timespec *at, mako_event_loop_timer_func_t func, void *data) {
|
||||
struct mako_timer *timer = calloc(1, sizeof(struct mako_timer));
|
||||
if (timer == NULL) {
|
||||
fprintf(stderr, "allocation failed\n");
|
||||
@@ -133,10 +118,9 @@ struct mako_timer *add_event_loop_timer(struct mako_event_loop *loop,
|
||||
timer->event_loop = loop;
|
||||
timer->func = func;
|
||||
timer->user_data = data;
|
||||
- wl_list_insert(&loop->timers, &timer->link);
|
||||
+ timer->at = *at;
|
||||
|
||||
- clock_gettime(CLOCK_MONOTONIC, &timer->at);
|
||||
- timespec_add(&timer->at, delay_ms);
|
||||
+ wl_list_insert(&loop->timers, &timer->link);
|
||||
|
||||
update_event_loop_timer(loop);
|
||||
return timer;
|
||||
diff --git a/include/criteria.h b/include/criteria.h
|
||||
index 2f03514..58c36ef 100644
|
||||
--- a/include/criteria.h
|
||||
+++ b/include/criteria.h
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <wayland-client.h>
|
||||
#include "config.h"
|
||||
#include "types.h"
|
||||
+#include "mako.h"
|
||||
|
||||
struct mako_config;
|
||||
struct mako_notification;
|
||||
@@ -53,8 +54,7 @@ bool parse_criteria(const char *string, struct mako_criteria *criteria);
|
||||
bool apply_criteria_field(struct mako_criteria *criteria, char *token);
|
||||
|
||||
struct mako_criteria *global_criteria(struct mako_config *config);
|
||||
-ssize_t apply_each_criteria(struct wl_list *criteria_list,
|
||||
- struct mako_notification *notif);
|
||||
+ssize_t apply_each_criteria(struct mako_state *state, struct mako_notification *notif);
|
||||
struct mako_criteria *create_criteria_from_notification(
|
||||
struct mako_notification *notif, struct mako_criteria_spec *spec);
|
||||
|
||||
diff --git a/include/event-loop.h b/include/event-loop.h
|
||||
index 95c8d36..cd63e98 100644
|
||||
--- a/include/event-loop.h
|
||||
+++ b/include/event-loop.h
|
||||
@@ -47,7 +47,7 @@ bool init_event_loop(struct mako_event_loop *loop, sd_bus *bus,
|
||||
void finish_event_loop(struct mako_event_loop *loop);
|
||||
int run_event_loop(struct mako_event_loop *loop);
|
||||
struct mako_timer *add_event_loop_timer(struct mako_event_loop *loop,
|
||||
- int delay_ms, mako_event_loop_timer_func_t func, void *data);
|
||||
+ struct timespec *at, mako_event_loop_timer_func_t func, void *data);
|
||||
|
||||
void destroy_timer(struct mako_timer *timer);
|
||||
|
||||
diff --git a/include/notification.h b/include/notification.h
|
||||
index b1482ec..2775d88 100644
|
||||
--- a/include/notification.h
|
||||
+++ b/include/notification.h
|
||||
@@ -56,6 +56,7 @@ struct mako_notification {
|
||||
|
||||
struct mako_hotspot hotspot;
|
||||
struct mako_timer *timer;
|
||||
+ struct timespec at;
|
||||
};
|
||||
|
||||
struct mako_action {
|
||||
diff --git a/notification.c b/notification.c
|
||||
index 32e7f7b..b78bd09 100644
|
||||
--- a/notification.c
|
||||
+++ b/notification.c
|
||||
@@ -68,6 +68,8 @@ void reset_notification(struct mako_notification *notif) {
|
||||
|
||||
destroy_icon(notif->icon);
|
||||
notif->icon = NULL;
|
||||
+
|
||||
+ clock_gettime(CLOCK_MONOTONIC, ¬if->at);
|
||||
}
|
||||
|
||||
struct mako_notification *create_notification(struct mako_state *state) {
|
||||
diff --git a/render.c b/render.c
|
||||
index 5b68632..44b78a0 100644
|
||||
--- a/render.c
|
||||
+++ b/render.c
|
||||
@@ -355,7 +355,7 @@ void render(struct mako_surface *surface, struct pool_buffer *buffer, int scale,
|
||||
// Immediately before rendering we need to re-match all of the criteria
|
||||
// so that matches against the anchor and output work even if the
|
||||
// output was automatically assigned by the compositor.
|
||||
- int rematch_count = apply_each_criteria(&state->config.criteria, notif);
|
||||
+ int rematch_count = apply_each_criteria(state, notif);
|
||||
if (rematch_count == -1) {
|
||||
// We encountered an allocation failure or similar while applying
|
||||
// criteria. The notification may be partially matched, but the
|
||||
@@ -427,7 +427,7 @@ void render(struct mako_surface *surface, struct pool_buffer *buffer, int scale,
|
||||
struct mako_notification *hidden_notif = create_notification(state);
|
||||
hidden_notif->surface = surface;
|
||||
hidden_notif->hidden = true;
|
||||
- apply_each_criteria(&state->config.criteria, hidden_notif);
|
||||
+ apply_each_criteria(state, hidden_notif);
|
||||
|
||||
struct mako_style *style = &hidden_notif->style;
|
||||
|
||||
--
|
||||
2.45.2
|
||||
|
192
pkgs/mako/0004-implement-notification-time-freezing.patch
Normal file
192
pkgs/mako/0004-implement-notification-time-freezing.patch
Normal file
|
@ -0,0 +1,192 @@
|
|||
From e2cb0d80c643b03a61f69f85454c9ed06eda5c3e Mon Sep 17 00:00:00 2001
|
||||
From: chayleaf <chayleaf-git@pavluk.org>
|
||||
Date: Sat, 24 Aug 2024 09:19:34 +0700
|
||||
Subject: [PATCH 4/5] implement notification time freezing
|
||||
|
||||
---
|
||||
config.c | 8 +++++++
|
||||
criteria.c | 49 +++++++++++++++++++++++++++++++++++-------
|
||||
doc/mako.5.scd | 6 ++++++
|
||||
include/config.h | 4 +++-
|
||||
include/notification.h | 2 ++
|
||||
notification.c | 1 +
|
||||
6 files changed, 61 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/config.c b/config.c
|
||||
index 87db932..79dc58a 100644
|
||||
--- a/config.c
|
||||
+++ b/config.c
|
||||
@@ -105,6 +105,7 @@ void init_default_style(struct mako_style *style) {
|
||||
style->actions = true;
|
||||
style->default_timeout = 0;
|
||||
style->ignore_timeout = false;
|
||||
+ style->freeze = false;
|
||||
|
||||
style->colors.background = 0x285577FF;
|
||||
style->colors.text = 0xFFFFFFFF;
|
||||
@@ -305,6 +306,11 @@ bool apply_style(struct mako_style *target, const struct mako_style *style) {
|
||||
target->spec.ignore_timeout = true;
|
||||
}
|
||||
|
||||
+ if (style->spec.freeze) {
|
||||
+ target->freeze = style->freeze;
|
||||
+ target->spec.freeze = true;
|
||||
+ }
|
||||
+
|
||||
if (style->spec.colors.background) {
|
||||
target->colors.background = style->colors.background;
|
||||
target->spec.colors.background = true;
|
||||
@@ -637,6 +643,8 @@ static bool apply_style_option(struct mako_style *style, const char *name,
|
||||
} else if (strcmp(name, "ignore-timeout") == 0) {
|
||||
return spec->ignore_timeout =
|
||||
parse_boolean(value, &style->ignore_timeout);
|
||||
+ } else if (strcmp(name, "freeze") == 0) {
|
||||
+ return spec->freeze = parse_boolean(value, &style->freeze);
|
||||
} else if (strcmp(name, "group-by") == 0) {
|
||||
return spec->group_criteria_spec =
|
||||
parse_criteria_spec(value, &style->group_criteria_spec);
|
||||
diff --git a/criteria.c b/criteria.c
|
||||
index 3108a38..523a467 100644
|
||||
--- a/criteria.c
|
||||
+++ b/criteria.c
|
||||
@@ -418,21 +418,39 @@ struct mako_criteria *global_criteria(struct mako_config *config) {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
-static void timespec_add(struct timespec *t, int delta_ms) {
|
||||
- static const long ms = 1000000, s = 1000000000;
|
||||
+static void timespec_from_ms(struct timespec *t, long time_ms) {
|
||||
+ static const long ms = 1000000;
|
||||
|
||||
- int delta_ms_low = delta_ms % 1000;
|
||||
- int delta_s_high = delta_ms / 1000;
|
||||
+ t->tv_sec = time_ms / 1000;
|
||||
+ t->tv_nsec = (time_ms % 1000) * ms;
|
||||
+}
|
||||
+
|
||||
+static void timespec_add(struct timespec *t, struct timespec *u) {
|
||||
+ static const long s = 1000000000;
|
||||
|
||||
- t->tv_sec += delta_s_high;
|
||||
+ t->tv_sec += u->tv_sec;
|
||||
+ t->tv_nsec += u->tv_nsec;
|
||||
|
||||
- t->tv_nsec += (long)delta_ms_low * ms;
|
||||
if (t->tv_nsec >= s) {
|
||||
t->tv_nsec -= s;
|
||||
++t->tv_sec;
|
||||
}
|
||||
}
|
||||
|
||||
+static void timespec_sub(struct timespec *t, struct timespec *u) {
|
||||
+ static const long s = 1000000000;
|
||||
+
|
||||
+ t->tv_sec -= u->tv_sec;
|
||||
+ t->tv_nsec += s;
|
||||
+ t->tv_nsec -= u->tv_nsec;
|
||||
+
|
||||
+ if (t->tv_nsec >= s) {
|
||||
+ t->tv_nsec -= s;
|
||||
+ } else {
|
||||
+ --t->tv_sec;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static void handle_notification_timer(void *data) {
|
||||
struct mako_notification *notif = data;
|
||||
struct mako_surface *surface = notif->surface;
|
||||
@@ -474,10 +492,25 @@ ssize_t apply_each_criteria(struct mako_state *state, struct mako_notification *
|
||||
if (expire_timeout < 0 || notif->style.ignore_timeout) {
|
||||
expire_timeout = notif->style.default_timeout;
|
||||
}
|
||||
+ if (notif->frozen != notif->style.freeze) {
|
||||
+ struct timespec now;
|
||||
+ clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
+ if (notif->style.freeze) {
|
||||
+ notif->froze_at = now;
|
||||
+ } else {
|
||||
+ timespec_sub(&now, ¬if->froze_at);
|
||||
+ timespec_add(¬if->at, &now);
|
||||
+ }
|
||||
+ notif->frozen = notif->style.freeze;
|
||||
+ }
|
||||
+ if (notif->frozen) {
|
||||
+ expire_timeout = 0;
|
||||
+ }
|
||||
|
||||
if (expire_timeout > 0) {
|
||||
- struct timespec at = notif->at;
|
||||
- timespec_add(&at, expire_timeout);
|
||||
+ struct timespec at = notif->at, delta;
|
||||
+ timespec_from_ms(&delta, expire_timeout);
|
||||
+ timespec_add(&at, &delta);
|
||||
if (notif->timer) {
|
||||
notif->timer->at = at;
|
||||
} else {
|
||||
diff --git a/doc/mako.5.scd b/doc/mako.5.scd
|
||||
index fff19ed..c0be528 100644
|
||||
--- a/doc/mako.5.scd
|
||||
+++ b/doc/mako.5.scd
|
||||
@@ -421,6 +421,12 @@ associated command-line option.
|
||||
|
||||
Default: 0
|
||||
|
||||
+*freeze*=0|1
|
||||
+ Whether to freeze this notification's active timeout, stopping it from
|
||||
+ progressing. This can be used for pausing notifications while you're away.
|
||||
+
|
||||
+ Default: 0
|
||||
+
|
||||
# COLORS
|
||||
|
||||
Colors can be specified as _#RRGGBB_ or _#RRGGBBAA_.
|
||||
diff --git a/include/config.h b/include/config.h
|
||||
index 5ff541c..53116e1 100644
|
||||
--- a/include/config.h
|
||||
+++ b/include/config.h
|
||||
@@ -42,7 +42,8 @@ struct mako_style_spec {
|
||||
bool width, height, outer_margin, margin, padding, border_size, border_radius, font,
|
||||
markup, format, text_alignment, actions, default_timeout, ignore_timeout,
|
||||
icons, max_icon_size, icon_path, group_criteria_spec, invisible, history,
|
||||
- icon_location, max_visible, layer, output, anchor, long_press_duration;
|
||||
+ icon_location, max_visible, layer, output, anchor, long_press_duration,
|
||||
+ freeze;
|
||||
struct {
|
||||
bool background, text, border, progress;
|
||||
} colors;
|
||||
@@ -76,6 +77,7 @@ struct mako_style {
|
||||
bool actions;
|
||||
int default_timeout; // in ms
|
||||
bool ignore_timeout;
|
||||
+ bool freeze;
|
||||
|
||||
struct {
|
||||
uint32_t background;
|
||||
diff --git a/include/notification.h b/include/notification.h
|
||||
index 2775d88..a631b49 100644
|
||||
--- a/include/notification.h
|
||||
+++ b/include/notification.h
|
||||
@@ -57,6 +57,8 @@ struct mako_notification {
|
||||
struct mako_hotspot hotspot;
|
||||
struct mako_timer *timer;
|
||||
struct timespec at;
|
||||
+ struct timespec froze_at;
|
||||
+ bool frozen;
|
||||
};
|
||||
|
||||
struct mako_action {
|
||||
diff --git a/notification.c b/notification.c
|
||||
index b78bd09..ce0bafd 100644
|
||||
--- a/notification.c
|
||||
+++ b/notification.c
|
||||
@@ -70,6 +70,7 @@ void reset_notification(struct mako_notification *notif) {
|
||||
notif->icon = NULL;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, ¬if->at);
|
||||
+ notif->frozen = false;
|
||||
}
|
||||
|
||||
struct mako_notification *create_notification(struct mako_state *state) {
|
||||
--
|
||||
2.45.2
|
||||
|
64
pkgs/mako/0005-cherry-pick-fixup.patch
Normal file
64
pkgs/mako/0005-cherry-pick-fixup.patch
Normal file
|
@ -0,0 +1,64 @@
|
|||
From cf4c99d9fa92e397b3860a71d293957741abc7c2 Mon Sep 17 00:00:00 2001
|
||||
From: chayleaf <chayleaf-git@pavluk.org>
|
||||
Date: Sat, 24 Aug 2024 14:22:23 +0700
|
||||
Subject: [PATCH 5/5] cherry-pick fixup
|
||||
|
||||
---
|
||||
criteria.c | 4 ++--
|
||||
include/criteria.h | 3 +++
|
||||
notification.c | 6 +++++-
|
||||
3 files changed, 10 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/criteria.c b/criteria.c
|
||||
index 523a467..2514da9 100644
|
||||
--- a/criteria.c
|
||||
+++ b/criteria.c
|
||||
@@ -418,14 +418,14 @@ struct mako_criteria *global_criteria(struct mako_config *config) {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
-static void timespec_from_ms(struct timespec *t, long time_ms) {
|
||||
+void timespec_from_ms(struct timespec *t, long time_ms) {
|
||||
static const long ms = 1000000;
|
||||
|
||||
t->tv_sec = time_ms / 1000;
|
||||
t->tv_nsec = (time_ms % 1000) * ms;
|
||||
}
|
||||
|
||||
-static void timespec_add(struct timespec *t, struct timespec *u) {
|
||||
+void timespec_add(struct timespec *t, struct timespec *u) {
|
||||
static const long s = 1000000000;
|
||||
|
||||
t->tv_sec += u->tv_sec;
|
||||
diff --git a/include/criteria.h b/include/criteria.h
|
||||
index 58c36ef..48f256d 100644
|
||||
--- a/include/criteria.h
|
||||
+++ b/include/criteria.h
|
||||
@@ -60,4 +60,7 @@ struct mako_criteria *create_criteria_from_notification(
|
||||
|
||||
bool validate_criteria(struct mako_criteria *criteria);
|
||||
|
||||
+void timespec_add(struct timespec *t, struct timespec *u);
|
||||
+void timespec_from_ms(struct timespec *t, long time_ms);
|
||||
+
|
||||
#endif
|
||||
diff --git a/notification.c b/notification.c
|
||||
index ce0bafd..730176f 100644
|
||||
--- a/notification.c
|
||||
+++ b/notification.c
|
||||
@@ -475,7 +475,11 @@ void notification_handle_touch_start(struct mako_notification *notif,
|
||||
return;
|
||||
}
|
||||
notif->long_press_ctx = *ctx;
|
||||
- notif->long_press_timer = add_event_loop_timer(¬if->state->event_loop, 500,
|
||||
+ struct timespec at, delta;
|
||||
+ clock_gettime(CLOCK_MONOTONIC, &at);
|
||||
+ timespec_from_ms(&delta, 500);
|
||||
+ timespec_add(&at, &delta);
|
||||
+ notif->long_press_timer = add_event_loop_timer(¬if->state->event_loop, &at,
|
||||
handle_notification_touch_timer, notif);
|
||||
}
|
||||
|
||||
--
|
||||
2.45.2
|
||||
|
181
pkgs/rofi-wayland/0001-wip-touch-support.patch
Normal file
181
pkgs/rofi-wayland/0001-wip-touch-support.patch
Normal file
|
@ -0,0 +1,181 @@
|
|||
From 637fe90e0c69d77d2ad24576d924b041525fd941 Mon Sep 17 00:00:00 2001
|
||||
From: chayleaf <chayleaf-git@pavluk.org>
|
||||
Date: Sat, 24 Aug 2024 12:10:16 +0700
|
||||
Subject: [PATCH 1/3] wip touch support
|
||||
|
||||
---
|
||||
include/wayland-internal.h | 7 +++
|
||||
source/wayland/display.c | 115 +++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 122 insertions(+)
|
||||
|
||||
diff --git a/include/wayland-internal.h b/include/wayland-internal.h
|
||||
index e6d248ce..77aaaf9d 100644
|
||||
--- a/include/wayland-internal.h
|
||||
+++ b/include/wayland-internal.h
|
||||
@@ -84,6 +84,8 @@ typedef struct {
|
||||
uint32_t layer_height;
|
||||
} wayland_stuff;
|
||||
|
||||
+#define MAX_TOUCHPOINTS 10
|
||||
+
|
||||
struct _wayland_seat {
|
||||
wayland_stuff *context;
|
||||
uint32_t global_name;
|
||||
@@ -99,6 +101,11 @@ struct _wayland_seat {
|
||||
uint32_t pointer_serial;
|
||||
struct wl_keyboard *keyboard;
|
||||
struct wl_pointer *pointer;
|
||||
+ struct wl_touch *touch;
|
||||
+ struct {
|
||||
+ int32_t x, start_y, move_y;
|
||||
+ uint32_t start_time, move_time;
|
||||
+ } touches[MAX_TOUCHPOINTS];
|
||||
|
||||
#ifdef HAVE_WAYLAND_CURSOR_SHAPE
|
||||
struct wp_cursor_shape_device_v1 *cursor_shape_device;
|
||||
diff --git a/source/wayland/display.c b/source/wayland/display.c
|
||||
index 6cdc7d2f..381c402d 100644
|
||||
--- a/source/wayland/display.c
|
||||
+++ b/source/wayland/display.c
|
||||
@@ -526,6 +526,101 @@ static const struct wl_keyboard_listener wayland_keyboard_listener = {
|
||||
.repeat_info = wayland_keyboard_repeat_info,
|
||||
};
|
||||
|
||||
+static void wayland_touch_down(void *data, struct wl_touch *wl_touch,
|
||||
+ uint32_t serial, uint32_t time, struct wl_surface *wl_surface,
|
||||
+ int32_t id, wl_fixed_t surface_x, wl_fixed_t surface_y) {
|
||||
+ wayland_seat *self = data;
|
||||
+ if (id >= MAX_TOUCHPOINTS) {
|
||||
+ return;
|
||||
+ }
|
||||
+ self->touches[id].x = wl_fixed_to_int(surface_x);
|
||||
+ self->touches[id].start_y = self->touches[id].move_y = wl_fixed_to_int(surface_y);
|
||||
+ self->touches[id].start_time = self->touches[id].move_time = time;
|
||||
+ RofiViewState *state = rofi_view_get_active();
|
||||
+
|
||||
+ if (state == NULL) {
|
||||
+ return;
|
||||
+ }
|
||||
+ rofi_view_handle_mouse_motion(state, self->touches[id].x, self->touches[id].start_y,
|
||||
+ FALSE);
|
||||
+}
|
||||
+
|
||||
+static void wayland_touch_up(void *data, struct wl_touch *wl_touch,
|
||||
+ uint32_t serial, uint32_t time, int32_t id) {
|
||||
+ wayland_seat *self = data;
|
||||
+ if (id >= MAX_TOUCHPOINTS) {
|
||||
+ return;
|
||||
+ }
|
||||
+ gboolean is_move =
|
||||
+ time - self->touches[id].start_time > 500
|
||||
+ || self->touches[id].start_time != self->touches[id].move_time;
|
||||
+ if (is_move) {
|
||||
+ return;
|
||||
+ }
|
||||
+ RofiViewState *state = rofi_view_get_active();
|
||||
+
|
||||
+ if (state == NULL) {
|
||||
+ return;
|
||||
+ }
|
||||
+ //rofi_view_handle_mouse_motion(state, self->touches[id].x, self->touches[id].start_y,
|
||||
+ // FALSE);
|
||||
+ nk_bindings_seat_handle_key(wayland->bindings_seat, NULL,
|
||||
+ KEY_ENTER + 8,
|
||||
+ NK_BINDINGS_KEY_STATE_PRESS);
|
||||
+ rofi_view_maybe_update(state);
|
||||
+}
|
||||
+
|
||||
+static int32_t y_offset_to_line_offset(int32_t y_offset) {
|
||||
+ static const int32_t line_height = 20;
|
||||
+ return -(y_offset / line_height);
|
||||
+}
|
||||
+
|
||||
+static void wayland_touch_motion(void *data, struct wl_touch *wl_touch,
|
||||
+ uint32_t time, int32_t id, wl_fixed_t surface_x, wl_fixed_t surface_y) {
|
||||
+ wayland_seat *self = data;
|
||||
+ if (id >= MAX_TOUCHPOINTS) {
|
||||
+ return;
|
||||
+ }
|
||||
+ RofiViewState *state = rofi_view_get_active();
|
||||
+
|
||||
+ if (state == NULL) {
|
||||
+ return;
|
||||
+ }
|
||||
+ int32_t x = wl_fixed_to_int(surface_x);
|
||||
+ int32_t y = wl_fixed_to_int(surface_y);
|
||||
+
|
||||
+ int last_pos = y_offset_to_line_offset(self->touches[id].move_y - self->touches[id].start_y);
|
||||
+ int cur_pos = y_offset_to_line_offset(y - self->touches[id].start_y);
|
||||
+
|
||||
+ if (cur_pos != last_pos) {
|
||||
+ rofi_view_handle_mouse_motion(state, x, y, FALSE);
|
||||
+ nk_bindings_seat_handle_scroll(wayland->bindings_seat, NULL,
|
||||
+ NK_BINDINGS_SCROLL_AXIS_VERTICAL,
|
||||
+ cur_pos - last_pos);
|
||||
+ self->touches[id].x = x;
|
||||
+ self->touches[id].move_y = y;
|
||||
+ self->touches[id].move_time = time;
|
||||
+ rofi_view_maybe_update(state);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void wayland_touch_frame(void *data, struct wl_touch *wl_touch) { }
|
||||
+static void wayland_touch_cancel(void *data, struct wl_touch *wl_touch) { }
|
||||
+static void wayland_touch_shape(void *data, struct wl_touch *wl_touch,
|
||||
+ int32_t id, wl_fixed_t major, wl_fixed_t minor) { }
|
||||
+static void wayland_touch_orientation(void *data, struct wl_touch *wl_touch,
|
||||
+ int32_t id, wl_fixed_t orientation) { }
|
||||
+
|
||||
+static const struct wl_touch_listener wayland_touch_listener = {
|
||||
+ .down = wayland_touch_down,
|
||||
+ .up = wayland_touch_up,
|
||||
+ .motion = wayland_touch_motion,
|
||||
+ .frame = wayland_touch_frame,
|
||||
+ .cancel = wayland_touch_cancel,
|
||||
+ .shape = wayland_touch_shape,
|
||||
+ .orientation = wayland_touch_orientation,
|
||||
+};
|
||||
+
|
||||
static gboolean wayland_cursor_reload_theme(guint scale);
|
||||
|
||||
static void wayland_cursor_set_image(int i) {
|
||||
@@ -1081,9 +1176,20 @@ static void wayland_pointer_release(wayland_seat *self) {
|
||||
self->pointer = NULL;
|
||||
}
|
||||
|
||||
+static void wayland_touch_release(wayland_seat *self) {
|
||||
+ if (self->touch == NULL) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ wl_touch_release(self->touch);
|
||||
+
|
||||
+ self->touch = NULL;
|
||||
+}
|
||||
+
|
||||
static void wayland_seat_release(wayland_seat *self) {
|
||||
wayland_keyboard_release(self);
|
||||
wayland_pointer_release(self);
|
||||
+ wayland_touch_release(self);
|
||||
|
||||
wl_seat_release(self->seat);
|
||||
|
||||
@@ -1113,6 +1219,15 @@ static void wayland_seat_capabilities(void *data, struct wl_seat *seat,
|
||||
wayland_pointer_release(self);
|
||||
}
|
||||
|
||||
+ if ((capabilities & WL_SEAT_CAPABILITY_TOUCH) &&
|
||||
+ (self->touch == NULL)) {
|
||||
+ self->touch = wl_seat_get_touch(self->seat);
|
||||
+ wl_touch_add_listener(self->touch, &wayland_touch_listener, self);
|
||||
+ } else if ((!(capabilities & WL_SEAT_CAPABILITY_TOUCH)) &&
|
||||
+ (self->touch != NULL)) {
|
||||
+ wayland_touch_release(self);
|
||||
+ }
|
||||
+
|
||||
if (wayland->data_device_manager != NULL) {
|
||||
self->data_device = wl_data_device_manager_get_data_device(
|
||||
wayland->data_device_manager, seat);
|
||||
--
|
||||
2.45.2
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
From 3d02857ec8ab68ae243e651874203e88e6788ae7 Mon Sep 17 00:00:00 2001
|
||||
From: chayleaf <chayleaf-git@pavluk.org>
|
||||
Date: Sat, 24 Aug 2024 13:22:34 +0700
|
||||
Subject: [PATCH 2/3] still scroll after the tap moves outside the rofi window
|
||||
|
||||
---
|
||||
source/wayland/display.c | 1 -
|
||||
1 file changed, 1 deletion(-)
|
||||
|
||||
diff --git a/source/wayland/display.c b/source/wayland/display.c
|
||||
index 381c402d..5154589a 100644
|
||||
--- a/source/wayland/display.c
|
||||
+++ b/source/wayland/display.c
|
||||
@@ -593,7 +593,6 @@ static void wayland_touch_motion(void *data, struct wl_touch *wl_touch,
|
||||
int cur_pos = y_offset_to_line_offset(y - self->touches[id].start_y);
|
||||
|
||||
if (cur_pos != last_pos) {
|
||||
- rofi_view_handle_mouse_motion(state, x, y, FALSE);
|
||||
nk_bindings_seat_handle_scroll(wayland->bindings_seat, NULL,
|
||||
NK_BINDINGS_SCROLL_AXIS_VERTICAL,
|
||||
cur_pos - last_pos);
|
||||
--
|
||||
2.45.2
|
||||
|
45
pkgs/rofi-wayland/0003-exit-on-long-tap.patch
Normal file
45
pkgs/rofi-wayland/0003-exit-on-long-tap.patch
Normal file
|
@ -0,0 +1,45 @@
|
|||
From 8b417bc6304c30bafb56113b868ecac2ffc0ed08 Mon Sep 17 00:00:00 2001
|
||||
From: chayleaf <chayleaf-git@pavluk.org>
|
||||
Date: Sat, 24 Aug 2024 13:29:32 +0700
|
||||
Subject: [PATCH 3/3] exit on long tap
|
||||
|
||||
---
|
||||
source/wayland/display.c | 14 +++++++-------
|
||||
1 file changed, 7 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/source/wayland/display.c b/source/wayland/display.c
|
||||
index 5154589a..cfd883b3 100644
|
||||
--- a/source/wayland/display.c
|
||||
+++ b/source/wayland/display.c
|
||||
@@ -551,10 +551,8 @@ static void wayland_touch_up(void *data, struct wl_touch *wl_touch,
|
||||
if (id >= MAX_TOUCHPOINTS) {
|
||||
return;
|
||||
}
|
||||
- gboolean is_move =
|
||||
- time - self->touches[id].start_time > 500
|
||||
- || self->touches[id].start_time != self->touches[id].move_time;
|
||||
- if (is_move) {
|
||||
+ gboolean has_moved = self->touches[id].start_time != self->touches[id].move_time;
|
||||
+ if (has_moved) {
|
||||
return;
|
||||
}
|
||||
RofiViewState *state = rofi_view_get_active();
|
||||
@@ -562,10 +560,12 @@ static void wayland_touch_up(void *data, struct wl_touch *wl_touch,
|
||||
if (state == NULL) {
|
||||
return;
|
||||
}
|
||||
- //rofi_view_handle_mouse_motion(state, self->touches[id].x, self->touches[id].start_y,
|
||||
- // FALSE);
|
||||
+ int key = KEY_ENTER;
|
||||
+ if (time - self->touches[id].start_time > 200) {
|
||||
+ key = KEY_ESC;
|
||||
+ }
|
||||
nk_bindings_seat_handle_key(wayland->bindings_seat, NULL,
|
||||
- KEY_ENTER + 8,
|
||||
+ key + 8,
|
||||
NK_BINDINGS_KEY_STATE_PRESS);
|
||||
rofi_view_maybe_update(state);
|
||||
}
|
||||
--
|
||||
2.45.2
|
||||
|
|
@ -55,9 +55,9 @@
|
|||
hardware = {
|
||||
opentabletdriver.enable = true;
|
||||
steam-hardware.enable = true;
|
||||
opengl.driSupport32Bit = true;
|
||||
graphics.enable32Bit = true;
|
||||
# needed for sway WLR_RENDERER=vulkan
|
||||
opengl.extraPackages = with pkgs; [ vulkan-validation-layers ];
|
||||
graphics.extraPackages = with pkgs; [ vulkan-validation-layers ];
|
||||
};
|
||||
|
||||
# see modules/vfio.nix
|
||||
|
@ -143,7 +143,7 @@
|
|||
|
||||
programs.ccache.enable = true;
|
||||
services.sshd.enable = true;
|
||||
boot.binfmt.emulatedSystems = [ "aarch64-linux" ];
|
||||
# boot.binfmt.emulatedSystems = [ "aarch64-linux" ];
|
||||
users.users.hydra-builder = {
|
||||
uid = 1001;
|
||||
isNormalUser = true;
|
||||
|
|
|
@ -151,7 +151,7 @@ in {
|
|||
'')
|
||||
cfg.lookingGlass.ivshmem));
|
||||
hardware = {
|
||||
opengl.enable = true;
|
||||
graphics.enable = true;
|
||||
} // lib.optionalAttrs (cfg.enable && !cfg.nvidiaGpu && options?hardware.amdgpu.loadInInitrd) {
|
||||
# disable early KMS so GPU can be properly unbound
|
||||
# can't use mkif because the option may not even exist
|
||||
|
|
Loading…
Reference in a new issue