处理 property_notify 事件
This commit is contained in:
51
src/main.c
51
src/main.c
@@ -10,6 +10,7 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <wordexp.h>
|
||||
#include <xcb/xproto.h>
|
||||
|
||||
#include "action.h"
|
||||
#include "config.h"
|
||||
@@ -44,6 +45,7 @@ static void expose(expose_event_t *event);
|
||||
static void motion_notify(motion_notify_event_t *event);
|
||||
static void enter_notify(enter_notify_event_t *event);
|
||||
static void focus_in(focus_in_event_t *event);
|
||||
static void property_notify(property_notify_event_t *event);
|
||||
static void manage_window(xcb_window_t window);
|
||||
static void unmanage_client(client_t *client, bool destroyed);
|
||||
static void update_client_list(void);
|
||||
@@ -473,6 +475,7 @@ void xcb_event_handler(generic_event_t *event, void *user_data) {
|
||||
EVENT(EVENT_TYPE_MOTION_NOTIFY, motion_notify);
|
||||
EVENT(EVENT_TYPE_ENTER_NOTIFY, enter_notify);
|
||||
EVENT(EVENT_TYPE_FOCUS_IN, focus_in);
|
||||
EVENT(EVENT_TYPE_PROPERTY_NOTIFY, property_notify);
|
||||
|
||||
#undef EVENT
|
||||
|
||||
@@ -579,6 +582,32 @@ void focus_in(focus_in_event_t *event) {
|
||||
}
|
||||
}
|
||||
|
||||
void property_notify(property_notify_event_t *event) {
|
||||
if (event->state == property_delete) return;
|
||||
|
||||
client_t *c = get_client_of_window(event->window);
|
||||
if (!c) return;
|
||||
switch (event->xcb_atom) {
|
||||
case XCB_ATOM_WM_TRANSIENT_FOR: {
|
||||
xcb_window_t transient_for;
|
||||
if (!c->floating &&
|
||||
((transient_for = get_transient_window_for(event->window)) !=
|
||||
WINDOW_NONE) &&
|
||||
(c->floating = (get_client_of_window(transient_for) != NULL))) {
|
||||
arrange(c->monitor);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (event->xcb_atom == XCB_ATOM_WM_NAME ||
|
||||
event->xcb_atom == get_xcb_atom(atom_net_wm_name)) {
|
||||
update_client_name(c);
|
||||
if (c->tags & c->monitor->selected_tags) draw_monitor_bar(c->monitor);
|
||||
}
|
||||
}
|
||||
|
||||
void manage_window(xcb_window_t window) {
|
||||
window_geometry_t *geometry = get_window_geometry(window);
|
||||
client_t *c = ecalloc(1, sizeof(client_t));
|
||||
@@ -874,17 +903,6 @@ gboolean handle_xcb_event(GIOChannel *channel, GIOCondition condition,
|
||||
}
|
||||
|
||||
void cleanup(void) {
|
||||
clean_pango_context();
|
||||
|
||||
free_wallpaper_config(wallpaper_config);
|
||||
wallpaper_config = NULL;
|
||||
|
||||
free(color_set);
|
||||
color_set = NULL;
|
||||
|
||||
free(font_family);
|
||||
font_family = NULL;
|
||||
|
||||
monitor_t *m = monitors;
|
||||
client_t *c = m->clients;
|
||||
while (m) {
|
||||
@@ -902,6 +920,17 @@ void cleanup(void) {
|
||||
}
|
||||
monitors = NULL;
|
||||
|
||||
clean_pango_context();
|
||||
|
||||
free_wallpaper_config(wallpaper_config);
|
||||
wallpaper_config = NULL;
|
||||
|
||||
free(color_set);
|
||||
color_set = NULL;
|
||||
|
||||
free(font_family);
|
||||
font_family = NULL;
|
||||
|
||||
destroy_event_adapter(adapter);
|
||||
adapter = NULL;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user