1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
|
diff --git a/README.md b/README.md
index 170dbe4..b2d567d 100644
--- a/README.md
+++ b/README.md
@@ -13,8 +13,9 @@ in Wayfire 0.11.0-r19 or newer. Unpatched upstream Wayfire is not supported.
| `find-pointer` | Press Ctrl twice to spotlight the pointer | Wayfire (GLES2 renderer) |
| `clipboard-keys` | Super+C and Super+V copy and paste in every app | Wayfire |
| `hold-super` | Hold Super to see the shortcut sheet | Wayfire, `pyr keys` |
+| `raise-on-release` | Clicking a background window raises it on release, so you can drag out of it | Wayfire |
-All seven build by default. Building a module does not enable it in Wayfire.
+All eight build by default. Building a module does not enable it in Wayfire.
Window-actions owns the desktop's spatial transactions, previews and physical
capture identity; it has no storage and no options. It replaces the former
`window-state` plugin: in `wayfire.ini`, replace `window-state` with
@@ -42,6 +43,7 @@ The installed libraries:
- `libfind-pointer.so`.
- `libclipboard-keys.so`.
- `libhold-super.so`.
+- `libraise-on-release.so`.
The package replaces the standalone implementations. Compatibility ebuilds for
`wayfire-window-state` and `wayfire-panel-desktop` depend
diff --git a/meson.build b/meson.build
index e98a7dd..f3a7239 100644
--- a/meson.build
+++ b/meson.build
@@ -2,10 +2,10 @@ project('wayfire-plugins-custom', 'cpp', version: '0.1.0',
default_options: ['cpp_std=c++17', 'warning_level=3'])
wf = dependency('wayfire', version: '>=0.11.0')
-if not get_option('window-actions') and not get_option('panel-desktop') and not get_option('workspace-backgrounds') and not get_option('screensaver') and not get_option('find-pointer') and not get_option('clipboard-keys') and not get_option('hold-super')
+if not get_option('window-actions') and not get_option('panel-desktop') and not get_option('workspace-backgrounds') and not get_option('screensaver') and not get_option('find-pointer') and not get_option('clipboard-keys') and not get_option('hold-super') and not get_option('raise-on-release')
error('Enable at least one plugin')
endif
-foreach plugin : ['window-actions', 'panel-desktop', 'workspace-backgrounds', 'screensaver', 'find-pointer', 'clipboard-keys', 'hold-super']
+foreach plugin : ['window-actions', 'panel-desktop', 'workspace-backgrounds', 'screensaver', 'find-pointer', 'clipboard-keys', 'hold-super', 'raise-on-release']
if get_option(plugin)
subdir('plugins' / plugin)
endif
@@ -18,5 +18,6 @@ summary({
'find-pointer': get_option('find-pointer'),
'clipboard-keys': get_option('clipboard-keys'),
'hold-super': get_option('hold-super'),
+ 'raise-on-release': get_option('raise-on-release'),
'tests': get_option('tests'),
}, section: 'Custom Wayfire plugins')
diff --git a/meson_options.txt b/meson_options.txt
index aa4b6d2..1b03ef1 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -7,3 +7,4 @@ option('screensaver', type: 'boolean', value: true, description: 'Per-monitor id
option('find-pointer', type: 'boolean', value: true, description: 'Press Ctrl twice to spotlight the pointer')
option('clipboard-keys', type: 'boolean', value: true, description: 'Super+C and Super+V copy and paste in every app')
option('hold-super', type: 'boolean', value: true, description: 'Hold Super to see the shortcut sheet')
+option('raise-on-release', type: 'boolean', value: true, description: 'Clicking a background window raises it on release, so a drag out of it stays behind')
diff --git a/plugins/raise-on-release/LICENSE b/plugins/raise-on-release/LICENSE
new file mode 100644
index 0000000..d610e4f
--- /dev/null
+++ b/plugins/raise-on-release/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2026 raise-on-release contributors
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/plugins/raise-on-release/README.md b/plugins/raise-on-release/README.md
new file mode 100644
index 0000000..11093f0
--- /dev/null
+++ b/plugins/raise-on-release/README.md
@@ -0,0 +1,62 @@
+# raise-on-release
+
+Clicking a window that is behind others gives it keyboard focus at once, but
+brings it to the front only when you let go of the button. If the press turns
+into a drag, the window stays where it is, so you can drag a file or text out
+of a background window and drop it on the window in front. macOS works this
+way, and KDE does too since Scott Jenson pointed it out.
+
+## Setup
+
+Add `raise-on-release` to `[core] plugins` and leave the left button out of
+core's own click-to-focus:
+
+```ini
+[core]
+focus_buttons = BTN_MIDDLE | BTN_RIGHT
+```
+
+The plugin takes the left button only when `core/focus_buttons` leaves it out.
+With Wayfire's default (`BTN_LEFT | BTN_MIDDLE | BTN_RIGHT`), core focuses and
+raises on press as before, and the plugin does nothing, so a click is never
+handled twice. Do not remove `BTN_LEFT` from `focus_buttons` without loading
+the plugin: left clicks would then stop focusing windows.
+
+## Behaviour
+
+Left-button presses on the app's own surface (its content, or the titlebar it
+draws itself) of an ordinary window:
+
+- **Press:** the window gets keyboard focus at once, and the press reaches the
+ app as usual. It stays behind any window in front of it.
+- **Release:** the window comes to the front, so a plain click looks as it
+ always did; only the raise happens a moment later.
+- **Drag:** the window is not raised if the pointer moves more than 8 pixels
+ with the button down, or if the app starts a drag-and-drop. After a drop,
+ focus is wherever the drop leaves it; the plugin changes nothing.
+- **Moving or resizing:** when the app asks to move or resize the window (a
+ drag on its own titlebar or edge), it is raised as the move starts.
+- **Focus moves elsewhere** while the button is down (for example the click
+ opened another window): the window is not raised.
+
+Everything else behaves exactly as core's click-to-focus:
+
+- Server-side frames (pixdecor titlebars and borders), panels, docks and
+ other layer-shell surfaces, popups, and windows that take no keyboard
+ focus are focused and raised on press. A titlebar drag raises as it starts.
+- Clicks with a modifier held (Super+drag moves) are left alone unless
+ `core/focus_button_with_modifiers` is on; then they raise on press.
+- With `core/focus_buttons_passthrough` off, a click that changes focus is
+ kept from the app (so no drag can start) and raises on press.
+- The middle and right buttons, touch and tablet follow `core/focus_buttons`
+ as before. Keyboard focus changes, Alt+Tab and new windows are untouched.
+
+While no button is held the plugin only watches button presses. It has no
+options of its own, so it can be enabled in a running session.
+
+## Tests
+
+`meson test` runs `raise-on-release-press`. It covers which presses wait for
+the release (frames, panels, modifiers, passthrough, core still owning the
+button) and when a held press stops being a click (threshold, drag-and-drop,
+window moves).
diff --git a/plugins/raise-on-release/meson.build b/plugins/raise-on-release/meson.build
new file mode 100644
index 0000000..7e80efe
--- /dev/null
+++ b/plugins/raise-on-release/meson.build
@@ -0,0 +1,6 @@
+shared_module('raise-on-release', 'src/plugin.cpp', dependencies: wf,
+ install: true, install_dir: wf.get_variable(pkgconfig: 'plugindir'))
+install_data('raise-on-release.xml', install_dir: wf.get_variable(pkgconfig: 'metadatadir'))
+if get_option('tests')
+ test('raise-on-release-press', executable('raise-on-release-test', 'tests/press-test.cpp'), timeout: 30)
+endif
diff --git a/plugins/raise-on-release/raise-on-release.xml b/plugins/raise-on-release/raise-on-release.xml
new file mode 100644
index 0000000..46c85e9
--- /dev/null
+++ b/plugins/raise-on-release/raise-on-release.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<wayfire>
+ <plugin name="raise-on-release">
+ <_short>Raise on Release</_short>
+ <_long>Clicking a window behind others gives it keyboard focus at once and raises it when the button comes up. If the press becomes a drag, the window stays behind, so you can drag something from it onto the window in front. Takes the left button when Mouse buttons to focus views (core) leaves it out.</_long>
+ <category>Window Management</category>
+ </plugin>
+</wayfire>
diff --git a/plugins/raise-on-release/src/plugin.cpp b/plugins/raise-on-release/src/plugin.cpp
new file mode 100644
index 0000000..cf05209
--- /dev/null
+++ b/plugins/raise-on-release/src/plugin.cpp
@@ -0,0 +1,214 @@
+// raise-on-release: clicking a window behind others gives it keyboard focus
+// at once but raises it only when the button comes up, and not at all if the
+// press became a drag, so something can be dragged out of a background window
+// onto the one in front, as on macOS. It takes the left button only when
+// core/focus_buttons leaves it out; idle, it only watches button presses.
+#include "press.hpp"
+#include <wayfire/core.hpp>
+#include <wayfire/option-wrapper.hpp>
+#include <wayfire/output.hpp>
+#include <wayfire/plugin.hpp>
+#include <wayfire/seat.hpp>
+#include <wayfire/signal-definitions.hpp>
+#include <wayfire/toplevel-view.hpp>
+#include <wayfire/util.hpp>
+#include <wayfire/view-helpers.hpp>
+#include <wayfire/window-manager.hpp>
+#include <wayfire/util/log.hpp>
+#include <wayfire/unstable/wlr-surface-node.hpp>
+#include <wayfire/nonstd/wlroots-full.hpp>
+#include <linux/input-event-codes.h>
+#include <memory>
+
+namespace
+{
+using raise_on_release::action_t;
+using button_signal = wf::input_event_signal<wlr_pointer_button_event>;
+
+// One app window: a view and its dialogs share their topmost parent.
+bool same_window(wayfire_view a, wayfire_view b)
+{
+ auto ta = wf::toplevel_cast(a), tb = wf::toplevel_cast(b);
+ return ta && tb && (wf::find_topmost_parent(ta) == wf::find_topmost_parent(tb));
+}
+
+class raise_on_release_plugin_t : public wf::plugin_interface_t
+{
+ wf::option_wrapper_t<wf::activatorbinding_t> focus_buttons{"core/focus_buttons"};
+ wf::option_wrapper_t<bool> focus_modifiers{"core/focus_button_with_modifiers"};
+ wf::option_wrapper_t<bool> passthrough{"core/focus_buttons_passthrough"};
+
+ raise_on_release::tracker_t tracker;
+ std::weak_ptr<wf::view_interface_t> pressed;
+ wf::wl_listener_wrapper on_start_drag;
+
+ bool core_focuses(uint32_t button)
+ {
+ wf::option_sptr_t<wf::activatorbinding_t> buttons = focus_buttons;
+ return buttons->get_value().has_match(wf::buttonbinding_t(0, button));
+ }
+
+ // Exactly what core's click-to-focus does.
+ void focus_now(wayfire_view view, button_signal *ev)
+ {
+ auto& seat = wf::get_core().seat;
+ if (!view->get_keyboard_focus_surface())
+ {
+ wf::view_bring_to_front(view);
+ return;
+ }
+
+ auto old_focus = seat->get_active_view();
+ wf::get_core().default_wm->focus_raise_view(view);
+ if (!passthrough && (seat->get_active_view() != old_focus))
+ {
+ ev->mode = wf::input_event_processing_mode_t::NO_CLIENT;
+ }
+ }
+
+ // Focus without raising, and watch the press until the button comes up.
+ void focus_and_wait(wayfire_view view)
+ {
+ auto& core = wf::get_core();
+ core.seat->focus_output(view->get_output());
+ core.seat->focus_view(view);
+ auto at = core.get_cursor_position();
+ tracker.press(at.x, at.y);
+ pressed = view->weak_from_this();
+ core.connect(&on_motion);
+ core.connect(&on_motion_absolute);
+ view->get_output()->connect(&on_move_request);
+ view->get_output()->connect(&on_resize_request);
+ on_start_drag.connect(&core.get_current_seat()->events.start_drag);
+ }
+
+ wayfire_view pressed_view()
+ {
+ auto view = pressed.lock();
+ return (view && view->is_mapped()) ? wayfire_view(view.get()) : nullptr;
+ }
+
+ void stop()
+ {
+ tracker.state = raise_on_release::tracker_t::IDLE;
+ pressed.reset();
+ on_motion.disconnect();
+ on_motion_absolute.disconnect();
+ on_move_request.disconnect();
+ on_resize_request.disconnect();
+ on_start_drag.disconnect();
+ }
+
+ // Raise, unless focus has meanwhile gone to another window.
+ void raise(wayfire_view view)
+ {
+ if (view && same_window(view, wf::get_core().seat->get_active_view()))
+ {
+ wf::view_bring_to_front(view);
+ }
+ }
+
+ wf::signal::connection_t<button_signal> on_button = [this] (button_signal *ev)
+ {
+ if (ev->event->button != BTN_LEFT)
+ {
+ return;
+ }
+
+ if (ev->event->state == WL_POINTER_BUTTON_STATE_RELEASED)
+ {
+ bool click = tracker.release();
+ auto view = pressed_view();
+ stop();
+ if (click)
+ {
+ raise(view);
+ }
+
+ return;
+ }
+
+ stop(); // a second press without a release (two mice) starts over
+ if (ev->mode == wf::input_event_processing_mode_t::IGNORE)
+ {
+ return;
+ }
+
+ auto& core = wf::get_core();
+ auto view = core.get_cursor_focus_view();
+ auto output = core.seat->get_active_output();
+ raise_on_release::press_t press;
+ press.core_focuses = core_focuses(ev->event->button);
+ press.modifiers = core.seat->get_keyboard_modifiers();
+ press.focus_with_modifiers = focus_modifiers;
+ press.focusable = view && view->is_mapped() && view->get_output() && output &&
+ output->can_activate_plugin(wf::CAPABILITY_MANAGE_DESKTOP);
+ press.app_window = wf::toplevel_cast(view) && (view->role == wf::VIEW_ROLE_TOPLEVEL);
+ // The app's own surface, not a server-side frame (pixdecor).
+ auto node = core.get_cursor_focus();
+ press.on_app_surface = dynamic_cast<wf::scene::wlr_surface_node_t*>(node.get()) != nullptr;
+ press.keyboard_focus = view && view->get_keyboard_focus_surface();
+ press.passthrough = passthrough;
+ press.active = view && (core.seat->get_active_view() == view);
+ switch (raise_on_release::classify(press))
+ {
+ case action_t::NONE:
+ return;
+
+ case action_t::CORE:
+ focus_now(view, ev);
+ return;
+
+ case action_t::DEFER:
+ focus_and_wait(view);
+ return;
+ }
+ };
+
+ void moved()
+ {
+ auto at = wf::get_core().get_cursor_position();
+ tracker.motion(at.x, at.y);
+ }
+
+ wf::signal::connection_t<wf::post_input_event_signal<wlr_pointer_motion_event>> on_motion =
+ [this] (auto) { moved(); };
+ wf::signal::connection_t<wf::post_input_event_signal<wlr_pointer_motion_absolute_event>>
+ on_motion_absolute = [this] (auto) { moved(); };
+
+ // A client-side titlebar or edge drag: raise as the move or resize starts.
+ void grabbed(wayfire_view target)
+ {
+ auto view = pressed_view();
+ if (view && same_window(view, target) && tracker.window_grabbed())
+ {
+ raise(view);
+ }
+ }
+
+ wf::signal::connection_t<wf::view_move_request_signal> on_move_request =
+ [this] (wf::view_move_request_signal *ev) { grabbed(ev->view); };
+ wf::signal::connection_t<wf::view_resize_request_signal> on_resize_request =
+ [this] (wf::view_resize_request_signal *ev) { grabbed(ev->view); };
+
+ public:
+ void init() override
+ {
+ on_start_drag.set_callback([this] (void*) { tracker.drag_started(); });
+ wf::get_core().connect(&on_button);
+ if (core_focuses(BTN_LEFT))
+ {
+ LOGI("raise-on-release: core/focus_buttons has BTN_LEFT, so core raises on press; "
+ "leave it out (e.g. BTN_MIDDLE | BTN_RIGHT) to raise on release");
+ }
+ }
+
+ void fini() override
+ {
+ stop();
+ on_button.disconnect();
+ }
+};
+}
+
+DECLARE_WAYFIRE_PLUGIN(raise_on_release_plugin_t);
diff --git a/plugins/raise-on-release/src/press.hpp b/plugins/raise-on-release/src/press.hpp
new file mode 100644
index 0000000..7d8cf90
--- /dev/null
+++ b/plugins/raise-on-release/src/press.hpp
@@ -0,0 +1,99 @@
+#pragma once
+// Pure raise-on-release logic, no Wayfire dependencies: what to do with a
+// left-button press, and whether the held press is still a click.
+#include <cmath>
+
+namespace raise_on_release
+{
+enum class action_t
+{
+ NONE, // leave the press alone: core focuses it, or nothing would
+ CORE, // focus and raise now, as core's click-to-focus does
+ DEFER, // focus now, raise on release unless the press becomes a drag
+};
+
+// What is known about a left press when it arrives.
+struct press_t
+{
+ bool core_focuses = false; // core/focus_buttons has this button
+ bool modifiers = false; // a keyboard modifier is held
+ bool focus_with_modifiers = false; // core/focus_button_with_modifiers
+ bool focusable = false; // a mapped view is under the pointer and no plugin holds the desktop
+ bool app_window = false; // that view is an ordinary toplevel (not a panel, popup or desktop)
+ bool on_app_surface = false; // the press lands on the app's own surface, not a server-side frame
+ bool keyboard_focus = false; // the view can take keyboard focus
+ bool passthrough = true; // core/focus_buttons_passthrough
+ bool active = false; // the view already has keyboard focus
+};
+
+inline action_t classify(const press_t& p)
+{
+ if (p.core_focuses || (p.modifiers && !p.focus_with_modifiers) || !p.focusable)
+ {
+ return action_t::NONE;
+ }
+
+ // Frames (so a titlebar drag raises as it starts), panels, popups,
+ // modifier clicks, and clicks that core would keep from the app.
+ if (p.modifiers || !p.app_window || !p.on_app_surface || !p.keyboard_focus ||
+ (!p.passthrough && !p.active))
+ {
+ return action_t::CORE;
+ }
+
+ return action_t::DEFER;
+}
+
+/* A deferred press, from button down to button up. Moving the pointer
+ * further than `threshold` makes it a drag (no raise on release); an app
+ * starting drag-and-drop does too, for good. The window manager moving or
+ * resizing the window (a client-side titlebar drag) raises it at once. */
+struct tracker_t
+{
+ enum state_t { IDLE, CLICK, MOVED, DND } state = IDLE;
+ double threshold = 8; // logical pixels; GTK's drag threshold
+ double x = 0, y = 0; // where the press was
+
+ void press(double px, double py)
+ {
+ state = CLICK, x = px, y = py;
+ }
+
+ bool held() const
+ {
+ return state != IDLE;
+ }
+
+ void motion(double px, double py)
+ {
+ if ((state == CLICK) && (std::hypot(px - x, py - y) > threshold))
+ {
+ state = MOVED;
+ }
+ }
+
+ void drag_started()
+ {
+ if (held())
+ {
+ state = DND;
+ }
+ }
+
+ // True if the window should be raised now.
+ bool window_grabbed()
+ {
+ bool raise = (state == CLICK) || (state == MOVED);
+ state = raise ? IDLE : state;
+ return raise;
+ }
+
+ // True if the window should be raised now.
+ bool release()
+ {
+ bool raise = (state == CLICK);
+ state = IDLE;
+ return raise;
+ }
+};
+}
diff --git a/plugins/raise-on-release/tests/press-test.cpp b/plugins/raise-on-release/tests/press-test.cpp
new file mode 100644
index 0000000..9d4c907
--- /dev/null
+++ b/plugins/raise-on-release/tests/press-test.cpp
@@ -0,0 +1,124 @@
+// Unit tests for raise-on-release: which presses wait for the release, and
+// when a held press stops being a click.
+#include "../src/press.hpp"
+#include <cassert>
+#include <cstdio>
+
+using namespace raise_on_release;
+
+// A left press on the client area of a background app window, with Pyr's
+// defaults (core/focus_buttons without BTN_LEFT, passthrough on).
+static press_t background_click()
+{
+ press_t p;
+ p.focusable = p.app_window = p.on_app_surface = p.keyboard_focus = true;
+ return p;
+}
+
+int main()
+{
+ // The client area of a background window: focus now, raise on release.
+ press_t p = background_click();
+ assert(classify(p) == action_t::DEFER);
+ // The active window too (it may sit behind after a drag-out).
+ p.active = true;
+ assert(classify(p) == action_t::DEFER);
+
+ // core/focus_buttons still has the button (an existing config): core
+ // focuses and raises; the plugin does nothing, so nothing happens twice.
+ p = background_click();
+ p.core_focuses = true;
+ assert(classify(p) == action_t::NONE);
+ p.modifiers = p.focus_with_modifiers = true;
+ assert(classify(p) == action_t::NONE);
+
+ // Modifier clicks (Super+drag moves) behave as core: ignored unless
+ // core/focus_button_with_modifiers, and then raised at once.
+ p = background_click();
+ p.modifiers = true;
+ assert(classify(p) == action_t::NONE);
+ p.focus_with_modifiers = true;
+ assert(classify(p) == action_t::CORE);
+
+ // Nothing to focus, or a plugin holds the desktop: nothing.
+ p = background_click();
+ p.focusable = false;
+ assert(classify(p) == action_t::NONE);
+
+ // Server-side frames (titlebar, borders) raise at once, so a titlebar
+ // drag raises as it starts; so do panels, popups and the desktop.
+ p = background_click();
+ p.on_app_surface = false;
+ assert(classify(p) == action_t::CORE);
+ p = background_click();
+ p.app_window = false;
+ assert(classify(p) == action_t::CORE);
+
+ // A window that takes no keyboard focus is raised at once, as by core.
+ p = background_click();
+ p.keyboard_focus = false;
+ assert(classify(p) == action_t::CORE);
+
+ // Without passthrough core keeps a focusing click from the app, so no
+ // drag can start: behave as core. A click in the active window passes.
+ p = background_click();
+ p.passthrough = false;
+ assert(classify(p) == action_t::CORE);
+ p.active = true;
+ assert(classify(p) == action_t::DEFER);
+
+ // A click, even a slightly shaky one, raises on release.
+ tracker_t t;
+ assert(!t.held() && !t.release());
+ t.press(100, 100);
+ assert(t.held());
+ t.motion(103, 104); // 5 px
+ t.motion(108, 100); // 8 px: still a click
+ assert(t.release() && !t.held());
+ assert(!t.release()); // only once
+
+ // Moving further than the threshold makes it a drag: no raise, even if
+ // the pointer comes back.
+ t.press(100, 100);
+ t.motion(106, 106); // 8.5 px
+ t.motion(100, 100);
+ assert(t.held() && !t.release());
+
+ // An app starting drag-and-drop: no raise, whether it started before or
+ // after the pointer passed the threshold.
+ t.press(10, 10);
+ t.drag_started();
+ assert(!t.release());
+ t.press(10, 10);
+ t.motion(40, 10);
+ t.drag_started();
+ assert(!t.release());
+ // ... and a drop moving nothing afterwards does not bring it back.
+ t.press(10, 10);
+ t.drag_started();
+ t.motion(10, 10);
+ assert(!t.window_grabbed() && !t.release());
+ // Drag-and-drop outside a press is not ours.
+ t.drag_started();
+ assert(!t.held());
+
+ // A client-side titlebar drag: the window manager starts moving it.
+ // Raise at once, before or after the threshold, and not again on release.
+ t.press(0, 0);
+ assert(t.window_grabbed() && !t.held() && !t.release());
+ t.press(0, 0);
+ t.motion(0, 30);
+ assert(t.window_grabbed() && !t.release());
+ // A move without a press (keyboard move) is not ours.
+ assert(!t.window_grabbed());
+
+ // The threshold follows its setting.
+ t = {};
+ t.threshold = 2;
+ t.press(0, 0);
+ t.motion(2, 1);
+ assert(!t.release());
+
+ std::puts("raise-on-release press tests passed");
+ return 0;
+}
|