From fd82b9070df1b6f82d3484cd6c7d0a9531360dc8 Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Mon, 6 Apr 2015 23:46:00 +0000 Subject: [PATCH] Split x11 into xlib and xcb systems --- makefile | 8 ++- sys-xcb.c | 114 ++++++++++++++++++++++++++++++++++++++++ sys-x11.c => sys-xlib.c | 0 3 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 sys-xcb.c rename sys-x11.c => sys-xlib.c (100%) diff --git a/makefile b/makefile index 9eb5924..d556e14 100644 --- a/makefile +++ b/makefile @@ -10,7 +10,13 @@ CFLAGS ?= -g -Wall PREFIX ?= /usr/local MANPREFIX ?= ${PREFIX}/share/man -ifeq ($(SYS),x11) +ifeq ($(SYS),xcb) +GCC ?= gcc +PROG ?= wmpus +LDFLAGS += -lxcb +endif + +ifeq ($(SYS),xlib) GCC ?= gcc PROG ?= wmpus LDFLAGS += -lX11 -lXinerama diff --git a/sys-xcb.c b/sys-xcb.c new file mode 100644 index 0000000..87dcb01 --- /dev/null +++ b/sys-xcb.c @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2015 Andy Spencer + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + */ + +#define _GNU_SOURCE +#include +#include + +#include + +#include "util.h" +#include "conf.h" +#include "types.h" +#include "sys.h" +#include "wm.h" + +/* Configuration */ +static int border = 2; +static int stack = 25; +static int no_capture = 0; + +/* Internal structures */ +struct win_sys { +}; + +/* Global data */ +static xcb_connection_t *conn; +static list_t *screens; + +/******************** + * System functions * + ********************/ +void sys_move(win_t *win, int x, int y, int w, int h) +{ + printf("sys_move: %p - %dx%d @ %d,%d\n", + win, w, h, x, y); +} + +void sys_raise(win_t *win) +{ + printf("sys_raise: %p\n", win); +} + +void sys_focus(win_t *win) +{ + printf("sys_focus: %p\n", win); +} + +void sys_show(win_t *win, state_t state) +{ + printf("sys_show: %p - %d\n", win, state); +} + +void sys_watch(win_t *win, event_t ev, mod_t mod) +{ + printf("sys_watch: %p - 0x%X,0x%X\n", win, ev, mod2int(mod)); +} + +void sys_unwatch(win_t *win, event_t ev, mod_t mod) +{ + printf("sys_unwatch: %p - 0x%X,0x%X\n", win, ev, mod2int(mod)); +} + +list_t *sys_info(void) +{ + printf("sys_info\n"); + if (screens == NULL) { + win_t *screen = new0(win_t); + screens = list_insert(NULL, screen); + } + return screens; +} + +void sys_init(void) +{ + printf("sys_init\n"); + + /* Load configuration */ + stack = conf_get_int("main.stack", stack); + border = conf_get_int("main.border", border); + no_capture = conf_get_int("main.no-capture", no_capture); + + /* Connect to display */ + if (!(conn = xcb_connect(NULL, NULL))) + error("xcb connect failed"); + if (xcb_connection_has_error(conn)) + error("xcb connection has errors"); +} + +void sys_run(void) +{ + printf("sys_run\n"); +} + +void sys_exit(void) +{ + printf("sys_exit\n"); +} + +void sys_free(void) +{ + printf("sys_free\n"); +} diff --git a/sys-x11.c b/sys-xlib.c similarity index 100% rename from sys-x11.c rename to sys-xlib.c -- 2.43.2