focus fixes, add focus on motion, add structs and functions for keyboard config, cleaned up keypress_handler

This commit is contained in:
2022-08-18 17:34:02 +02:00
parent ca69dc89d1
commit 30cf32f830
2 changed files with 346 additions and 227 deletions

49
wm.h
View File

@ -14,12 +14,12 @@
#include <sys/socket.h>
#include <sys/un.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
// TODO: get_atom probably not working correctly
// TODO: important: do not lay out non-regular windows
// TODO: important: code cleanliness, ewmh!!
// TODO: config command line utility(sockets), avoid global vars
// TODO: config command line utility(sockets), maybe avoid global vars
#define RETURN_IF_NULL(c) \
if (c == NULL) \
@ -35,6 +35,8 @@ if (c == NULL) \
typedef struct Client Client;
typedef struct Monitor Monitor;
typedef struct Keybind Keybind;
typedef struct Arg Arg;
enum Direction {
UP,
@ -63,11 +65,30 @@ struct Client {
Window window;
Client *prev;
Client *next;
char *name;
bool has_border;
bool is_floating;
// linked list is not sufficent for manual tiling.
// will propably need a tree.
};
struct Arg {
int i;
unsigned int ui;
Client *c;
char* s;
char **sl;
int count;
};
struct Keybind {
unsigned int mask;
KeySym keysym;
void (*func)(Arg*);
Arg args;
};
static Display *wm_display;
static Monitor *wm_monitors;
static Monitor *wm_smon;
@ -75,11 +96,17 @@ static int wm_mc;
static bool wm_other_wm;
static Client wm_root;
static Window wm_dock = -1;
/* global configuration variables */
// TODO: active layout not working
static void (*wm_active_layout)(Monitor*);
static float wm_ms_p;
static unsigned int wm_border_col = 0x222222;
static unsigned int wm_focused_border_col = 0x444444;
static unsigned char wm_border_width = 2;
static float wm_cfg_ms_p = 0.5;
static char wm_cfg_border_col[] = "#222222";
static char wm_cfg_focused_border_col[] = "#444444";
static unsigned char wm_cfg_border_width = 2;
static Keybind *wm_cfg_keybinds;
static int wm_cfg_kb_count;
static bool wm_cfg_focus_on_motion = true;
static int wm_socket_fd;
@ -92,6 +119,7 @@ void wm_configure_handler(XConfigureRequestEvent e);
void wm_keyrelease_handler(XKeyReleasedEvent e);
void wm_keypress_handler(XKeyPressedEvent e);
void wm_maprequest_handler(XMapRequestEvent e);
void wm_motion_handler(XMotionEvent e);
Monitor wm_monitor_open(Display *d, XineramaScreenInfo info);
void wm_monitors_open_all(Display *d);
@ -125,11 +153,20 @@ bool wm_window_is_dock(Window w);
XWindowChanges wm_client_to_xwchanges(Client c);
Client* wm_client_find(Window w);
void wm_spawn(char **str);
void wm_switch_ws(int ws);
void wm_mainloop();
void wm_init();
void wm_grab_keys();
void wm_kb_spawn(Arg *args);
void wm_kb_kill(Arg *args);
void wm_kb_switch_ws(Arg *args);
void wm_kb_focus_dir(Arg *args);
void wm_keybinds_init_def();
struct sockaddr wm_socket_init();
void wm_socket_cleanup();
void wm_settings_message_parse(char *c, int len);