add workspace struct

This commit is contained in:
Akos Horvath 2023-05-26 17:08:15 +02:00
parent 71ee3fd10c
commit 88a788d5f4
2 changed files with 27 additions and 11 deletions

20
wm.c
View File

@ -32,6 +32,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <unistd.h>
#include "handler.h"
#include "client.h"
#include "util.h"
Monitor wm_monitor_open(Display *d, XineramaScreenInfo info)
{
@ -60,12 +61,18 @@ void wm_monitors_open_all(Wm *wm, Display *d)
wm->monitors[i] = wm_monitor_open(d, xsi[i]);
//TODO: cfg
wm->monitors[i].wscount = 9;
wm->monitors[i].wss = malloc(wm->monitors[i].wscount*sizeof(int));
memset(wm->monitors[i].wss, 0, wm->monitors[i].wscount);
wm->monitors[i].selws = wm->monitors[i].wss[0];
wm->monitors[i].workspaces = calloc(wm->monitors[i].wscount, sizeof(Workspace));
wm->monitors[i].selws = 0;
for (int j = 0; j < wm->monitors[i].wscount; j++)
wm->monitors[i].wss[i] = j;
for (int j = 0; j < wm->monitors[i].wscount; j++) {
Workspace *ws = &wm->monitors[i].workspaces[i];
ws->index = j;
ws->monitor = &wm->monitors[i];
// TODO config
snprintf(ws->name, WM_WS_NAME_LEN, "%d", j);
wm_treenode_init(&ws->tree, NODE_CLIENT, NULL);
}
//wm->monitors[i].clients = &wm->root;
wm->monitors[i].clients = NULL;
@ -148,9 +155,6 @@ void wm_switch_ws(Wm *wm, int ws)
wm_client_set_atom(wm, &wm-> root, "_NET_CURRENT_DESKTOP",
(unsigned char*) &(ws), XA_CARDINAL, 1);
// XChangeProperty(wm->display, root.window,
// XInternAtom(wm->display, "_NET_CURRENT_DESKTOP", False), XA_CARDINAL,
// 32, PropModeReplace, (unsigned char *) &(xasws), 1);
for (c = wm->smon->clients; c; c = c->next) {
if (c->ws == wm->smon->selws) {

18
wm.h
View File

@ -36,6 +36,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <sys/socket.h>
#include <sys/un.h>
#include "util.h"
// TODO: when only 1 window on ws it is not focused
// TODO: dont draw border on not normal windows, floating dialog window,
// window type/name/... atom member variable on Client struct
@ -55,7 +57,10 @@ if (c == NULL) \
#define DEBUG_PRINT(fmt, ...) \
do { if (DEBUG) fprintf(stderr, fmt, ##__VA_ARGS__); } while (0);
#define WM_WS_NAME_LEN 64
typedef struct Client Client;
typedef struct Workspace Workspace;
typedef struct Monitor Monitor;
typedef struct Keybind Keybind;
typedef struct Arg Arg;
@ -72,9 +77,9 @@ struct Monitor {
Display *display;
XineramaScreenInfo info;
Client *clients;
int *wss;
int selws;
int wscount;
Workspace *workspaces;
size_t selws;
size_t wscount;
};
struct Client {
@ -95,6 +100,13 @@ struct Client {
// will propably need a tree.
};
struct Workspace {
TreeNode tree;
size_t index;
char name[WM_WS_NAME_LEN];
Monitor *monitor;
};
struct Arg {
int i;
unsigned int ui;