处理移动鼠标事件
This commit is contained in:
28
src/main.c
28
src/main.c
@@ -39,6 +39,7 @@ static void key_press(key_press_event_t *event);
|
||||
static void configure_request(configure_request_event_t *event);
|
||||
static void map_request(map_request_event_t *event);
|
||||
static void unmap_notify(unmap_notify_event_t *event);
|
||||
static void motion_notify(motion_notify_event_t *event);
|
||||
static void manage_window(xcb_window_t window);
|
||||
static void unmanage_client(client_t *client);
|
||||
static void update_client_name(client_t *client);
|
||||
@@ -52,6 +53,7 @@ static void arrange(monitor_t *monitor);
|
||||
static void show_hide_client(client_t *client);
|
||||
static void restack(monitor_t *monitor);
|
||||
static void focus(client_t *client);
|
||||
static void unfocus(client_t *client, bool set_focus);
|
||||
static void apply_monitor_layout(monitor_t *monitor);
|
||||
static client_t *get_client_of_window(xcb_window_t window);
|
||||
static gboolean handle_xcb_event(GIOChannel *channel, GIOCondition condition,
|
||||
@@ -457,6 +459,7 @@ void xcb_event_handler(generic_event_t *event, void *user_data) {
|
||||
EVENT(EVENT_TYPE_CONFIGURE_REQUEST, configure_request);
|
||||
EVENT(EVENT_TYPE_MAP_REQUEST, map_request);
|
||||
EVENT(EVENT_TYPE_UNMAP_NOTIFY, unmap_notify);
|
||||
EVENT(EVENT_TYPE_MOTION_NOTIFY, motion_notify);
|
||||
|
||||
#undef EVENT
|
||||
|
||||
@@ -505,6 +508,19 @@ void unmap_notify(unmap_notify_event_t *event) {
|
||||
}
|
||||
}
|
||||
|
||||
void motion_notify(motion_notify_event_t *event) {
|
||||
if (event->window != get_root_window()) return;
|
||||
|
||||
static monitor_t *mon = NULL;
|
||||
monitor_t *m = rect_to_monitor(monitors, event->root_x, event->root_y, 1, 1);
|
||||
if (mon && m != mon) {
|
||||
unfocus(current_monitor->selected_client, true);
|
||||
current_monitor = m;
|
||||
focus(NULL);
|
||||
}
|
||||
mon = m;
|
||||
}
|
||||
|
||||
void manage_window(xcb_window_t window) {
|
||||
window_geometry_t *geometry = get_window_geometry(window);
|
||||
client_t *c = ecalloc(1, sizeof(client_t));
|
||||
@@ -660,12 +676,22 @@ void arrange(monitor_t *monitor) {
|
||||
}
|
||||
}
|
||||
|
||||
void restack(monitor_t *monitor) { /* TODO: */ draw_monitor_bar(monitor); }
|
||||
void restack(monitor_t *monitor) {
|
||||
draw_monitor_bar(monitor);
|
||||
/* TODO: */
|
||||
}
|
||||
void focus(client_t *client) {
|
||||
/* TODO: */
|
||||
current_monitor->selected_client = client;
|
||||
draw_all_monitor_bars();
|
||||
}
|
||||
void unfocus(client_t *client, bool set_focus) {
|
||||
if (!client) return;
|
||||
change_window_border_color(client->window, color_set->border_color.argb);
|
||||
if (set_focus) {
|
||||
/* TODO: */
|
||||
}
|
||||
}
|
||||
|
||||
void show_hide_client(client_t *client) {
|
||||
if (!client) return;
|
||||
|
||||
Reference in New Issue
Block a user