update some property identifiers
This commit is contained in:
parent
2f6e191b3b
commit
b7adb5349e
10
src/client.c
10
src/client.c
@ -71,8 +71,8 @@ Client* wm_client_create(Wm *wm, Window w)
|
|||||||
c->next = NULL;
|
c->next = NULL;
|
||||||
c->prev = NULL;
|
c->prev = NULL;
|
||||||
c->window = w;
|
c->window = w;
|
||||||
c->m = wm->smon;
|
c->m = wm->selected_monitor;
|
||||||
c->ws = &wm->smon->workspaces[wm->smon->selws];
|
c->ws = &CURRENT_WS(wm);
|
||||||
c->hidden = true;
|
c->hidden = true;
|
||||||
c->is_floating = false;
|
c->is_floating = false;
|
||||||
c->name = NULL;
|
c->name = NULL;
|
||||||
@ -235,7 +235,7 @@ void wm_client_swap_dir(Wm* wm, Client *c, int dir)
|
|||||||
|
|
||||||
wm_treenode_swap(c->ws->tree, client_node, client_node1);
|
wm_treenode_swap(c->ws->tree, client_node, client_node1);
|
||||||
|
|
||||||
wm_layout(wm, wm->smon);
|
wm_layout(wm, wm->selected_monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wm_client_free(Wm *wm, Client *c)
|
void wm_client_free(Wm *wm, Client *c)
|
||||||
@ -399,7 +399,7 @@ ret:
|
|||||||
|
|
||||||
Client* wm_client_get_focused(Wm *wm)
|
Client* wm_client_get_focused(Wm *wm)
|
||||||
{
|
{
|
||||||
Workspace *ws = &wm->smon->workspaces[wm->smon->selws];
|
Workspace *ws = &CURRENT_WS(wm);
|
||||||
TreeNode *node = wm_treenode_ptr_find_focused_client_node(ws->tree);
|
TreeNode *node = wm_treenode_ptr_find_focused_client_node(ws->tree);
|
||||||
|
|
||||||
if (!node)
|
if (!node)
|
||||||
@ -440,7 +440,7 @@ void wm_monitor_clients_border(Wm *wm, Monitor *m)
|
|||||||
{
|
{
|
||||||
DEBUG_PRINT("%s\n", __func__)
|
DEBUG_PRINT("%s\n", __func__)
|
||||||
RETURN_IF_NULL(m);
|
RETURN_IF_NULL(m);
|
||||||
NodeArray *clients = wm_treenode_find_client_nodes(m->workspaces[m->selws].tree);
|
NodeArray *clients = wm_treenode_find_client_nodes(m->workspaces[m->selected_ws].tree);
|
||||||
if (clients->size == 0)
|
if (clients->size == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -50,7 +50,6 @@ struct Client {
|
|||||||
|
|
||||||
XWindowChanges wm_client_to_xwchanges(Client *c);
|
XWindowChanges wm_client_to_xwchanges(Client *c);
|
||||||
Client* wm_client_find(Wm* wm, Window w);
|
Client* wm_client_find(Wm* wm, Window w);
|
||||||
Client *wm_get_last_client(Wm *wm, Monitor m);
|
|
||||||
Client* wm_client_create(Wm *wm, Window w);
|
Client* wm_client_create(Wm *wm, Window w);
|
||||||
void wm_client_handle_window_types(Wm *wm, Client *c, XMapRequestEvent e);
|
void wm_client_handle_window_types(Wm *wm, Client *c, XMapRequestEvent e);
|
||||||
void wm_client_hide(Wm *wm, Client *c);
|
void wm_client_hide(Wm *wm, Client *c);
|
||||||
|
@ -207,14 +207,14 @@ UIntArray* wm_nonempty_workspaces_to_strptrarray(Wm *wm)
|
|||||||
_Static_assert(sizeof(uint64_t) == sizeof(uint64_t*), "static assert failed");
|
_Static_assert(sizeof(uint64_t) == sizeof(uint64_t*), "static assert failed");
|
||||||
UIntArray *ret = wm_uintarray_new();
|
UIntArray *ret = wm_uintarray_new();
|
||||||
|
|
||||||
for (size_t i = 0; i < wm->smon->wscount; i++) {
|
for (size_t i = 0; i < wm->selected_monitor->wscount; i++) {
|
||||||
TreeNode *node = wm->smon->workspaces[i].tree;
|
TreeNode *node = wm->selected_monitor->workspaces[i].tree;
|
||||||
if (!wm_treenode_is_empty(node) || (node->type == NODE_CLIENT && node->client)) {
|
if (!wm_treenode_is_empty(node) || (node->type == NODE_CLIENT && node->client)) {
|
||||||
WmWorkspaceToStrRet *ws_str_with_index = malloc(sizeof(WmWorkspaceToStrRet));
|
WmWorkspaceToStrRet *ws_str_with_index = malloc(sizeof(WmWorkspaceToStrRet));
|
||||||
assert(ws_str_with_index);
|
assert(ws_str_with_index);
|
||||||
*ws_str_with_index = (WmWorkspaceToStrRet) {
|
*ws_str_with_index = (WmWorkspaceToStrRet) {
|
||||||
.ws_index = i,
|
.ws_index = i,
|
||||||
.str = wm_treenode_to_str(wm->smon->workspaces[i].tree)
|
.str = wm_treenode_to_str(wm->selected_monitor->workspaces[i].tree)
|
||||||
};
|
};
|
||||||
wm_uintarray_push(ret, (uint64_t)ws_str_with_index);
|
wm_uintarray_push(ret, (uint64_t)ws_str_with_index);
|
||||||
}
|
}
|
||||||
|
54
src/wm.c
54
src/wm.c
@ -58,7 +58,7 @@ void wm_monitors_open_all(Wm *wm, Display *d)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
wm->wm_mc = count;
|
wm->monitors_len = count;
|
||||||
wm->monitors = malloc(count * sizeof(Monitor));
|
wm->monitors = malloc(count * sizeof(Monitor));
|
||||||
assert(wm->monitors);
|
assert(wm->monitors);
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ void wm_monitors_open_all(Wm *wm, Display *d)
|
|||||||
wm->monitors[i].wscount = 9;
|
wm->monitors[i].wscount = 9;
|
||||||
wm->monitors[i].workspaces = calloc(wm->monitors[i].wscount, sizeof(Workspace));
|
wm->monitors[i].workspaces = calloc(wm->monitors[i].wscount, sizeof(Workspace));
|
||||||
assert(wm->monitors[i].workspaces);
|
assert(wm->monitors[i].workspaces);
|
||||||
wm->monitors[i].selws = 0;
|
wm->monitors[i].selected_ws = 0;
|
||||||
|
|
||||||
for (size_t j = 0; j < wm->monitors[i].wscount; j++) {
|
for (size_t j = 0; j < wm->monitors[i].wscount; j++) {
|
||||||
Workspace *ws = &wm->monitors[i].workspaces[j];
|
Workspace *ws = &wm->monitors[i].workspaces[j];
|
||||||
@ -79,12 +79,10 @@ void wm_monitors_open_all(Wm *wm, Display *d)
|
|||||||
snprintf(ws->name, WM_WS_NAME_LEN, "%ld", j);
|
snprintf(ws->name, WM_WS_NAME_LEN, "%ld", j);
|
||||||
ws->tree = wm_treenode_new(NODE_CLIENT, NULL);
|
ws->tree = wm_treenode_new(NODE_CLIENT, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
wm->monitors[i].clients = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wm->smon = &wm->monitors[0];
|
wm->selected_monitor = &wm->monitors[0];
|
||||||
DEBUG_PRINT("smon width: %d\n", wm->smon->info.width);
|
DEBUG_PRINT("smon width: %d\n", wm->selected_monitor->info.width);
|
||||||
XFree(xsi);
|
XFree(xsi);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,7 +102,7 @@ void wm_set_supported_atoms(Wm *wm)
|
|||||||
{
|
{
|
||||||
XChangeProperty(wm->display, wm->root.window,
|
XChangeProperty(wm->display, wm->root.window,
|
||||||
XInternAtom(wm->display, "_NET_NUMBER_OF_DESKTOPS", False), XA_CARDINAL,
|
XInternAtom(wm->display, "_NET_NUMBER_OF_DESKTOPS", False), XA_CARDINAL,
|
||||||
32, PropModeReplace, (unsigned char *) &wm->smon->wscount, 1);
|
32, PropModeReplace, (unsigned char *) &wm->selected_monitor->wscount, 1);
|
||||||
|
|
||||||
char *desktop_names[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9"};
|
char *desktop_names[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9"};
|
||||||
|
|
||||||
@ -226,27 +224,27 @@ void wm_ws_tree_insert_client(Wm *wm, Workspace *ws, Client *client)
|
|||||||
|
|
||||||
void wm_switch_ws(Wm *wm, size_t ws)
|
void wm_switch_ws(Wm *wm, size_t ws)
|
||||||
{
|
{
|
||||||
if (ws > wm->smon->wscount)
|
if (ws > wm->selected_monitor->wscount)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int wscc = 0;
|
int wscc = 0;
|
||||||
Client *c;
|
Client *c;
|
||||||
|
|
||||||
DEBUG_PRINT("switching to ws %ld, clients:", ws);
|
DEBUG_PRINT("switching to ws %ld, clients:", ws);
|
||||||
wm_treenode_print(wm->smon->workspaces[ws].tree);
|
wm_treenode_print(wm->selected_monitor->workspaces[ws].tree);
|
||||||
|
|
||||||
NodeArray *current_ws_clients = wm_treenode_find_client_nodes(CURRENT_WS(wm).tree);
|
NodeArray *current_ws_clients = wm_treenode_find_client_nodes(CURRENT_WS(wm).tree);
|
||||||
|
|
||||||
for (size_t i = 0; i < current_ws_clients->size; i++) {
|
for (size_t i = 0; i < current_ws_clients->size; i++) {
|
||||||
c = ((TreeNode**)current_ws_clients->nodes)[i]->client;
|
c = ((TreeNode**)current_ws_clients->nodes)[i]->client;
|
||||||
assert(c);
|
assert(c);
|
||||||
if (c->ws->index == wm->smon->selws) {
|
if (c->ws->index == wm->selected_monitor->selected_ws) {
|
||||||
DEBUG_PRINT("wm_switch_ws hide client selws: %ld\n", c->ws->index)
|
DEBUG_PRINT("wm_switch_ws hide client selws: %ld\n", c->ws->index)
|
||||||
wm_client_hide(wm, c);
|
wm_client_hide(wm, c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wm->smon->selws = ws;
|
wm->selected_monitor->selected_ws = ws;
|
||||||
|
|
||||||
wm_client_set_atom(wm, &wm-> root, "_NET_CURRENT_DESKTOP",
|
wm_client_set_atom(wm, &wm-> root, "_NET_CURRENT_DESKTOP",
|
||||||
(unsigned char*) &(ws), XA_CARDINAL, 1);
|
(unsigned char*) &(ws), XA_CARDINAL, 1);
|
||||||
@ -255,7 +253,7 @@ void wm_switch_ws(Wm *wm, size_t ws)
|
|||||||
|
|
||||||
for (size_t i = 0; i < switch_ws_clients->size; i++) {
|
for (size_t i = 0; i < switch_ws_clients->size; i++) {
|
||||||
c = ((TreeNode**)switch_ws_clients->nodes)[i]->client;
|
c = ((TreeNode**)switch_ws_clients->nodes)[i]->client;
|
||||||
if (c->ws->index == wm->smon->selws) {
|
if (c->ws->index == wm->selected_monitor->selected_ws) {
|
||||||
wscc++;
|
wscc++;
|
||||||
wm_client_show(wm, c);
|
wm_client_show(wm, c);
|
||||||
}
|
}
|
||||||
@ -266,7 +264,7 @@ void wm_switch_ws(Wm *wm, size_t ws)
|
|||||||
if (CURRENT_WS(wm).focused_node)
|
if (CURRENT_WS(wm).focused_node)
|
||||||
wm_client_focus(wm, CURRENT_WS(wm).focused_node->client);
|
wm_client_focus(wm, CURRENT_WS(wm).focused_node->client);
|
||||||
|
|
||||||
wm_layout(wm, wm->smon);
|
wm_layout(wm, wm->selected_monitor);
|
||||||
|
|
||||||
wm_nodearray_free(current_ws_clients);
|
wm_nodearray_free(current_ws_clients);
|
||||||
wm_nodearray_free(switch_ws_clients);
|
wm_nodearray_free(switch_ws_clients);
|
||||||
@ -274,15 +272,15 @@ void wm_switch_ws(Wm *wm, size_t ws)
|
|||||||
|
|
||||||
void wm_move_client_ws(Wm *wm, int ws)
|
void wm_move_client_ws(Wm *wm, int ws)
|
||||||
{
|
{
|
||||||
if (ws > wm->smon->wscount)
|
if (ws > wm->selected_monitor->wscount)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TreeNode *focused_node = wm_treenode_ptr_find_focused_client_node(CURRENT_WS(wm).tree);
|
TreeNode *focused_node = wm_treenode_ptr_find_focused_client_node(CURRENT_WS(wm).tree);
|
||||||
Client *moved_client = focused_node->client;
|
Client *moved_client = focused_node->client;
|
||||||
|
|
||||||
wm_ws_tree_insert_client(wm, &wm->smon->workspaces[ws], moved_client);
|
wm_ws_tree_insert_client(wm, &wm->selected_monitor->workspaces[ws], moved_client);
|
||||||
wm_client_hide(wm, moved_client);
|
wm_client_hide(wm, moved_client);
|
||||||
moved_client->ws = &wm->smon->workspaces[ws];
|
moved_client->ws = &wm->selected_monitor->workspaces[ws];
|
||||||
wm_client_set_atom(wm, moved_client, "_NET_WM_DESKTOP",
|
wm_client_set_atom(wm, moved_client, "_NET_WM_DESKTOP",
|
||||||
(unsigned char*)&moved_client->ws->index, XA_CARDINAL,
|
(unsigned char*)&moved_client->ws->index, XA_CARDINAL,
|
||||||
CURRENT_WS(wm).index);
|
CURRENT_WS(wm).index);
|
||||||
@ -290,9 +288,9 @@ void wm_move_client_ws(Wm *wm, int ws)
|
|||||||
wm_treenode_remove_node(wm, CURRENT_WS(wm).tree, focused_node);
|
wm_treenode_remove_node(wm, CURRENT_WS(wm).tree, focused_node);
|
||||||
CURRENT_WS(wm).focused_node = NULL;
|
CURRENT_WS(wm).focused_node = NULL;
|
||||||
|
|
||||||
char *str = wm_treenode_to_str(wm->smon->workspaces[ws].tree);
|
char *str = wm_treenode_to_str(wm->selected_monitor->workspaces[ws].tree);
|
||||||
DEBUG_PRINT("move target ws tree: %s\n", str);
|
DEBUG_PRINT("move target ws tree: %s\n", str);
|
||||||
wm_layout(wm, wm->smon);
|
wm_layout(wm, wm->selected_monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wm_layout(Wm *wm, Monitor *m)
|
void wm_layout(Wm *wm, Monitor *m)
|
||||||
@ -302,7 +300,7 @@ void wm_layout(Wm *wm, Monitor *m)
|
|||||||
|
|
||||||
DEBUG_PRINT("%s\n", __func__);
|
DEBUG_PRINT("%s\n", __func__);
|
||||||
|
|
||||||
Workspace *ws = &m->workspaces[m->selws];
|
Workspace *ws = &m->workspaces[m->selected_ws];
|
||||||
NodeArray *clients = wm_treenode_find_client_nodes(ws->tree);
|
NodeArray *clients = wm_treenode_find_client_nodes(ws->tree);
|
||||||
if (clients->size == 0)
|
if (clients->size == 0)
|
||||||
goto ret;
|
goto ret;
|
||||||
@ -335,20 +333,6 @@ ret:
|
|||||||
wm_nodearray_free(clients);
|
wm_nodearray_free(clients);
|
||||||
}
|
}
|
||||||
|
|
||||||
Client *wm_get_last_client(Wm *wm, Monitor m)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
Client *c = m.clients;
|
|
||||||
|
|
||||||
if (c == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
while (c->next != NULL)
|
|
||||||
c = c->next;
|
|
||||||
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wm_mainloop(Wm *wm)
|
void wm_mainloop(Wm *wm)
|
||||||
{
|
{
|
||||||
struct sockaddr s;
|
struct sockaddr s;
|
||||||
@ -480,7 +464,7 @@ void wm_exit(Wm *wm)
|
|||||||
// TODO: perhaps add created clients to a PtrArray field in workspace.
|
// TODO: perhaps add created clients to a PtrArray field in workspace.
|
||||||
// would reduce number of calls to wm_treenode_find_client_nodes_ptr
|
// would reduce number of calls to wm_treenode_find_client_nodes_ptr
|
||||||
|
|
||||||
for (size_t i = 0; i < wm->wm_mc; i++) {
|
for (size_t i = 0; i < wm->monitors_len; i++) {
|
||||||
for (size_t j = 0; j < wm->monitors[i].wscount; j++) {
|
for (size_t j = 0; j < wm->monitors[i].wscount; j++) {
|
||||||
NodeArray *clients = wm_treenode_find_client_nodes(
|
NodeArray *clients = wm_treenode_find_client_nodes(
|
||||||
wm->monitors[i].workspaces[j].tree);
|
wm->monitors[i].workspaces[j].tree);
|
||||||
@ -637,7 +621,7 @@ void wm_kb_switch_split_mode(Wm *wm, Arg *args)
|
|||||||
|
|
||||||
WM_LOG_STATE_START(wm);
|
WM_LOG_STATE_START(wm);
|
||||||
|
|
||||||
wm->smon->workspaces[wm->smon->selws].split = args->i;
|
wm->selected_monitor->workspaces[wm->selected_monitor->selected_ws].split = args->i;
|
||||||
|
|
||||||
WM_LOG_STATE_END(wm);
|
WM_LOG_STATE_END(wm);
|
||||||
}
|
}
|
||||||
|
21
src/wm.h
21
src/wm.h
@ -63,7 +63,7 @@ if (c == NULL) \
|
|||||||
|
|
||||||
#define WM_WS_NAME_LEN 64
|
#define WM_WS_NAME_LEN 64
|
||||||
|
|
||||||
#define CURRENT_WS(wm) (wm)->smon->workspaces[(wm)->smon->selws]
|
#define CURRENT_WS(wm) (wm)->selected_monitor->workspaces[(wm)->selected_monitor->selected_ws]
|
||||||
|
|
||||||
#define WM_PREFIX_LEN 4096
|
#define WM_PREFIX_LEN 4096
|
||||||
|
|
||||||
@ -99,9 +99,8 @@ typedef enum {
|
|||||||
struct Monitor {
|
struct Monitor {
|
||||||
Display *display;
|
Display *display;
|
||||||
XineramaScreenInfo info;
|
XineramaScreenInfo info;
|
||||||
Client *clients;
|
|
||||||
Workspace *workspaces;
|
Workspace *workspaces;
|
||||||
size_t selws;
|
size_t selected_ws;
|
||||||
size_t wscount;
|
size_t wscount;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -115,27 +114,19 @@ struct Workspace {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct Wm {
|
struct Wm {
|
||||||
// TODO INIT
|
|
||||||
Display *display;
|
Display *display;
|
||||||
Monitor *monitors;
|
Monitor *monitors;
|
||||||
Monitor *smon;
|
size_t monitors_len;
|
||||||
bool running;
|
Monitor *selected_monitor;
|
||||||
int wm_mc;
|
|
||||||
bool other_wm;
|
|
||||||
Client root;
|
Client root;
|
||||||
Window dock;
|
Window dock;
|
||||||
|
|
||||||
Client *focused_client;
|
Client *focused_client;
|
||||||
|
|
||||||
// float cfg_ms_p;
|
|
||||||
// char *cfg_border_col;
|
|
||||||
// char *cfg_focused_border_col;
|
|
||||||
// unsigned char cfg_border_width;
|
|
||||||
// Keybind *cfg_keybinds;
|
|
||||||
// int cfg_kb_count;
|
|
||||||
// bool cfg_focus_on_motion;
|
|
||||||
Config config;
|
Config config;
|
||||||
|
|
||||||
|
bool running;
|
||||||
bool log_after_maprequest;
|
bool log_after_maprequest;
|
||||||
int socket_fd;
|
int socket_fd;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user