2012-08-01 12:56:57 +02:00
|
|
|
#include <stdio.h>
|
2012-08-29 18:37:31 +02:00
|
|
|
#include <stdlib.h>
|
2012-09-24 19:40:49 +02:00
|
|
|
#include <string.h>
|
2012-08-01 12:56:57 +02:00
|
|
|
#include <xcb/xcb.h>
|
2013-01-02 12:36:54 +01:00
|
|
|
#include <xcb/xcb_keysyms.h>
|
2012-08-01 12:56:57 +02:00
|
|
|
#include <xcb/xcb_event.h>
|
2012-10-24 16:34:56 +02:00
|
|
|
#include <xcb/xcb_icccm.h>
|
2012-08-25 15:24:35 +02:00
|
|
|
#include "types.h"
|
2012-08-28 21:15:29 +02:00
|
|
|
#include "bspwm.h"
|
2012-09-13 13:56:53 +02:00
|
|
|
#include "settings.h"
|
2013-01-02 12:36:54 +01:00
|
|
|
#include "buttons.h"
|
2012-10-03 20:07:33 +03:00
|
|
|
#include "helpers.h"
|
2012-09-18 17:21:04 +02:00
|
|
|
#include "window.h"
|
2012-08-01 12:56:57 +02:00
|
|
|
#include "events.h"
|
2012-09-01 21:55:35 +02:00
|
|
|
#include "tree.h"
|
2012-09-18 17:21:04 +02:00
|
|
|
#include "rules.h"
|
2012-09-11 22:48:26 +02:00
|
|
|
#include "ewmh.h"
|
2012-08-01 12:56:57 +02:00
|
|
|
|
|
|
|
void handle_event(xcb_generic_event_t *evt)
|
|
|
|
{
|
|
|
|
switch (XCB_EVENT_RESPONSE_TYPE(evt)) {
|
|
|
|
case XCB_MAP_REQUEST:
|
2012-08-25 15:24:35 +02:00
|
|
|
map_request(evt);
|
2012-08-01 23:16:07 +02:00
|
|
|
break;
|
2012-09-16 14:16:58 +02:00
|
|
|
case XCB_DESTROY_NOTIFY:
|
|
|
|
destroy_notify(evt);
|
|
|
|
break;
|
|
|
|
case XCB_UNMAP_NOTIFY:
|
2012-09-21 19:05:42 +02:00
|
|
|
unmap_notify(evt);
|
2012-09-16 14:16:58 +02:00
|
|
|
break;
|
2012-09-11 22:48:26 +02:00
|
|
|
case XCB_CLIENT_MESSAGE:
|
|
|
|
client_message(evt);
|
|
|
|
break;
|
2012-08-01 23:16:07 +02:00
|
|
|
case XCB_CONFIGURE_REQUEST:
|
2012-09-16 14:16:58 +02:00
|
|
|
configure_request(evt);
|
2012-08-01 23:16:07 +02:00
|
|
|
break;
|
2012-09-20 23:32:32 +02:00
|
|
|
case XCB_PROPERTY_NOTIFY:
|
|
|
|
property_notify(evt);
|
|
|
|
break;
|
2013-01-02 12:36:54 +01:00
|
|
|
case XCB_MAPPING_NOTIFY:
|
|
|
|
mapping_notify(evt);
|
|
|
|
break;
|
2012-10-22 12:21:12 +02:00
|
|
|
case XCB_ENTER_NOTIFY:
|
|
|
|
enter_notify(evt);
|
|
|
|
break;
|
2012-08-01 23:16:07 +02:00
|
|
|
case XCB_BUTTON_PRESS:
|
2012-09-22 12:16:46 +02:00
|
|
|
button_press(evt);
|
|
|
|
break;
|
2012-09-22 15:10:59 +02:00
|
|
|
case XCB_MOTION_NOTIFY:
|
|
|
|
motion_notify(evt);
|
|
|
|
break;
|
2012-09-22 12:16:46 +02:00
|
|
|
case XCB_BUTTON_RELEASE:
|
2012-10-06 11:36:16 +02:00
|
|
|
button_release();
|
2012-08-01 12:56:57 +02:00
|
|
|
break;
|
|
|
|
default:
|
2012-09-12 14:56:51 +02:00
|
|
|
break;
|
2012-08-01 12:56:57 +02:00
|
|
|
}
|
|
|
|
}
|
2012-08-25 15:24:35 +02:00
|
|
|
|
|
|
|
void map_request(xcb_generic_event_t *evt)
|
|
|
|
{
|
|
|
|
xcb_map_request_event_t *e = (xcb_map_request_event_t *) evt;
|
2012-09-20 16:32:01 +02:00
|
|
|
|
|
|
|
PRINTF("map request %X\n", e->window);
|
|
|
|
|
2012-10-25 21:49:14 +02:00
|
|
|
manage_window(mon, mon->desk, e->window);
|
2012-09-16 14:16:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void configure_request(xcb_generic_event_t *evt)
|
|
|
|
{
|
|
|
|
xcb_configure_request_event_t *e = (xcb_configure_request_event_t *) evt;
|
2012-09-20 16:32:01 +02:00
|
|
|
|
|
|
|
PRINTF("configure request %X\n", e->window);
|
|
|
|
|
2012-09-16 14:16:58 +02:00
|
|
|
window_location_t loc;
|
|
|
|
bool is_managed = locate_window(e->window, &loc);
|
2012-09-18 17:21:04 +02:00
|
|
|
|
2012-09-24 15:00:40 +02:00
|
|
|
if (!is_managed || is_floating(loc.node->client)) {
|
|
|
|
uint16_t mask = 0;
|
|
|
|
uint32_t values[7];
|
|
|
|
unsigned short i = 0;
|
|
|
|
|
|
|
|
if (e->value_mask & XCB_CONFIG_WINDOW_X) {
|
|
|
|
mask |= XCB_CONFIG_WINDOW_X;
|
|
|
|
values[i++] = e->x;
|
|
|
|
if (is_managed)
|
|
|
|
loc.node->client->floating_rectangle.x = e->x;
|
|
|
|
}
|
2012-09-16 14:16:58 +02:00
|
|
|
|
2012-09-24 15:00:40 +02:00
|
|
|
if (e->value_mask & XCB_CONFIG_WINDOW_Y) {
|
|
|
|
mask |= XCB_CONFIG_WINDOW_Y;
|
|
|
|
values[i++] = e->y;
|
|
|
|
if (is_managed)
|
|
|
|
loc.node->client->floating_rectangle.y = e->y;
|
|
|
|
}
|
2012-09-16 14:16:58 +02:00
|
|
|
|
2012-09-24 15:00:40 +02:00
|
|
|
if (e->value_mask & XCB_CONFIG_WINDOW_WIDTH) {
|
|
|
|
mask |= XCB_CONFIG_WINDOW_WIDTH;
|
|
|
|
values[i++] = e->width;
|
|
|
|
if (is_managed)
|
|
|
|
loc.node->client->floating_rectangle.width = e->width;
|
|
|
|
}
|
2012-09-16 14:16:58 +02:00
|
|
|
|
2012-09-24 15:00:40 +02:00
|
|
|
if (e->value_mask & XCB_CONFIG_WINDOW_HEIGHT) {
|
|
|
|
mask |= XCB_CONFIG_WINDOW_HEIGHT;
|
|
|
|
values[i++] = e->height;
|
|
|
|
if (is_managed)
|
|
|
|
loc.node->client->floating_rectangle.height = e->height;
|
|
|
|
}
|
2012-09-16 14:16:58 +02:00
|
|
|
|
2012-09-24 15:00:40 +02:00
|
|
|
if (!is_managed && e->value_mask & XCB_CONFIG_WINDOW_BORDER_WIDTH) {
|
|
|
|
mask |= XCB_CONFIG_WINDOW_BORDER_WIDTH;
|
|
|
|
values[i++] = e->border_width;
|
|
|
|
}
|
2012-09-16 14:16:58 +02:00
|
|
|
|
2012-09-24 15:00:40 +02:00
|
|
|
if (e->value_mask & XCB_CONFIG_WINDOW_SIBLING) {
|
|
|
|
mask |= XCB_CONFIG_WINDOW_SIBLING;
|
|
|
|
values[i++] = e->sibling;
|
|
|
|
}
|
2012-09-18 17:21:04 +02:00
|
|
|
|
2012-09-24 15:00:40 +02:00
|
|
|
if (e->value_mask & XCB_CONFIG_WINDOW_STACK_MODE) {
|
|
|
|
mask |= XCB_CONFIG_WINDOW_STACK_MODE;
|
|
|
|
values[i++] = e->stack_mode;
|
|
|
|
}
|
2012-09-24 12:08:51 +02:00
|
|
|
|
2012-09-24 15:00:40 +02:00
|
|
|
xcb_configure_window(dpy, e->window, mask, values);
|
|
|
|
if (is_managed)
|
2012-10-17 16:18:40 +02:00
|
|
|
window_draw_border(loc.node, loc.node == loc.desktop->focus, loc.monitor == mon);
|
2012-09-24 15:00:40 +02:00
|
|
|
} else {
|
|
|
|
xcb_configure_notify_event_t evt;
|
|
|
|
xcb_rectangle_t rect;
|
|
|
|
unsigned int bw;
|
|
|
|
xcb_window_t win = loc.node->client->window;
|
|
|
|
|
|
|
|
if (is_tiled(loc.node->client)) {
|
|
|
|
rect = loc.node->client->tiled_rectangle;
|
|
|
|
bw = border_width;
|
|
|
|
} else {
|
2012-10-29 10:45:47 +01:00
|
|
|
rect = loc.monitor->rectangle;
|
2012-09-24 15:00:40 +02:00
|
|
|
bw = 0;
|
2012-09-24 12:08:51 +02:00
|
|
|
}
|
2012-09-24 15:00:40 +02:00
|
|
|
|
|
|
|
evt.response_type = XCB_CONFIGURE_NOTIFY;
|
|
|
|
evt.event = win;
|
|
|
|
evt.window = win;
|
|
|
|
evt.above_sibling = XCB_NONE;
|
|
|
|
evt.x = rect.x;
|
|
|
|
evt.y = rect.y;
|
|
|
|
evt.width = rect.width;
|
|
|
|
evt.height = rect.height;
|
|
|
|
evt.border_width = bw;
|
|
|
|
evt.override_redirect = false;
|
|
|
|
|
|
|
|
xcb_send_event(dpy, false, win, XCB_EVENT_MASK_STRUCTURE_NOTIFY, (const char *) &evt);
|
2012-09-24 12:08:51 +02:00
|
|
|
}
|
2012-09-16 14:16:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void destroy_notify(xcb_generic_event_t *evt)
|
|
|
|
{
|
|
|
|
xcb_destroy_notify_event_t *e = (xcb_destroy_notify_event_t *) evt;
|
|
|
|
|
2012-09-20 16:32:01 +02:00
|
|
|
PRINTF("destroy notify %X\n", e->window);
|
|
|
|
|
2012-09-20 23:32:32 +02:00
|
|
|
window_location_t loc;
|
2012-09-16 14:16:58 +02:00
|
|
|
if (locate_window(e->window, &loc)) {
|
|
|
|
remove_node(loc.desktop, loc.node);
|
2012-10-17 16:18:40 +02:00
|
|
|
arrange(loc.monitor, loc.desktop);
|
2012-09-16 14:16:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void unmap_notify(xcb_generic_event_t *evt)
|
|
|
|
{
|
|
|
|
xcb_unmap_notify_event_t *e = (xcb_unmap_notify_event_t *) evt;
|
2012-09-20 16:32:01 +02:00
|
|
|
|
2012-10-06 11:36:16 +02:00
|
|
|
PRINTF("unmap notify %X\n", e->window);
|
2012-09-21 19:05:42 +02:00
|
|
|
|
2012-09-20 16:32:01 +02:00
|
|
|
window_location_t loc;
|
2012-09-20 23:32:32 +02:00
|
|
|
if (locate_window(e->window, &loc)) {
|
2012-09-21 19:05:42 +02:00
|
|
|
remove_node(loc.desktop, loc.node);
|
2012-10-17 16:18:40 +02:00
|
|
|
arrange(loc.monitor, loc.desktop);
|
2012-09-16 14:16:58 +02:00
|
|
|
}
|
2012-08-25 15:24:35 +02:00
|
|
|
}
|
2012-09-11 22:48:26 +02:00
|
|
|
|
2012-09-20 23:32:32 +02:00
|
|
|
void property_notify(xcb_generic_event_t *evt)
|
|
|
|
{
|
|
|
|
xcb_property_notify_event_t *e = (xcb_property_notify_event_t *) evt;
|
|
|
|
xcb_icccm_wm_hints_t hints;
|
|
|
|
|
2012-09-21 17:39:22 +02:00
|
|
|
/* PRINTF("property notify %X\n", e->window); */
|
2012-09-20 23:32:32 +02:00
|
|
|
|
|
|
|
if (e->atom != XCB_ATOM_WM_HINTS)
|
|
|
|
return;
|
|
|
|
|
|
|
|
window_location_t loc;
|
|
|
|
if (locate_window(e->window, &loc)) {
|
|
|
|
if (xcb_icccm_get_wm_hints_reply(dpy, xcb_icccm_get_wm_hints(dpy, e->window), &hints, NULL) == 1) {
|
2012-12-25 12:39:23 +01:00
|
|
|
uint32_t urgent = xcb_icccm_wm_hints_get_urgency(&hints);
|
|
|
|
if (urgent != 0 && loc.node != mon->desk->focus) {
|
|
|
|
loc.node->client->urgent = urgent;
|
|
|
|
put_status();
|
|
|
|
if (loc.monitor->desk == loc.desktop)
|
|
|
|
arrange(loc.monitor, loc.desktop);
|
|
|
|
}
|
2012-09-20 23:32:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-02 12:36:54 +01:00
|
|
|
void mapping_notify(xcb_generic_event_t *evt)
|
|
|
|
{
|
|
|
|
xcb_mapping_notify_event_t *e = (xcb_mapping_notify_event_t *) evt;
|
|
|
|
if (e->count > 0) {
|
|
|
|
ungrab_buttons();
|
|
|
|
xcb_refresh_keyboard_mapping(symbols, e);
|
|
|
|
get_lock_fields();
|
|
|
|
grab_buttons();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-22 12:21:12 +02:00
|
|
|
void enter_notify(xcb_generic_event_t *evt)
|
|
|
|
{
|
|
|
|
xcb_enter_notify_event_t *e = (xcb_enter_notify_event_t *) evt;
|
|
|
|
|
2012-10-22 22:38:21 +02:00
|
|
|
PRINTF("enter notify %X %d %d\n", e->event, e->mode, e->detail);
|
2012-10-22 12:21:12 +02:00
|
|
|
|
2012-10-23 19:29:21 +02:00
|
|
|
if (!focus_follows_mouse
|
2012-10-24 19:31:33 +02:00
|
|
|
|| (e->mode != XCB_NOTIFY_MODE_NORMAL && e->detail == XCB_NOTIFY_DETAIL_INFERIOR)
|
2012-12-20 11:14:38 +01:00
|
|
|
|| (pointer_position.x == e->root_x && pointer_position.y == e->root_y)
|
|
|
|
|| last_entered == e->event)
|
2012-10-22 12:21:12 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
window_location_t loc;
|
2012-10-23 13:48:09 +02:00
|
|
|
if (locate_window(e->event, &loc)) {
|
|
|
|
select_monitor(loc.monitor);
|
2012-10-23 12:17:19 +02:00
|
|
|
focus_node(loc.monitor, loc.desktop, loc.node, true);
|
2012-10-24 19:31:33 +02:00
|
|
|
pointer_position = (xcb_point_t) {e->root_x, e->root_y};
|
2012-12-20 11:14:38 +01:00
|
|
|
last_entered = e->event;
|
2012-10-23 13:48:09 +02:00
|
|
|
}
|
2012-10-22 12:21:12 +02:00
|
|
|
}
|
|
|
|
|
2012-09-11 22:48:26 +02:00
|
|
|
void client_message(xcb_generic_event_t *evt)
|
|
|
|
{
|
|
|
|
xcb_client_message_event_t *e = (xcb_client_message_event_t *) evt;
|
2012-09-20 16:32:01 +02:00
|
|
|
|
2012-12-08 23:14:29 +01:00
|
|
|
PRINTF("client message %X %u\n", e->window, e->type);
|
2012-09-20 16:32:01 +02:00
|
|
|
|
2012-12-08 23:14:29 +01:00
|
|
|
if (e->type == ewmh->_NET_CURRENT_DESKTOP) {
|
|
|
|
desktop_location_t loc;
|
|
|
|
if (ewmh_locate_desktop(e->data.data32[0], &loc)) {
|
|
|
|
select_monitor(loc.monitor);
|
|
|
|
select_desktop(loc.desktop);
|
|
|
|
}
|
2012-12-08 23:19:13 +01:00
|
|
|
return;
|
2012-12-08 23:14:29 +01:00
|
|
|
}
|
2012-09-16 14:16:58 +02:00
|
|
|
|
2012-12-08 23:14:29 +01:00
|
|
|
window_location_t loc;
|
2012-09-16 14:16:58 +02:00
|
|
|
if (!locate_window(e->window, &loc))
|
2012-09-11 22:48:26 +02:00
|
|
|
return;
|
|
|
|
|
2012-09-16 14:16:58 +02:00
|
|
|
if (e->type == ewmh->_NET_WM_STATE) {
|
2012-10-18 11:09:17 +02:00
|
|
|
handle_state(loc.monitor, loc.desktop, loc.node, e->data.data32[1], e->data.data32[0]);
|
|
|
|
handle_state(loc.monitor, loc.desktop, loc.node, e->data.data32[2], e->data.data32[0]);
|
2012-09-16 14:16:58 +02:00
|
|
|
} else if (e->type == ewmh->_NET_ACTIVE_WINDOW) {
|
2012-10-11 15:16:40 +02:00
|
|
|
if (loc.desktop->focus->client->fullscreen && loc.desktop->focus != loc.node)
|
2012-10-18 11:09:17 +02:00
|
|
|
toggle_fullscreen(loc.monitor, loc.desktop->focus->client);
|
2012-10-25 19:45:41 +02:00
|
|
|
select_monitor(loc.monitor);
|
|
|
|
select_desktop(loc.desktop);
|
2012-10-17 16:18:40 +02:00
|
|
|
focus_node(loc.monitor, loc.desktop, loc.node, true);
|
2012-10-25 19:45:41 +02:00
|
|
|
arrange(loc.monitor, loc.desktop);
|
2012-09-11 22:48:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-22 12:16:46 +02:00
|
|
|
void button_press(xcb_generic_event_t *evt)
|
|
|
|
{
|
|
|
|
xcb_button_press_event_t *e = (xcb_button_press_event_t *) evt;
|
|
|
|
xcb_window_t win = e->child;
|
|
|
|
|
2012-12-03 19:30:48 +01:00
|
|
|
PRINTF("button press %u %u %X\n", e->detail, e->state, win);
|
2012-09-22 12:16:46 +02:00
|
|
|
|
|
|
|
window_location_t loc;
|
|
|
|
if (locate_window(win, &loc)) {
|
2012-09-22 16:32:35 +02:00
|
|
|
client_t *c = loc.node->client;
|
2012-09-22 12:16:46 +02:00
|
|
|
switch (e->detail) {
|
|
|
|
case XCB_BUTTON_INDEX_2:
|
2012-10-17 16:18:40 +02:00
|
|
|
focus_node(loc.monitor, loc.desktop, loc.node, true);
|
2012-09-22 12:16:46 +02:00
|
|
|
break;
|
|
|
|
case XCB_BUTTON_INDEX_1:
|
|
|
|
case XCB_BUTTON_INDEX_3:
|
2012-10-23 13:58:31 +02:00
|
|
|
if (is_tiled(loc.node->client)) {
|
|
|
|
loc.node->client->floating_rectangle = loc.node->client->tiled_rectangle;
|
|
|
|
toggle_floating(loc.node);
|
|
|
|
arrange(loc.monitor, loc.desktop);
|
|
|
|
} else if (loc.node->client->fullscreen) {
|
2012-09-22 15:10:59 +02:00
|
|
|
return;
|
2012-10-23 13:58:31 +02:00
|
|
|
}
|
2012-11-02 14:47:26 +01:00
|
|
|
frozen_pointer->monitor = loc.monitor;
|
2012-09-22 16:32:35 +02:00
|
|
|
frozen_pointer->desktop = loc.desktop;
|
|
|
|
frozen_pointer->node = loc.node;
|
|
|
|
frozen_pointer->rectangle = c->floating_rectangle;
|
2012-09-22 15:10:59 +02:00
|
|
|
frozen_pointer->position = (xcb_point_t) {e->root_x, e->root_y};
|
|
|
|
frozen_pointer->button = e->detail;
|
2012-09-22 16:32:35 +02:00
|
|
|
if (e->detail == XCB_BUTTON_INDEX_3) {
|
|
|
|
int16_t mid_x, mid_y;
|
|
|
|
mid_x = c->floating_rectangle.x + (c->floating_rectangle.width / 2);
|
|
|
|
mid_y = c->floating_rectangle.y + (c->floating_rectangle.height / 2);
|
|
|
|
if (e->root_x > mid_x) {
|
|
|
|
if (e->root_y > mid_y)
|
|
|
|
frozen_pointer->corner = BOTTOM_RIGHT;
|
|
|
|
else
|
|
|
|
frozen_pointer->corner = TOP_RIGHT;
|
|
|
|
} else {
|
|
|
|
if (e->root_y > mid_y)
|
|
|
|
frozen_pointer->corner = BOTTOM_LEFT;
|
|
|
|
else
|
|
|
|
frozen_pointer->corner = TOP_LEFT;
|
|
|
|
}
|
|
|
|
}
|
2013-01-02 12:36:54 +01:00
|
|
|
xcb_grab_pointer(dpy, false, root, XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_BUTTON_RELEASE, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, XCB_NONE, XCB_NONE, XCB_CURRENT_TIME);
|
2012-09-22 12:16:46 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-22 15:10:59 +02:00
|
|
|
void motion_notify(xcb_generic_event_t *evt)
|
|
|
|
{
|
|
|
|
xcb_motion_notify_event_t *e = (xcb_motion_notify_event_t *) evt;
|
|
|
|
|
2012-09-22 17:17:18 +02:00
|
|
|
int16_t delta_x, delta_y, x, y, w, h;
|
|
|
|
uint16_t width, height;
|
2012-09-22 16:32:35 +02:00
|
|
|
|
2012-10-17 16:18:40 +02:00
|
|
|
monitor_t *m = frozen_pointer->monitor;
|
2012-09-22 16:32:35 +02:00
|
|
|
desktop_t *d = frozen_pointer->desktop;
|
|
|
|
node_t *n = frozen_pointer->node;
|
|
|
|
client_t *c = n->client;
|
|
|
|
xcb_rectangle_t rect = frozen_pointer->rectangle;
|
|
|
|
xcb_window_t win = c->window;
|
|
|
|
|
2012-11-02 14:47:26 +01:00
|
|
|
x = y = 0;
|
|
|
|
w = h = 1;
|
|
|
|
|
2012-10-06 11:19:51 +02:00
|
|
|
/* PRINTF("motion notify %X\n", win); */
|
2012-09-22 16:32:35 +02:00
|
|
|
|
|
|
|
delta_x = e->root_x - frozen_pointer->position.x;
|
|
|
|
delta_y = e->root_y - frozen_pointer->position.y;
|
2012-09-22 15:10:59 +02:00
|
|
|
|
|
|
|
switch (frozen_pointer->button) {
|
|
|
|
case XCB_BUTTON_INDEX_1:
|
2012-09-22 16:32:35 +02:00
|
|
|
x = rect.x + delta_x;
|
|
|
|
y = rect.y + delta_y;
|
|
|
|
window_move(win, x, y);
|
2012-09-22 15:10:59 +02:00
|
|
|
break;
|
2012-09-22 16:32:35 +02:00
|
|
|
case XCB_BUTTON_INDEX_3:
|
|
|
|
switch (frozen_pointer->corner) {
|
|
|
|
case TOP_LEFT:
|
|
|
|
x = rect.x + delta_x;
|
|
|
|
y = rect.y + delta_y;
|
|
|
|
w = rect.width - delta_x;
|
|
|
|
h = rect.height - delta_y;
|
|
|
|
break;
|
|
|
|
case TOP_RIGHT:
|
|
|
|
x = rect.x;
|
|
|
|
y = rect.y + delta_y;
|
|
|
|
w = rect.width + delta_x;
|
|
|
|
h = rect.height - delta_y;
|
|
|
|
break;
|
|
|
|
case BOTTOM_LEFT:
|
|
|
|
x = rect.x + delta_x;
|
|
|
|
y = rect.y;
|
|
|
|
w = rect.width - delta_x;
|
|
|
|
h = rect.height + delta_y;
|
|
|
|
break;
|
|
|
|
case BOTTOM_RIGHT:
|
|
|
|
x = rect.x;
|
|
|
|
y = rect.y;
|
|
|
|
w = rect.width + delta_x;
|
|
|
|
h = rect.height + delta_y;
|
|
|
|
break;
|
|
|
|
}
|
2012-09-22 17:17:18 +02:00
|
|
|
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};
|
2012-10-17 16:18:40 +02:00
|
|
|
window_draw_border(n, d->focus == n, mon == m);
|
2012-11-02 14:47:26 +01:00
|
|
|
break;
|
2012-09-22 15:10:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-06 11:36:16 +02:00
|
|
|
void button_release(void)
|
2012-09-22 15:10:59 +02:00
|
|
|
{
|
2012-10-06 11:36:16 +02:00
|
|
|
PUTS("button release");
|
2012-09-22 15:10:59 +02:00
|
|
|
|
|
|
|
xcb_ungrab_pointer(dpy, XCB_CURRENT_TIME);
|
2012-10-06 11:36:16 +02:00
|
|
|
update_floating_rectangle(frozen_pointer->node->client);
|
2012-11-08 18:24:17 +01:00
|
|
|
monitor_t *m = underlying_monitor(frozen_pointer->node->client);
|
|
|
|
if (m != NULL && m != frozen_pointer->monitor) {
|
|
|
|
transfer_node(frozen_pointer->monitor, frozen_pointer->desktop, m, m->desk, frozen_pointer->node);
|
|
|
|
select_monitor(m);
|
|
|
|
}
|
2012-09-22 15:10:59 +02:00
|
|
|
}
|
2012-09-22 12:16:46 +02:00
|
|
|
|
2012-10-18 11:09:17 +02:00
|
|
|
void handle_state(monitor_t *m, desktop_t *d, node_t *n, xcb_atom_t state, unsigned int action)
|
2012-09-11 22:48:26 +02:00
|
|
|
{
|
2012-09-16 14:16:58 +02:00
|
|
|
if (state == ewmh->_NET_WM_STATE_FULLSCREEN) {
|
2012-09-11 22:48:26 +02:00
|
|
|
bool fs = n->client->fullscreen;
|
|
|
|
if (action == XCB_EWMH_WM_STATE_TOGGLE
|
|
|
|
|| (fs && action == XCB_EWMH_WM_STATE_REMOVE)
|
2012-10-05 12:27:46 +02:00
|
|
|
|| (!fs && action == XCB_EWMH_WM_STATE_ADD)) {
|
2012-10-18 11:09:17 +02:00
|
|
|
toggle_fullscreen(m, n->client);
|
|
|
|
arrange(m, d);
|
2012-10-05 12:27:46 +02:00
|
|
|
}
|
2012-09-11 22:48:26 +02:00
|
|
|
}
|
|
|
|
}
|