-int resize_graphical_handler(xcb_connection_t *conn, Workspace *ws, int first, int second,
- resize_orientation_t orientation, xcb_button_press_event_t *event) {
- int new_position;
- xcb_screen_t *root_screen = xcb_setup_roots_iterator(xcb_get_setup(conn)).data;
- i3Screen *screen = get_screen_containing(event->root_x, event->root_y);
- if (screen == NULL) {
- LOG("BUG: No screen found at this position (%d, %d)\n", event->root_x, event->root_y);
- return 1;
- }
-
- LOG("Screen dimensions: (%d, %d) %d x %d\n", screen->rect.x, screen->rect.y, screen->rect.width, screen->rect.height);
+struct callback_params {
+ orientation_t orientation;
+ Con *output;
+ xcb_window_t helpwin;
+ uint32_t *new_position;
+};
+
+DRAGGING_CB(resize_callback) {
+ const struct callback_params *params = extra;
+ Con *output = params->output;
+ DLOG("new x = %d, y = %d\n", new_x, new_y);
+ if (params->orientation == HORIZ) {
+ /* Check if the new coordinates are within screen boundaries */
+ if (new_x > (output->rect.x + output->rect.width - 25) ||
+ new_x < (output->rect.x + 25))
+ return;
+
+ *(params->new_position) = new_x;
+ xcb_configure_window(conn, params->helpwin, XCB_CONFIG_WINDOW_X, params->new_position);
+ } else {
+ if (new_y > (output->rect.y + output->rect.height - 25) ||
+ new_y < (output->rect.y + 25))
+ return;
+
+ *(params->new_position) = new_y;
+ xcb_configure_window(conn, params->helpwin, XCB_CONFIG_WINDOW_Y, params->new_position);
+ }
+
+ xcb_flush(conn);
+}