diff options
Diffstat (limited to 'src/user/raleigh/window.cpp')
-rw-r--r-- | src/user/raleigh/window.cpp | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/src/user/raleigh/window.cpp b/src/user/raleigh/window.cpp index 052422e..5d1a3de 100644 --- a/src/user/raleigh/window.cpp +++ b/src/user/raleigh/window.cpp @@ -1,7 +1,6 @@ #include <raleigh/runtime.h> #include <raleigh/window.h> -#include <popups/info.h> -#include <knob/heap.h> +#include <knob/key.h> #include <knob/format.h> @@ -44,8 +43,16 @@ namespace raleigh { 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) 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) + 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)) { + n->d.b(*this); + goto next_loop; + } focussed->handle_key(wa.as_key); + next_loop: + ; + } else if (wa.action_type == wa.FOCUS_ENTER) focussed->on_focus(); else if (wa.action_type == wa.FOCUS_LEAVE) @@ -83,4 +90,22 @@ namespace raleigh { focussed->on_focus(); } } + + void window::notify_widget_size_change(widget &from, coord old_size) { + if (from.parent) + from.parent->notify_child_size_change(from, old_size); + else { + size = root.size; + delete[] pixbuf; + pixbuf = new _pixel_t[size.x * size.y]; + if (!pixbuf) + show_error_and_quitf("Failed to allocate %u byte buffer while\nresizing window to %ux%u pixels.", size.x * size.y, size.x, size.y); + paint_full(); + _resize_window(handle, size.x, size.y, pixbuf); + } + } + + void window::add_keybind(struct key_packet kp, void (*handler)(window &)) { + keybinds.add_front(duple<struct key_packet, void (*)(window &)>(kp, handler)); + } }
\ No newline at end of file |