static void touch_handler(struct widget *widget, struct input *input, uint32_t serial, uint32_t time, int32_t id, float x, float y, void *data) { struct fullscreen *fullscreen = data; window_move(fullscreen->window, input, display_get_serial(fullscreen->display)); }
static void touch_handler(struct widget *widget, struct input *input, uint32_t serial, uint32_t time, int32_t id, float x, float y, void *data) { struct transformed *transformed = data; window_move(transformed->window, input, display_get_serial(transformed->display)); }
static void touch_down_handler(struct widget *widget, struct input *input, uint32_t serial, uint32_t time, int32_t id, float x, float y, void *data) { struct flower *flower = data; window_move(flower->window, input, display_get_serial(flower->display)); }
static void button_handler(struct window *window, struct input *input, uint32_t time, int button, int state, void *data) { if (state) window_move(window, input, time); }
static void button_handler(struct widget *widget, struct input *input, uint32_t time, uint32_t button, enum wl_pointer_button_state state, void *data) { struct box *box = data; if (button != BTN_LEFT) return; if (state == WL_POINTER_BUTTON_STATE_PRESSED) { window_move(box->window, input, display_get_serial(box->display)); } }
/** * @brief Resizes the main menu and its background. * * This is a one-off function that ensures the main menu's appearance * is consistent regardless of window resizing. */ void menu_main_resize (void) { int w, h, bgw, bgh, tw, th; int offset_logo, offset_wdw, freespace; int menu_id, bg_id; Widget *wgt; if (!menu_isOpen(MENU_MAIN)) return; menu_id = window_get("Main Menu"); bg_id = window_get("BG"); window_dimWindow( menu_id, &w, &h ); window_dimWindow( bg_id, &bgw, &bgh ); freespace = SCREEN_H - main_naevLogo->sh - h; if (freespace < 0) { offset_logo = SCREEN_H - main_naevLogo->sh; offset_wdw = 0; } else { offset_logo = -freespace/4; offset_wdw = freespace/2; } window_moveWidget( bg_id, "imgLogo", (bgw - main_naevLogo->sw)/2., offset_logo ); window_dimWidget( bg_id, "txtBG", &tw, &th ); if (tw > SCREEN_W) { /* RIP abstractions. X must be set manually because window_moveWidget * transforms negative coordinates. */ wgt = window_getwgt( bg_id, "txtBG" ); if (wgt) wgt->x = (SCREEN_W - tw) / 2; } else window_moveWidget( bg_id, "txtBG", (SCREEN_W - tw)/2, 10. ); window_move( menu_id, -1, offset_wdw ); }
static void button_handler(struct widget *widget, struct input *input, uint32_t time, uint32_t button, enum wl_pointer_button_state state, void *data) { struct fullscreen *fullscreen = data; switch (button) { case BTN_LEFT: if (state == WL_POINTER_BUTTON_STATE_PRESSED) window_move(fullscreen->window, input, display_get_serial(fullscreen->display)); break; case BTN_RIGHT: if (state == WL_POINTER_BUTTON_STATE_PRESSED) window_show_frame_menu(fullscreen->window, input, time); break; } }
static void button_handler(struct widget *widget, struct input *input, uint32_t time, uint32_t button, enum wl_pointer_button_state state, void *data) { struct transformed *transformed = data; switch (button) { case BTN_LEFT: if (state == WL_POINTER_BUTTON_STATE_PRESSED) window_move(transformed->window, input, display_get_serial(transformed->display)); break; case BTN_MIDDLE: if (state == WL_POINTER_BUTTON_STATE_PRESSED) widget_schedule_redraw(widget); break; case BTN_RIGHT: if (state == WL_POINTER_BUTTON_STATE_PRESSED) window_show_frame_menu(transformed->window, input, time); break; } }
void track_pointer(int root_x, int root_y) { if (frozen_pointer->action == ACTION_NONE) return; int16_t delta_x, delta_y, x = 0, y = 0, w = 1, h = 1; uint16_t width, height; pointer_action_t pac = frozen_pointer->action; monitor_t *m = frozen_pointer->monitor; desktop_t *d = frozen_pointer->desktop; node_t *n = frozen_pointer->node; client_t *c = frozen_pointer->client; xcb_window_t win = frozen_pointer->window; xcb_rectangle_t rect = frozen_pointer->rectangle; node_t *vertical_fence = frozen_pointer->vertical_fence; node_t *horizontal_fence = frozen_pointer->horizontal_fence; delta_x = root_x - frozen_pointer->position.x; delta_y = root_y - frozen_pointer->position.y; switch (pac) { case ACTION_MOVE: if (frozen_pointer->is_tiled) { xcb_window_t pwin = XCB_NONE; query_pointer(&pwin, NULL); if (pwin == win) return; coordinates_t loc; bool is_managed = (pwin == XCB_NONE ? false : locate_window(pwin, &loc)); if (is_managed && is_tiled(loc.node->client) && loc.monitor == m) { swap_nodes(m, d, n, m, d, loc.node); arrange(m, d); } else { if (is_managed && loc.monitor == m) { return; } else if (!is_managed) { xcb_point_t pt = (xcb_point_t) {root_x, root_y}; monitor_t *pmon = monitor_from_point(pt); if (pmon == NULL || pmon == m) { return; } else { loc.monitor = pmon; loc.desktop = pmon->desk; } } bool focused = (n == mon->desk->focus); transfer_node(m, d, n, loc.monitor, loc.desktop, loc.desktop->focus); if (focused) focus_node(loc.monitor, loc.desktop, n); frozen_pointer->monitor = loc.monitor; frozen_pointer->desktop = loc.desktop; } } else { x = rect.x + delta_x; y = rect.y + delta_y; window_move(win, x, y); c->floating_rectangle.x = x; c->floating_rectangle.y = y; xcb_point_t pt = (xcb_point_t) {root_x, root_y}; monitor_t *pmon = monitor_from_point(pt); if (pmon == NULL || pmon == m) return; bool focused = (n == mon->desk->focus); transfer_node(m, d, n, pmon, pmon->desk, pmon->desk->focus); if (focused) focus_node(pmon, pmon->desk, n); frozen_pointer->monitor = pmon; frozen_pointer->desktop = pmon->desk; } break; case ACTION_RESIZE_SIDE: case ACTION_RESIZE_CORNER: if (frozen_pointer->is_tiled) { if (vertical_fence != NULL) { double sr = frozen_pointer->vertical_ratio + (double) delta_x / vertical_fence->rectangle.width; sr = MAX(0, sr); sr = MIN(1, sr); vertical_fence->split_ratio = sr; } if (horizontal_fence != NULL) { double sr = frozen_pointer->horizontal_ratio + (double) delta_y / horizontal_fence->rectangle.height; sr = MAX(0, sr); sr = MIN(1, sr); horizontal_fence->split_ratio = sr; } arrange(mon, mon->desk); } else { if (pac == ACTION_RESIZE_SIDE) { switch (frozen_pointer->side) { case SIDE_TOP: x = rect.x; y = rect.y + delta_y; w = rect.width; h = rect.height - delta_y; break; case SIDE_RIGHT: x = rect.x; y = rect.y; w = rect.width + delta_x; h = rect.height; break; case SIDE_BOTTOM: x = rect.x; y = rect.y; w = rect.width; h = rect.height + delta_y; break; case SIDE_LEFT: x = rect.x + delta_x; y = rect.y; w = rect.width - delta_x; h = rect.height; break; } width = MAX(1, w); height = MAX(1, h); window_move_resize(win, x, y, width, height); c->floating_rectangle = (xcb_rectangle_t) {x, y, width, height}; window_draw_border(n, d->focus == n, mon == m); } else if (pac == ACTION_RESIZE_CORNER) { switch (frozen_pointer->corner) { case CORNER_TOP_LEFT: x = rect.x + delta_x; y = rect.y + delta_y; w = rect.width - delta_x; h = rect.height - delta_y; break; case CORNER_TOP_RIGHT: x = rect.x; y = rect.y + delta_y; w = rect.width + delta_x; h = rect.height - delta_y; break; case CORNER_BOTTOM_LEFT: x = rect.x + delta_x; y = rect.y; w = rect.width - delta_x; h = rect.height + delta_y; break; case CORNER_BOTTOM_RIGHT: x = rect.x; y = rect.y; w = rect.width + delta_x; h = rect.height + delta_y; break; } width = MAX(1, w); height = MAX(1, h); window_move_resize(win, x, y, width, height); c->floating_rectangle = (xcb_rectangle_t) {x, y, width, height}; window_draw_border(n, d->focus == n, mon == m); } } break; case ACTION_FOCUS: case ACTION_NONE: break; } }
bool move_client(coordinates_t *loc, int dx, int dy) { node_t *n = loc->node; if (n == NULL || n->client == NULL) { return false; } monitor_t *pm = NULL; if (IS_TILED(n->client)) { if (!grabbing) { return false; } xcb_window_t pwin = XCB_NONE; query_pointer(&pwin, NULL); if (pwin == n->id) { return false; } coordinates_t dst; bool is_managed = (pwin != XCB_NONE && locate_window(pwin, &dst)); if (is_managed && dst.monitor == loc->monitor && IS_TILED(dst.node->client)) { swap_nodes(loc->monitor, loc->desktop, n, loc->monitor, loc->desktop, dst.node); return true; } else { if (is_managed && dst.monitor == loc->monitor) { return false; } else { xcb_point_t pt = {0, 0}; query_pointer(NULL, &pt); pm = monitor_from_point(pt); } } } else { client_t *c = n->client; xcb_rectangle_t rect = c->floating_rectangle; int16_t x = rect.x + dx; int16_t y = rect.y + dy; if (focus_follows_pointer) { listen_enter_notify(loc->desktop->root, false); } window_move(n->id, x, y); if (focus_follows_pointer) { listen_enter_notify(loc->desktop->root, true); } c->floating_rectangle.x = x; c->floating_rectangle.y = y; if (!grabbing) { put_status(SBSC_MASK_NODE_GEOMETRY, "node_geometry 0x%08X 0x%08X 0x%08X %ux%u+%i+%i\n", loc->monitor->id, loc->desktop->id, loc->node->id, rect.width, rect.height, x, y); } pm = monitor_from_client(c); } if (pm == NULL || pm == loc->monitor) { return true; } bool focused = (n == mon->desk->focus); transfer_node(loc->monitor, loc->desktop, n, pm, pm->desk, pm->desk->focus); loc->monitor = pm; loc->desktop = pm->desk; if (focused) { focus_node(pm, pm->desk, n); } return true; }
inline void window::move(int x, int y, int w, int h) { window_move( hwnd,x, y, w, h ); }
DECLARE_TEST( window, sizemove ) { window_t* window; #if FOUNDATION_PLATFORM_MACOSX window = window_allocate_from_nswindow( delegate_nswindow() ); #elif FOUNDATION_PLATFORM_IOS window = window_allocate_from_uiwindow( delegate_uiwindow() ); #endif EXPECT_NE( window, 0 ); EXPECT_TRUE( window_is_open( window ) ); thread_sleep( 1000 ); #if FOUNDATION_PLATFORM_IOS || FOUNDATION_PLATFORM_ANDROID EXPECT_TRUE( window_is_maximized( window ) ); #else EXPECT_FALSE( window_is_maximized( window ) ); #endif EXPECT_TRUE( window_is_visible( window ) ); EXPECT_TRUE( window_has_focus( window ) ); window_maximize( window ); thread_sleep( 1000 ); EXPECT_TRUE( window_is_maximized( window ) ); EXPECT_TRUE( window_has_focus( window ) ); #if !FOUNDATION_PLATFORM_IOS && !FOUNDATION_PLATFORM_ANDROID window_restore( window ); thread_sleep( 1000 ); EXPECT_FALSE( window_is_maximized( window ) ); EXPECT_TRUE( window_has_focus( window ) ); #endif window_maximize( window ); thread_sleep( 1000 ); EXPECT_TRUE( window_is_maximized( window ) ); #if !FOUNDATION_PLATFORM_IOS && !FOUNDATION_PLATFORM_ANDROID window_resize( window, 150, 100 ); thread_sleep( 1000 ); EXPECT_EQ( window_width( window ), 150 ); EXPECT_EQ( window_height( window ), 100 ); EXPECT_FALSE( window_is_maximized( window ) ); EXPECT_TRUE( window_has_focus( window ) ); window_move( window, 10, 20 ); thread_sleep( 1000 ); EXPECT_EQ( window_position_x( window ), 10 ); EXPECT_EQ( window_position_y( window ), 20 ); EXPECT_FALSE( window_is_maximized( window ) ); EXPECT_TRUE( window_has_focus( window ) ); window_minimize( window ); thread_sleep( 1000 ); EXPECT_FALSE( window_is_maximized( window ) ); EXPECT_FALSE( window_has_focus( window ) ); window_restore( window ); thread_sleep( 1000 ); EXPECT_FALSE( window_is_maximized( window ) ); EXPECT_FALSE( window_is_minimized( window ) ); EXPECT_TRUE( window_has_focus( window ) ); window_minimize( window ); thread_sleep( 1000 ); EXPECT_FALSE( window_is_maximized( window ) ); EXPECT_TRUE( window_is_minimized( window ) ); #endif window_deallocate( window ); window = 0; EXPECT_FALSE( window_is_open( window ) ); return 0; }