Merge branch 'i3bar-tray-size' into next
This commit is contained in:
commit
ea89cf179a
|
@ -10,9 +10,12 @@ CPPFLAGS += -I$(TOPDIR)/include
|
||||||
|
|
||||||
all: i3bar doc
|
all: i3bar doc
|
||||||
|
|
||||||
i3bar: ${FILES}
|
i3bar: libi3/libi3.a ${FILES}
|
||||||
echo "LINK"
|
echo "LINK"
|
||||||
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
|
$(CC) $(LDFLAGS) -o $@ $(filter-out libi3/libi3.a,$^) $(LIBS)
|
||||||
|
|
||||||
|
libi3/%.a:
|
||||||
|
$(MAKE) -C $(TOPDIR)/libi3
|
||||||
|
|
||||||
doc:
|
doc:
|
||||||
echo ""
|
echo ""
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
/*
|
/*
|
||||||
|
* vim:ts=4:sw=4:expandtab
|
||||||
|
*
|
||||||
* i3bar - an xcb-based status- and ws-bar for i3
|
* i3bar - an xcb-based status- and ws-bar for i3
|
||||||
*
|
*
|
||||||
* © 2010-2011 Axel Wagner and contributors
|
* © 2010-2011 Axel Wagner and contributors
|
||||||
|
@ -26,6 +28,7 @@
|
||||||
#include <X11/extensions/XKB.h>
|
#include <X11/extensions/XKB.h>
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#include "libi3.h"
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
|
|
||||||
|
@ -640,6 +643,42 @@ static void handle_property_notify(xcb_property_notify_event_t *event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Handle ConfigureRequests by denying them and sending the client a
|
||||||
|
* ConfigureNotify with its actual size.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static void handle_configure_request(xcb_configure_request_event_t *event) {
|
||||||
|
DLOG("ConfigureRequest for window = %08x\n", event->window);
|
||||||
|
|
||||||
|
trayclient *trayclient;
|
||||||
|
i3_output *output;
|
||||||
|
SLIST_FOREACH(output, outputs, slist) {
|
||||||
|
if (!output->active)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
int clients = 0;
|
||||||
|
TAILQ_FOREACH_REVERSE(trayclient, output->trayclients, tc_head, tailq) {
|
||||||
|
clients++;
|
||||||
|
|
||||||
|
if (trayclient->win != event->window)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
xcb_rectangle_t rect;
|
||||||
|
rect.x = output->rect.w - (clients * (font_height + 2));
|
||||||
|
rect.y = 2;
|
||||||
|
rect.width = font_height;
|
||||||
|
rect.height = font_height;
|
||||||
|
|
||||||
|
DLOG("This is a tray window. x = %d\n", rect.x);
|
||||||
|
fake_configure_notify(xcb_connection, rect, event->window, 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DLOG("WARNING: Could not find corresponding tray window.\n");
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function is called immediately before the main loop locks. We flush xcb
|
* This function is called immediately before the main loop locks. We flush xcb
|
||||||
* then (and only then)
|
* then (and only then)
|
||||||
|
@ -689,6 +728,10 @@ void xcb_chk_cb(struct ev_loop *loop, ev_check *watcher, int revents) {
|
||||||
/* PropertyNotify */
|
/* PropertyNotify */
|
||||||
handle_property_notify((xcb_property_notify_event_t*) event);
|
handle_property_notify((xcb_property_notify_event_t*) event);
|
||||||
break;
|
break;
|
||||||
|
case XCB_CONFIGURE_REQUEST:
|
||||||
|
/* ConfigureRequest, sent by a tray child */
|
||||||
|
handle_configure_request((xcb_configure_request_event_t*) event);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
FREE(event);
|
FREE(event);
|
||||||
}
|
}
|
||||||
|
@ -1146,8 +1189,14 @@ void reconfig_windows() {
|
||||||
values[0] = colors.bar_bg;
|
values[0] = colors.bar_bg;
|
||||||
/* If hide_on_modifier is set, i3 is not supposed to manage our bar-windows */
|
/* If hide_on_modifier is set, i3 is not supposed to manage our bar-windows */
|
||||||
values[1] = config.hide_on_modifier;
|
values[1] = config.hide_on_modifier;
|
||||||
/* The events we want to receive */
|
/* We enable the following EventMask fields:
|
||||||
values[2] = XCB_EVENT_MASK_EXPOSURE;
|
* EXPOSURE, to get expose events (we have to re-draw then)
|
||||||
|
* SUBSTRUCTURE_REDIRECT, to get ConfigureRequests when the tray
|
||||||
|
* child windows use ConfigureWindow
|
||||||
|
* BUTTON_PRESS, to handle clicks on the workspace buttons
|
||||||
|
* */
|
||||||
|
values[2] = XCB_EVENT_MASK_EXPOSURE |
|
||||||
|
XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT;
|
||||||
if (!config.disable_ws) {
|
if (!config.disable_ws) {
|
||||||
values[2] |= XCB_EVENT_MASK_BUTTON_PRESS;
|
values[2] |= XCB_EVENT_MASK_BUTTON_PRESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,9 @@
|
||||||
#ifndef _LIBI3_H
|
#ifndef _LIBI3_H
|
||||||
#define _LIBI3_H
|
#define _LIBI3_H
|
||||||
|
|
||||||
|
#include <xcb/xcb.h>
|
||||||
|
#include <xcb/xproto.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Try to get the socket path from X11 and return NULL if it doesn’t work.
|
* Try to get the socket path from X11 and return NULL if it doesn’t work.
|
||||||
*
|
*
|
||||||
|
@ -67,4 +70,12 @@ int ipc_send_message(int sockfd, uint32_t message_size,
|
||||||
int ipc_recv_message(int sockfd, uint32_t message_type,
|
int ipc_recv_message(int sockfd, uint32_t message_type,
|
||||||
uint32_t *reply_length, uint8_t **reply);
|
uint32_t *reply_length, uint8_t **reply);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates a configure_notify event and sends it to the given window
|
||||||
|
* Applications need this to think they’ve configured themselves correctly.
|
||||||
|
* The truth is, however, that we will manage them.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void fake_configure_notify(xcb_connection_t *conn, xcb_rectangle_t r, xcb_window_t window, int border_width);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -102,14 +102,6 @@ void xcb_draw_rect(xcb_connection_t *conn, xcb_drawable_t drawable,
|
||||||
xcb_gcontext_t gc, uint32_t colorpixel, uint32_t x,
|
xcb_gcontext_t gc, uint32_t colorpixel, uint32_t x,
|
||||||
uint32_t y, uint32_t width, uint32_t height);
|
uint32_t y, uint32_t width, uint32_t height);
|
||||||
|
|
||||||
/**
|
|
||||||
* Generates a configure_notify event and sends it to the given window
|
|
||||||
* Applications need this to think they’ve configured themselves correctly.
|
|
||||||
* The truth is, however, that we will manage them.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void fake_configure_notify(xcb_connection_t *conn, Rect r, xcb_window_t window, int border_width);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a configure_notify_event with absolute coordinates (relative to
|
* Generates a configure_notify_event with absolute coordinates (relative to
|
||||||
* the X root window, not to the client’s frame) for the given client.
|
* the X root window, not to the client’s frame) for the given client.
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
/*
|
||||||
|
* vim:ts=4:sw=4:expandtab
|
||||||
|
*
|
||||||
|
* i3 - an improved dynamic tiling window manager
|
||||||
|
*
|
||||||
|
* © 2009-2011 Michael Stapelberg and contributors
|
||||||
|
*
|
||||||
|
* See file LICENSE for license information.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include <xcb/xcb.h>
|
||||||
|
#include <xcb/xproto.h>
|
||||||
|
|
||||||
|
#include "libi3.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Generates a configure_notify event and sends it to the given window
|
||||||
|
* Applications need this to think they’ve configured themselves correctly.
|
||||||
|
* The truth is, however, that we will manage them.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void fake_configure_notify(xcb_connection_t *conn, xcb_rectangle_t r, xcb_window_t window, int border_width) {
|
||||||
|
/* Every X11 event is 32 bytes long. Therefore, XCB will copy 32 bytes.
|
||||||
|
* In order to properly initialize these bytes, we allocate 32 bytes even
|
||||||
|
* though we only need less for an xcb_configure_notify_event_t */
|
||||||
|
void *event = scalloc(32);
|
||||||
|
xcb_configure_notify_event_t *generated_event = event;
|
||||||
|
|
||||||
|
generated_event->event = window;
|
||||||
|
generated_event->window = window;
|
||||||
|
generated_event->response_type = XCB_CONFIGURE_NOTIFY;
|
||||||
|
|
||||||
|
generated_event->x = r.x;
|
||||||
|
generated_event->y = r.y;
|
||||||
|
generated_event->width = r.width;
|
||||||
|
generated_event->height = r.height;
|
||||||
|
|
||||||
|
generated_event->border_width = border_width;
|
||||||
|
generated_event->above_sibling = XCB_NONE;
|
||||||
|
generated_event->override_redirect = false;
|
||||||
|
|
||||||
|
xcb_send_event(conn, false, window, XCB_EVENT_MASK_STRUCTURE_NOTIFY, (char*)generated_event);
|
||||||
|
xcb_flush(conn);
|
||||||
|
|
||||||
|
free(event);
|
||||||
|
}
|
34
src/xcb.c
34
src/xcb.c
|
@ -162,45 +162,13 @@ void xcb_draw_rect(xcb_connection_t *conn, xcb_drawable_t drawable, xcb_gcontext
|
||||||
xcb_poly_fill_rectangle(conn, drawable, gc, 1, &rect);
|
xcb_poly_fill_rectangle(conn, drawable, gc, 1, &rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Generates a configure_notify event and sends it to the given window
|
|
||||||
* Applications need this to think they’ve configured themselves correctly.
|
|
||||||
* The truth is, however, that we will manage them.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void fake_configure_notify(xcb_connection_t *conn, Rect r, xcb_window_t window, int border_width) {
|
|
||||||
/* Every X11 event is 32 bytes long. Therefore, XCB will copy 32 bytes.
|
|
||||||
* In order to properly initialize these bytes, we allocate 32 bytes even
|
|
||||||
* though we only need less for an xcb_configure_notify_event_t */
|
|
||||||
void *event = scalloc(32);
|
|
||||||
xcb_configure_notify_event_t *generated_event = event;
|
|
||||||
|
|
||||||
generated_event->event = window;
|
|
||||||
generated_event->window = window;
|
|
||||||
generated_event->response_type = XCB_CONFIGURE_NOTIFY;
|
|
||||||
|
|
||||||
generated_event->x = r.x;
|
|
||||||
generated_event->y = r.y;
|
|
||||||
generated_event->width = r.width;
|
|
||||||
generated_event->height = r.height;
|
|
||||||
|
|
||||||
generated_event->border_width = border_width;
|
|
||||||
generated_event->above_sibling = XCB_NONE;
|
|
||||||
generated_event->override_redirect = false;
|
|
||||||
|
|
||||||
xcb_send_event(conn, false, window, XCB_EVENT_MASK_STRUCTURE_NOTIFY, (char*)generated_event);
|
|
||||||
xcb_flush(conn);
|
|
||||||
|
|
||||||
free(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generates a configure_notify_event with absolute coordinates (relative to the X root
|
* Generates a configure_notify_event with absolute coordinates (relative to the X root
|
||||||
* window, not to the client’s frame) for the given client.
|
* window, not to the client’s frame) for the given client.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void fake_absolute_configure_notify(Con *con) {
|
void fake_absolute_configure_notify(Con *con) {
|
||||||
Rect absolute;
|
xcb_rectangle_t absolute;
|
||||||
if (con->window == NULL)
|
if (con->window == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue