-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,8 @@ | |
#include "parse.h" | ||
#include "window.h" | ||
|
||
#include <xcb/shape.h> | ||
|
||
void schedule_window(xcb_window_t win) | ||
{ | ||
coordinates_t loc; | ||
|
@@ -404,6 +406,108 @@ void draw_border(node_t *n, bool focused_node, bool focused_monitor) | |
} | ||
} | ||
|
||
void window_rounded_border(xcb_window_t win) | ||
{ | ||
// Check for compatibility | ||
const xcb_query_extension_reply_t *shape_query; | ||
xcb_shape_query_extents_cookie_t extents_cookie; | ||
xcb_shape_query_extents_reply_t *extents; | ||
|
||
shape_query = xcb_get_extension_data (dpy, &xcb_shape_id); | ||
if (!shape_query->present) return; | ||
|
||
// get geometry | ||
xcb_get_geometry_reply_t *geo = xcb_get_geometry_reply(dpy, xcb_get_geometry(dpy, win), NULL); | ||
if (geo == NULL) return; | ||
|
||
uint16_t w = geo->width; | ||
uint16_t h = geo->height; | ||
uint16_t bw = geo->border_width; | ||
free(geo); | ||
|
||
xcb_pixmap_t bpid = xcb_generate_id(dpy); | ||
xcb_pixmap_t cpid = xcb_generate_id(dpy); | ||
|
||
xcb_create_pixmap(dpy, 1, bpid, win, w+2*bw, h+2*bw); | ||
xcb_create_pixmap(dpy, 1, cpid, win, w, h); | ||
|
||
xcb_gcontext_t bblack = xcb_generate_id(dpy); | ||
xcb_gcontext_t bwhite = xcb_generate_id(dpy); | ||
xcb_gcontext_t cblack = xcb_generate_id(dpy); | ||
xcb_gcontext_t cwhite = xcb_generate_id(dpy); | ||
|
||
xcb_create_gc(dpy, bblack, bpid, | ||
XCB_GC_FOREGROUND, | ||
//(uint32_t[]){screen->black_pixel, 0}); | ||
(uint32_t[]){0, 0}); | ||
xcb_create_gc(dpy, bwhite, bpid, | ||
XCB_GC_FOREGROUND, | ||
//(uint32_t[]){screen->white_pixel, 0}); | ||
(uint32_t[]){1, 0}); | ||
xcb_create_gc(dpy, cblack, cpid, | ||
XCB_GC_FOREGROUND, | ||
//(uint32_t[]){screen->black_pixel, 0}); | ||
(uint32_t[]){0, 0}); | ||
xcb_create_gc(dpy, cwhite, cpid, | ||
XCB_GC_FOREGROUND, | ||
//(uint32_t[]){screen->white_pixel, 0}); | ||
(uint32_t[]){1, 0}); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Javyre
Author
Owner
|
||
|
||
int32_t rad, dia; | ||
|
||
rad = 40; dia = rad*2; | ||
|
||
xcb_arc_t barcs[] = { | ||
{ 0, 0, dia, dia, 0, 360 << 6 }, | ||
{ 0, h-dia, dia, dia, 0, 360 << 6 }, | ||
{ w-dia, 0, dia, dia, 0, 360 << 6 }, | ||
{ w-dia, h-dia, dia, dia, 0, 360 << 6 }, | ||
}; | ||
xcb_rectangle_t brects[] = { | ||
{ rad, 0, w-dia, h }, | ||
{ 0, rad, w, h-dia }, | ||
}; | ||
|
||
rad -= bw; dia = rad*2; | ||
|
||
xcb_arc_t carcs[] = { | ||
{ bw, bw, dia, dia, 0, 360 << 6 }, | ||
{ bw, h-dia, dia, dia, 0, 360 << 6 }, | ||
{ w-dia, 0, dia, dia, 0, 360 << 6 }, | ||
{ w-dia, h-dia, dia, dia, 0, 360 << 6 }, | ||
}; | ||
xcb_rectangle_t crects[] = { | ||
{ bw+rad, bw, w-dia-bw, h }, | ||
{ bw, bw+rad, w, h-dia-bw }, | ||
}; | ||
|
||
xcb_rectangle_t bounding = {-bw, -bw, w+2*bw, h+2*bw}; | ||
//xcb_rectangle_t bounding = {-bw, -bw, w, h}; | ||
xcb_poly_fill_rectangle(dpy, bpid, bblack, 1, &bounding); | ||
xcb_poly_fill_rectangle(dpy, bpid, bwhite, 2, brects); | ||
xcb_poly_fill_arc(dpy, bpid, bwhite, 4, barcs); | ||
|
||
xcb_rectangle_t clipping = {0, 0, w, h}; | ||
xcb_poly_fill_rectangle(dpy, cpid, cblack, 1, &clipping); | ||
xcb_poly_fill_rectangle(dpy, cpid, cwhite, 2, crects); | ||
xcb_poly_fill_arc(dpy, cpid, cwhite, 4, carcs); | ||
|
||
xcb_shape_mask( | ||
dpy, | ||
0 /*Bounding*/, | ||
0 /*ShapeSet*/, | ||
This comment has been minimized.
Sorry, something went wrong.
psychon
|
||
win, 0, 0, bpid); | ||
|
||
xcb_shape_mask( | ||
dpy, | ||
1 /*Clipping*/, | ||
0 /*ShapeSet*/, | ||
win, 0, 0, cpid); | ||
|
||
xcb_free_pixmap(dpy, bpid); | ||
xcb_free_pixmap(dpy, cpid); | ||
} | ||
|
||
void window_draw_border(xcb_window_t win, uint32_t border_color_pxl) | ||
{ | ||
xcb_change_window_attributes(dpy, win, XCB_CW_BORDER_PIXEL, &border_color_pxl); | ||
|
@@ -798,6 +902,8 @@ void window_border_width(xcb_window_t win, uint32_t bw) | |
{ | ||
uint32_t values[] = {bw}; | ||
xcb_configure_window(dpy, win, XCB_CONFIG_WINDOW_BORDER_WIDTH, values); | ||
|
||
window_rounded_border(win); | ||
} | ||
|
||
void window_move(xcb_window_t win, int16_t x, int16_t y) | ||
|
@@ -810,12 +916,18 @@ void window_resize(xcb_window_t win, uint16_t w, uint16_t h) | |
{ | ||
uint32_t values[] = {w, h}; | ||
xcb_configure_window(dpy, win, XCB_CONFIG_WINDOW_WIDTH_HEIGHT, values); | ||
|
||
window_rounded_border(win); | ||
} | ||
|
||
void window_move_resize(xcb_window_t win, int16_t x, int16_t y, uint16_t w, uint16_t h) | ||
{ | ||
uint32_t values[] = {x, y, w, h}; | ||
|
||
window_rounded_border(win); | ||
xcb_configure_window(dpy, win, XCB_CONFIG_WINDOW_X_Y_WIDTH_HEIGHT, values); | ||
|
||
window_rounded_border(win); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Javyre
Author
Owner
|
||
} | ||
|
||
void window_center(monitor_t *m, client_t *c) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,7 @@ void hide_presel_feedbacks(monitor_t *m, desktop_t *d, node_t *n); | |
void update_colors(void); | ||
void update_colors_in(node_t *n, desktop_t *d, monitor_t *m); | ||
void draw_border(node_t *n, bool focused_node, bool focused_monitor); | ||
void window_rounded_border(xcb_window_t win); | ||
void window_draw_border(xcb_window_t win, uint32_t border_color_pxl); | ||
void adopt_orphans(void); | ||
uint32_t get_border_color(bool focused_node, bool focused_monitor); | ||
This comment has been minimized.
Sorry, something went wrong.
psychon
|
||
|
Why so many GCs? Two and two of them are the same, and you could reconfigure the GC with
xcb_change_gc
instead of creating another one, thus doing everything with just a single GC.This would not make any measurable effects, but would mean that you use less XIDs, thus the very unlikely event of running through the assigned XID space becomes even less likely.