refactor: 将 APP_NAME 宏从 CMake 配置文件生成改为静态头文件
This commit is contained in:
@@ -91,9 +91,3 @@ target_link_libraries(${APP_NAME}
|
|||||||
PRIVATE m
|
PRIVATE m
|
||||||
PRIVATE ${deps_LIBRARIES}
|
PRIVATE ${deps_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
|
||||||
configure_file("${SOURCE_DIR}/app.h.in"
|
|
||||||
"${BUILD_DIR}/app.h"
|
|
||||||
ESCAPE_QUOTES
|
|
||||||
@ONLY
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#define APP_NAME "@APP_NAME@"
|
|
||||||
|
|
||||||
#cmakedefine HAS_EXECINFO
|
|
||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "backend/output_utils.h"
|
#include "backend/output_utils.h"
|
||||||
#include "backend/x11/window.h"
|
#include "backend/x11/window.h"
|
||||||
|
#include "base/app.h"
|
||||||
#include "base/array.h"
|
#include "base/array.h"
|
||||||
#include "base/log.h"
|
#include "base/log.h"
|
||||||
#include "base/macros.h"
|
#include "base/macros.h"
|
||||||
@@ -72,13 +73,12 @@ static void create_wm_check_window(backend_t *backend) {
|
|||||||
xcb_create_window(conn, depth, win, root, -1, -1, 1, 1, 0, _c, v, m, p);
|
xcb_create_window(conn, depth, win, root, -1, -1, 1, 1, 0, _c, v, m, p);
|
||||||
window_set_class_instance(conn, win);
|
window_set_class_instance(conn, win);
|
||||||
|
|
||||||
#define NAME "zdwm"
|
window_set_name_static(conn, win, APP_NAME);
|
||||||
window_set_name_static(conn, win, NAME);
|
|
||||||
uint8_t mode = XCB_PROP_MODE_REPLACE;
|
uint8_t mode = XCB_PROP_MODE_REPLACE;
|
||||||
xcb_atom_t prop = backend->atoms._NET_WM_NAME;
|
xcb_atom_t prop = backend->atoms._NET_WM_NAME;
|
||||||
xcb_atom_t type = backend->atoms.UTF8_STRING;
|
xcb_atom_t type = backend->atoms.UTF8_STRING;
|
||||||
xcb_change_property(conn, mode, win, prop, type, 8, sizeof(NAME) - 1, NAME);
|
auto data_len = sizeof(APP_NAME) - 1;
|
||||||
#undef NAME
|
xcb_change_property(conn, mode, win, prop, type, 8, data_len, APP_NAME);
|
||||||
|
|
||||||
prop = backend->atoms._NET_SUPPORTING_WM_CHECK;
|
prop = backend->atoms._NET_SUPPORTING_WM_CHECK;
|
||||||
type = XCB_ATOM_WINDOW;
|
type = XCB_ATOM_WINDOW;
|
||||||
@@ -109,7 +109,7 @@ static void create_no_focus_window(backend_t *backend) {
|
|||||||
};
|
};
|
||||||
xcb_create_window_aux(conn, d, win, root, -1, -1, 1, 1, 0, _c, v, m, &p);
|
xcb_create_window_aux(conn, d, win, root, -1, -1, 1, 1, 0, _c, v, m, &p);
|
||||||
window_set_class_instance(conn, win);
|
window_set_class_instance(conn, win);
|
||||||
window_set_name_static(conn, win, "zdwm no input window");
|
window_set_name_static(conn, win, APP_NAME " no input window");
|
||||||
xcb_map_window(conn, win);
|
xcb_map_window(conn, win);
|
||||||
|
|
||||||
backend->window_no_focus = win;
|
backend->window_no_focus = win;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include <xcb/xcb_icccm.h>
|
#include <xcb/xcb_icccm.h>
|
||||||
#include <xcb/xproto.h>
|
#include <xcb/xproto.h>
|
||||||
|
|
||||||
|
#include "base/app.h"
|
||||||
#include "core/backend.h"
|
#include "core/backend.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
@@ -73,7 +74,7 @@ window_state_t atom_to_window_state(const atoms_t *atoms, xcb_atom_t atom);
|
|||||||
xcb_icccm_set_wm_name(conn, win, XCB_ATOM_STRING, 8, sizeof(name) - 1, name)
|
xcb_icccm_set_wm_name(conn, win, XCB_ATOM_STRING, 8, sizeof(name) - 1, name)
|
||||||
|
|
||||||
#define window_set_class_instance(conn, win) \
|
#define window_set_class_instance(conn, win) \
|
||||||
window_set_class_instance_static(conn, win, "zdwm", "zdwm")
|
window_set_class_instance_static(conn, win, APP_NAME, APP_NAME)
|
||||||
#define window_set_class_instance_static(conn, win, instance, class) \
|
#define window_set_class_instance_static(conn, win, instance, class) \
|
||||||
_window_set_class_instance_static(conn, win, instance "\0" class)
|
_window_set_class_instance_static(conn, win, instance "\0" class)
|
||||||
#define _window_set_class_instance_static(conn, win, instance_class) \
|
#define _window_set_class_instance_static(conn, win, instance_class) \
|
||||||
|
|||||||
3
src/base/app.h
Normal file
3
src/base/app.h
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define APP_NAME "zdwm"
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include "app.h"
|
#include "base/app.h"
|
||||||
|
|
||||||
const char *current_time_str(void) {
|
const char *current_time_str(void) {
|
||||||
static char buffer[25];
|
static char buffer[25];
|
||||||
|
|||||||
Reference in New Issue
Block a user