diff options
Diffstat (limited to 'src/user/raleigh/window.cpp')
-rw-r--r-- | src/user/raleigh/window.cpp | 16 |
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 |