102 lines
2.5 KiB
C
102 lines
2.5 KiB
C
#ifndef X_KUTU_H
|
|
#define X_KUTU_H
|
|
|
|
// Standard headers
|
|
#include <err.h>
|
|
#include <stdint.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <unistd.h>
|
|
|
|
// XCB headers
|
|
#include <xcb/xcb.h>
|
|
#include <xcb/xcb_icccm.h>
|
|
|
|
// Macro to clean modifier masks
|
|
#define CLEANMASK(m) ((m & ~0x80))
|
|
|
|
// Definitions for modifier keys
|
|
#define SUPER XCB_MOD_MASK_4
|
|
#define ALT XCB_MOD_MASK_1
|
|
#define CTRL XCB_MOD_MASK_CONTROL
|
|
#define SHIFT XCB_MOD_MASK_SHIFT
|
|
|
|
// Change this to change the modifier key you want to use
|
|
#define MOD SUPER
|
|
|
|
// Forward declarations of global variables
|
|
extern xcb_connection_t *conn;
|
|
extern xcb_screen_t *scr;
|
|
extern xcb_window_t focuswin;
|
|
|
|
// Geometry structure for rectangles and positions
|
|
typedef struct Geometry {
|
|
int16_t x;
|
|
int16_t y;
|
|
uint16_t width;
|
|
uint16_t height;
|
|
} Geometry;
|
|
|
|
typedef struct PointerInfo {
|
|
int16_t x;
|
|
int16_t y;
|
|
uint32_t window;
|
|
} PointerInfo;
|
|
|
|
// Event structure to represent various X events
|
|
typedef struct Event {
|
|
int32_t type;
|
|
uint32_t window;
|
|
int8_t override_redirect;
|
|
uint32_t btn;
|
|
int32_t x;
|
|
int32_t y;
|
|
uint32_t height;
|
|
uint32_t width;
|
|
uint32_t state;
|
|
int8_t is_root;
|
|
} Event;
|
|
|
|
// Function prototypes
|
|
extern void flush(void);
|
|
extern int deploy(void);
|
|
extern void cleanup(void);
|
|
|
|
extern void add_keybind(int key, int mod);
|
|
extern void add_mousebind(int button, int mod);
|
|
|
|
extern xcb_window_t get_focus(void);
|
|
extern xcb_window_t get_root(void);
|
|
|
|
extern void focus(xcb_window_t win);
|
|
extern void subscribe(xcb_window_t win);
|
|
extern void kill(xcb_window_t window);
|
|
extern void destroy(xcb_window_t win);
|
|
extern void show(xcb_window_t window);
|
|
extern void hide(xcb_window_t window);
|
|
extern void send_to_top(xcb_window_t win);
|
|
|
|
extern void get_geometry(xcb_window_t win, Geometry *out);
|
|
extern void get_screen(Geometry *out);
|
|
extern void get_pointer(PointerInfo *out);
|
|
|
|
extern void warp_pointer(xcb_window_t win, int x, int y);
|
|
extern void move_window(xcb_window_t win, int x, int y);
|
|
extern void resize_window(xcb_window_t win, int width, int height);
|
|
|
|
extern xcb_size_hints_t get_wm_n_hints(xcb_window_t win);
|
|
extern xcb_icccm_wm_hints_t get_wm_hints(xcb_window_t win);
|
|
extern char *get_wm_name(xcb_window_t win);
|
|
extern uint8_t get_wm_transient_for(xcb_window_t win);
|
|
extern void set_wm_state(xcb_window_t win, int state);
|
|
|
|
extern xcb_window_t draw_rectangle(int x, int y, int width, int height,
|
|
uint32_t color);
|
|
|
|
extern void grab_pointer(xcb_window_t win);
|
|
extern void ungrab_pointer(void);
|
|
|
|
extern int next_event(Event *out);
|
|
|
|
#endif // X_KUTU_H
|