summaryrefslogtreecommitdiff
path: root/src/user/raleigh/window.cpp
diff options
context:
space:
mode:
authorBenji Dial <benji6283@gmail.com>2021-03-09 11:24:11 -0500
committerBenji Dial <benji6283@gmail.com>2021-03-09 11:24:11 -0500
commit0f2398d1f622cce37925f52d978d92e6cce1c7a9 (patch)
tree68435086d6375a6a5dab2106b1ecfdabb6340fa8 /src/user/raleigh/window.cpp
parentfd4557c4adddf710979a42e9f9d470bc8b3f77bd (diff)
downloadportland-os-0f2398d1f622cce37925f52d978d92e6cce1c7a9.tar.gz
making mouse movements only reported to widgets in raleigh if they request it, and making it continue while the mouse is outside the widget (but inside the window)
Diffstat (limited to 'src/user/raleigh/window.cpp')
-rw-r--r--src/user/raleigh/window.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/user/raleigh/window.cpp b/src/user/raleigh/window.cpp
index 8501f7e..b99346d 100644
--- a/src/user/raleigh/window.cpp
+++ b/src/user/raleigh/window.cpp
@@ -7,7 +7,7 @@
namespace raleigh {
window::window(widget &root, _pixel_t bg_color, bool (*on_close)(window &))
: handle(0), size(root.size), root(root), focussed(&root),
- bg_color(bg_color), on_close(on_close) {
+ drag_reciever(0), bg_color(bg_color), on_close(on_close) {
root.w = this;
root.window_offset = coord(0, 0);
root.notify_window_change();
@@ -41,8 +41,11 @@ namespace raleigh {
got = GOOD;
if (wa.action_type == wa.MOUSE_DOWN)
root.handle_click(coord(wa.as_mouse.x, wa.as_mouse.y), wa.as_mouse.which, false);
- else if (wa.action_type == wa.MOUSE_UP)
+ else if (wa.action_type == wa.MOUSE_UP) {
+ if (drag_reciever && (wa.as_mouse.which == drag_until))
+ drag_reciever = 0;
root.handle_click(coord(wa.as_mouse.x, wa.as_mouse.y), wa.as_mouse.which, true);
+ }
else if (wa.action_type == wa.KEY_DOWN) {
for (dllist<duple<struct key_packet, void (*)(window &)>>::node *n = keybinds.first; n; n = n->next)
if (match_side_agnostic(wa.as_key, n->d.a)) {
@@ -57,8 +60,8 @@ namespace raleigh {
focussed->on_focus();
else if (wa.action_type == wa.FOCUS_LEAVE)
focussed->on_unfocus();
- else if (wa.action_type == wa.MOUSE_MOVE)
- root.on_mouse_move(coord(wa.moved_to.x, wa.moved_to.y));
+ else if (drag_reciever && (wa.action_type == wa.MOUSE_MOVE))
+ drag_reciever->on_mouse_move(coord(wa.moved_to.x, wa.moved_to.y));
}
}
@@ -112,4 +115,9 @@ namespace raleigh {
void window::add_keybind(struct key_packet kp, void (*handler)(window &)) {
keybinds.add_front(duple<struct key_packet, void (*)(window &)>(kp, handler));
}
+
+ void window::notify_wants_movements(widget &from, enum mouse_packet::mouse_button while_down) {
+ drag_reciever = &from;
+ drag_until = while_down;
+ }
} \ No newline at end of file