添加布局算法并在新建窗口时应用规则
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "window.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -34,6 +35,28 @@ void set_window_class_instance(xcb_window_t window, const char *class,
|
||||
free(str);
|
||||
}
|
||||
|
||||
static char broken[] = "broken";
|
||||
|
||||
void get_window_class_instance(xcb_window_t window,
|
||||
window_class_instance_t *class_instance) {
|
||||
xcb_get_property_cookie_t cookie = xcb_icccm_get_wm_class(conn, window);
|
||||
xcb_icccm_get_wm_class_reply_t prop;
|
||||
const char *class = NULL;
|
||||
const char *instance = NULL;
|
||||
if (xcb_icccm_get_wm_class_reply(conn, cookie, &prop, NULL)) {
|
||||
class = prop.class_name;
|
||||
instance = prop.instance_name;
|
||||
} else {
|
||||
class = broken;
|
||||
instance = broken;
|
||||
}
|
||||
|
||||
strncpy(class_instance->class, class, LENGTH(class_instance->class));
|
||||
strncpy(class_instance->instance, instance, LENGTH(class_instance->instance));
|
||||
|
||||
xcb_icccm_get_wm_class_reply_wipe(&prop);
|
||||
}
|
||||
|
||||
typedef struct visual_t {
|
||||
uint8_t depth;
|
||||
xcb_visualtype_t *visual;
|
||||
@@ -242,9 +265,8 @@ char *get_window_name(xcb_window_t window) {
|
||||
}
|
||||
|
||||
{
|
||||
const char *broken = "broken";
|
||||
char *name = ecalloc(strlen(broken) + 1, sizeof(char));
|
||||
strncpy(name, broken, strlen(broken));
|
||||
char *name = ecalloc(LENGTH(broken), sizeof(char));
|
||||
strncpy(name, broken, LENGTH(broken));
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user