#include <xcb/xcb.h>
+#include <X11/XKBlib.h>
+#include <X11/extensions/XKB.h>
+
#include "xcb_wm.h"
#include "xcb_aux.h"
#include "xcb_event.h"
#define TERMINAL "/usr/pkg/bin/urxvt"
-Font *myfont;
+i3Font *myfont;
+Display *xkbdpy;
static const int TOP = 20;
static const int LEFT = 5;
uint32_t mask = 0;
uint32_t values[3];
xcb_screen_t *root_screen = xcb_setup_roots_iterator(xcb_get_setup(conn)).data;
- Font *font = load_font(conn, pattern);
+ i3Font *font = load_font(conn, pattern);
uint32_t background_color,
text_color,
border_color;
XCB_CONFIG_WINDOW_Y |
XCB_CONFIG_WINDOW_WIDTH |
XCB_CONFIG_WINDOW_HEIGHT;
- Font *font = load_font(connection, pattern);
+ i3Font *font = load_font(connection, pattern);
if (container->mode == MODE_DEFAULT) {
int num_clients = 0;
for (cols = 0; cols < table_dims.x; cols++)
for (rows = 0; rows < table_dims.y; rows++)
if (table[cols][rows] != NULL) {
+ Container *con = table[cols][rows];
+ printf("container has %d colspan, %d rowspan\n",
+ con->colspan, con->rowspan);
/* Update position of the container */
- table[cols][rows]->row = rows;
- table[cols][rows]->col = cols;
- table[cols][rows]->width = width / num_cols;
- table[cols][rows]->height = height / num_rows;
+ con->row = rows;
+ con->col = cols;
+ con->width = (width / num_cols) * con->colspan;
+ con->height = (height / num_rows) * con->rowspan;
/* Render it */
render_container(conn, table[cols][rows]);
table_put(byChild, child, new);
/* Moves the original window into the new frame we've created for it */
- Font *font = load_font(conn, pattern);
+ i3Font *font = load_font(conn, pattern);
xcb_reparent_window(conn, child, new->frame, 0, font->height);
/* We are interested in property changes */
*
*/
static int handle_key_press(void *ignored, xcb_connection_t *conn, xcb_key_press_event_t *event) {
-
/* FIXME: We need to translate the keypress + state into a string (like, ä)
because they do not generate keysyms (use xev and see for yourself) */
printf("oh yay!\n");
printf("gots press %d\n", event->detail);
+
+ /* We need to get the keysym group (There are group 1 to group 4, each holding
+ two keysyms (without shift and with shift) using Xkb because X fails to
+ provide them reliably (it works in Xephyr, it does not in real X) */
+ XkbStateRec state;
+ if (XkbGetState(xkbdpy, XkbUseCoreKbd, &state) == Success) {
+ if (state.group+1 == 2)
+ event->state |= 0x2;
+ }
printf("i'm in state %d\n", event->state);
+
+ xcb_key_symbols_t *keysyms = xcb_key_symbols_alloc(conn);
+
+ xcb_keysym_t k0 = xcb_key_symbols_get_keysym(keysyms, event->detail, event->state);
+ if (k0 == XCB_NONE)
+ printf("couldn't get k0\n");
+
+ printf("gots keysym %d and \n", k0);
+
+
/* 30 = u
* 57 = n
* 27 = r
if (event->detail == 30) {
/* 'u' */
start_application(TERMINAL, NULL);
+
return 1;
} else if (event->detail == 57) {
direction = D_LEFT;
direction = D_UP;
} else if (event->detail == 40) {
direction = D_RIGHT;
+ } else if (event->detail == 25) {
+ Container *con = CUR_CELL;
+ if (con->colspan == 1)
+ con->colspan++;
+ else con->colspan--;
+ render_layout(conn);
+ xcb_flush(conn);
+ return 1;
} else {
printf("don't want this.\n");
return 1;
old_client = client->container->currently_focused;
client->container->currently_focused = client;
+ current_col = client->container->col;
+ current_row = client->container->row;
+
/* Set focus to the entered window, and flush xcb buffer immediately */
xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, client->child, XCB_CURRENT_TIME);
/* Update last/current client’s titlebar */
return 1;
}
+
int handle_map_notify_event(void *prophs, xcb_connection_t *c, xcb_map_notify_event_t *e)
{
window_attributes_t wa = { TAG_VALUE };
printf("x screen is %d\n", screens);
+ int major, minor, error;
+
+ major = XkbMajorVersion;
+ minor = XkbMinorVersion;
+
+ int evBase, errBase;
+
+ if ((xkbdpy = XkbOpenDisplay(getenv("DISPLAY"), &evBase, &errBase, &major, &minor, &error)) == NULL) {
+ fprintf(stderr, "XkbOpenDisplay() failed\n");
+ return 1;
+ }
+
+ int i1;
+ if (!XkbQueryExtension(xkbdpy,&i1,&evBase,&errBase,&major,&minor)) {
+ fprintf(stderr, "XKB not supported by X-server\n");
+ return 1;
+ }
+
/* Font loading */
myfont = load_font(c, pattern);
//xcb_grab_key(c, 0, root, 0, 38, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);
xcb_grab_key(c, 0, root, 0, 30, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);
+ xcb_grab_key(c, 0, root, 0, 38, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);
+
+
xcb_grab_key(c, 0, root, XCB_MOD_MASK_1, 57, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);
xcb_grab_key(c, 0, root, XCB_MOD_MASK_1, 28, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);
xcb_grab_key(c, 0, root, XCB_MOD_MASK_1, 27, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);
xcb_grab_key(c, 0, root, XCB_MOD_MASK_CONTROL, 28, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);
xcb_grab_key(c, 0, root, XCB_MOD_MASK_CONTROL, 27, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);
xcb_grab_key(c, 0, root, XCB_MOD_MASK_CONTROL, 40, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);
+ xcb_grab_key(c, 0, root, XCB_MOD_MASK_CONTROL, 25, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);
+
//xcb_grab_key(c, 0, root, XCB_BUTTON_MASK_ANY, 40, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);