swc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/swc
Log | Files | Refs | README | LICENSE

commit dbead1dae62d18cd9269eb05157ae83bf0c7132a
parent 5ef6e78174f34fc730647509e6d3f55376d45bb5
Author: Michael Forney <mforney@mforney.org>
Date:   Tue, 18 Feb 2014 15:39:23 -0800

window: Implement interactive moving

Diffstat:
Mlibswc/window.c | 12+++++++++++-
Mlibswc/window.h | 1+
2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/libswc/window.c b/libswc/window.c @@ -130,7 +130,13 @@ static inline void window_begin_interaction void window_begin_interactive_move(struct window * window, struct button_press * button) { + struct swc_rectangle * geometry = &window->view->geometry; + int32_t px = wl_fixed_to_int(swc.seat->pointer->x), + py = wl_fixed_to_int(swc.seat->pointer->y); + window_begin_interaction(window, &window->move.interaction, button); + window->move.offset.x = geometry->x - px; + window->move.offset.y = geometry->y - py; } void window_begin_interactive_resize(struct window * window, uint32_t edges, @@ -181,7 +187,11 @@ void swc_window_end_resize(struct swc_window * base) static bool move_motion(struct pointer_handler * handler, uint32_t time, wl_fixed_t fx, wl_fixed_t fy) { - /* TODO: Implement interactive moving */ + struct window * window + = CONTAINER_OF(handler, typeof(*window), move.interaction.handler); + + swc_view_move(window->view, wl_fixed_to_int(fx) + window->move.offset.x, + wl_fixed_to_int(fy) + window->move.offset.y); return true; } diff --git a/libswc/window.h b/libswc/window.h @@ -46,6 +46,7 @@ struct window struct { struct window_pointer_interaction interaction; + struct { int32_t x, y; } offset; } move; struct