Wibox: Remove shape support
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
932e0bfcd0
commit
03e0ee53d2
|
@ -28,7 +28,6 @@
|
||||||
|
|
||||||
#include <xcb/bigreq.h>
|
#include <xcb/bigreq.h>
|
||||||
#include <xcb/randr.h>
|
#include <xcb/randr.h>
|
||||||
#include <xcb/shape.h>
|
|
||||||
#include <xcb/xcb_event.h>
|
#include <xcb/xcb_event.h>
|
||||||
#include <xcb/xinerama.h>
|
#include <xcb/xinerama.h>
|
||||||
#include <xcb/xtest.h>
|
#include <xcb/xtest.h>
|
||||||
|
@ -372,7 +371,6 @@ main(int argc, char **argv)
|
||||||
xcb_prefetch_extension_data(globalconf.connection, &xcb_test_id);
|
xcb_prefetch_extension_data(globalconf.connection, &xcb_test_id);
|
||||||
xcb_prefetch_extension_data(globalconf.connection, &xcb_randr_id);
|
xcb_prefetch_extension_data(globalconf.connection, &xcb_randr_id);
|
||||||
xcb_prefetch_extension_data(globalconf.connection, &xcb_xinerama_id);
|
xcb_prefetch_extension_data(globalconf.connection, &xcb_xinerama_id);
|
||||||
xcb_prefetch_extension_data(globalconf.connection, &xcb_shape_id);
|
|
||||||
|
|
||||||
/* initialize dbus */
|
/* initialize dbus */
|
||||||
a_dbus_init();
|
a_dbus_init();
|
||||||
|
|
|
@ -140,7 +140,6 @@ pkg_check_modules(AWESOME_REQUIRED REQUIRED
|
||||||
xcb-randr
|
xcb-randr
|
||||||
xcb-xtest
|
xcb-xtest
|
||||||
xcb-xinerama
|
xcb-xinerama
|
||||||
xcb-shape
|
|
||||||
xcb-aux>=0.3.0
|
xcb-aux>=0.3.0
|
||||||
xcb-atom>=0.3.0
|
xcb-atom>=0.3.0
|
||||||
xcb-keysyms>=0.3.4
|
xcb-keysyms>=0.3.4
|
||||||
|
|
|
@ -75,8 +75,6 @@ role
|
||||||
screen
|
screen
|
||||||
selected
|
selected
|
||||||
session
|
session
|
||||||
shape_bounding
|
|
||||||
shape_clip
|
|
||||||
Shift
|
Shift
|
||||||
size_hints
|
size_hints
|
||||||
size_hints_honor
|
size_hints_honor
|
||||||
|
|
|
@ -265,58 +265,6 @@ function new(arg)
|
||||||
return w
|
return w
|
||||||
end
|
end
|
||||||
|
|
||||||
local function do_rounded_corners(width, height, corner)
|
|
||||||
local img = image.argb32(width, height, nil)
|
|
||||||
|
|
||||||
-- The image starts completely black which is fully opaque for our use
|
|
||||||
|
|
||||||
local function transp_rect(x, y)
|
|
||||||
img:draw_rectangle(x, y, corner, corner, true, "#ffffff")
|
|
||||||
end
|
|
||||||
local function opaque_circle(x, y)
|
|
||||||
-- x, y are the center of the circle
|
|
||||||
img:draw_circle(x, y, corner, corner, true, "#000000")
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Upper left corner
|
|
||||||
-- First make a 'corner times corner' rectangle transparent
|
|
||||||
transp_rect(0, 0)
|
|
||||||
-- Then add the rounded corner
|
|
||||||
opaque_circle(corner, corner)
|
|
||||||
|
|
||||||
-- Upper right corner
|
|
||||||
transp_rect(width - corner, 0)
|
|
||||||
opaque_circle(width - corner - 1, corner)
|
|
||||||
|
|
||||||
-- Bottom left corner
|
|
||||||
transp_rect(0, height - corner)
|
|
||||||
opaque_circle(corner, height - corner - 1)
|
|
||||||
|
|
||||||
-- Bottom right corner
|
|
||||||
transp_rect(width - corner, height - corner)
|
|
||||||
opaque_circle(width - corner - 1, height - corner - 1)
|
|
||||||
|
|
||||||
return img
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Add rounded corners to a wibox
|
|
||||||
-- @param wibox The wibox.
|
|
||||||
-- @param corner_size The size in pixel of the rounded corners.
|
|
||||||
function rounded_corners(wibox, corner_size)
|
|
||||||
local border = wibox.border_width
|
|
||||||
|
|
||||||
-- Corners can't be larger than half the wibox' space
|
|
||||||
if wibox.width / 2 < corner_size then
|
|
||||||
corner_size = wibox.width / 2
|
|
||||||
end
|
|
||||||
if wibox.height / 2 < corner_size then
|
|
||||||
corner_size = wibox.height / 2
|
|
||||||
end
|
|
||||||
|
|
||||||
wibox.shape_clip = do_rounded_corners(wibox.width, wibox.height, corner_size)
|
|
||||||
wibox.shape_bounding = do_rounded_corners(wibox.width + border * 2, wibox.height + border * 2, corner_size + border)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function update_wiboxes_on_struts(c)
|
local function update_wiboxes_on_struts(c)
|
||||||
local struts = c:struts()
|
local struts = c:struts()
|
||||||
if struts.left ~= 0 or struts.right ~= 0
|
if struts.left ~= 0 or struts.right ~= 0
|
||||||
|
|
|
@ -20,8 +20,6 @@ module("wibox")
|
||||||
-- @field y The y coordinates.
|
-- @field y The y coordinates.
|
||||||
-- @field width The width of the wibox.
|
-- @field width The width of the wibox.
|
||||||
-- @field height The height of the wibox.
|
-- @field height The height of the wibox.
|
||||||
-- @field shape_bounding Image describing the window's border shape.
|
|
||||||
-- @field shape_clip Image describing the window's content shape.
|
|
||||||
-- @class table
|
-- @class table
|
||||||
-- @name wibox
|
-- @name wibox
|
||||||
|
|
||||||
|
|
107
objects/wibox.c
107
objects/wibox.c
|
@ -19,8 +19,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xcb/shape.h>
|
|
||||||
|
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "wibox.h"
|
#include "wibox.h"
|
||||||
#include "objects/client.h"
|
#include "objects/client.h"
|
||||||
|
@ -114,62 +112,6 @@ wibox_need_update(wibox_t *wibox)
|
||||||
wibox_clear_mouse_over(wibox);
|
wibox_clear_mouse_over(wibox);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
have_shape(void)
|
|
||||||
{
|
|
||||||
const xcb_query_extension_reply_t *reply;
|
|
||||||
|
|
||||||
reply = xcb_get_extension_data(globalconf.connection, &xcb_shape_id);
|
|
||||||
if (!reply || !reply->present)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* We don't need a specific version of SHAPE, no version check required */
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
shape_update(xcb_window_t win, xcb_shape_kind_t kind, image_t *image, int offset)
|
|
||||||
{
|
|
||||||
xcb_pixmap_t shape;
|
|
||||||
|
|
||||||
if(image)
|
|
||||||
shape = image_to_1bit_pixmap(image, win);
|
|
||||||
else
|
|
||||||
/* Reset the shape */
|
|
||||||
shape = XCB_NONE;
|
|
||||||
|
|
||||||
xcb_shape_mask(globalconf.connection, XCB_SHAPE_SO_SET, kind,
|
|
||||||
win, offset, offset, shape);
|
|
||||||
|
|
||||||
if (shape != XCB_NONE)
|
|
||||||
xcb_free_pixmap(globalconf.connection, shape);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Update the window's shape.
|
|
||||||
* \param wibox The simple window whose shape should be updated.
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
wibox_shape_update(wibox_t *wibox)
|
|
||||||
{
|
|
||||||
if(wibox->window == XCB_NONE)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(!have_shape())
|
|
||||||
{
|
|
||||||
static bool warned = false;
|
|
||||||
if(!warned)
|
|
||||||
warn("The X server doesn't have the SHAPE extension; "
|
|
||||||
"can't change window's shape");
|
|
||||||
warned = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
shape_update(wibox->window, XCB_SHAPE_SK_CLIP, wibox->shape.clip, 0);
|
|
||||||
shape_update(wibox->window, XCB_SHAPE_SK_BOUNDING, wibox->shape.bounding, - wibox->border_width);
|
|
||||||
|
|
||||||
wibox->need_shape_update = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
wibox_draw_context_update(wibox_t *w)
|
wibox_draw_context_update(wibox_t *w)
|
||||||
{
|
{
|
||||||
|
@ -239,8 +181,6 @@ wibox_init(wibox_t *w)
|
||||||
|
|
||||||
/* Update draw context physical screen, important for Zaphod. */
|
/* Update draw context physical screen, important for Zaphod. */
|
||||||
wibox_draw_context_update(w);
|
wibox_draw_context_update(w);
|
||||||
|
|
||||||
wibox_shape_update(w);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Refresh the window content by copying its pixmap data to its window.
|
/** Refresh the window content by copying its pixmap data to its window.
|
||||||
|
@ -584,8 +524,6 @@ wibox_refresh(void)
|
||||||
{
|
{
|
||||||
foreach(w, globalconf.wiboxes)
|
foreach(w, globalconf.wiboxes)
|
||||||
{
|
{
|
||||||
if((*w)->need_shape_update)
|
|
||||||
wibox_shape_update(*w);
|
|
||||||
if((*w)->need_update)
|
if((*w)->need_update)
|
||||||
wibox_draw(*w);
|
wibox_draw(*w);
|
||||||
}
|
}
|
||||||
|
@ -1163,41 +1101,6 @@ luaA_wibox_get_widgets(lua_State *L, wibox_t *wibox)
|
||||||
{
|
{
|
||||||
return luaA_object_push_item(L, 1, wibox->widgets_table);
|
return luaA_object_push_item(L, 1, wibox->widgets_table);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
luaA_wibox_set_shape_bounding(lua_State *L, wibox_t *wibox)
|
|
||||||
{
|
|
||||||
luaA_checkudata(L, -1, &image_class);
|
|
||||||
luaA_object_unref_item(L, -3, wibox->shape.bounding);
|
|
||||||
wibox->shape.bounding = luaA_object_ref_item(L, -3, -1);
|
|
||||||
wibox->need_shape_update = true;
|
|
||||||
luaA_object_emit_signal(L, -2, "property::shape_bounding", 0);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
luaA_wibox_get_shape_bounding(lua_State *L, wibox_t *wibox)
|
|
||||||
{
|
|
||||||
return luaA_object_push_item(L, 1, wibox->shape.bounding);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
luaA_wibox_set_shape_clip(lua_State *L, wibox_t *wibox)
|
|
||||||
{
|
|
||||||
luaA_checkudata(L, -1, &image_class);
|
|
||||||
luaA_object_unref_item(L, -3, wibox->shape.clip);
|
|
||||||
wibox->shape.clip = luaA_object_ref_item(L, -3, -1);
|
|
||||||
wibox->need_shape_update = true;
|
|
||||||
luaA_object_emit_signal(L, -2, "property::shape_clip", 0);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
luaA_wibox_get_shape_clip(lua_State *L, wibox_t *wibox)
|
|
||||||
{
|
|
||||||
return luaA_object_push_item(L, 1, wibox->shape.clip);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
wibox_class_setup(lua_State *L)
|
wibox_class_setup(lua_State *L)
|
||||||
{
|
{
|
||||||
|
@ -1274,14 +1177,6 @@ wibox_class_setup(lua_State *L)
|
||||||
(lua_class_propfunc_t) luaA_wibox_set_height,
|
(lua_class_propfunc_t) luaA_wibox_set_height,
|
||||||
(lua_class_propfunc_t) luaA_wibox_get_height,
|
(lua_class_propfunc_t) luaA_wibox_get_height,
|
||||||
(lua_class_propfunc_t) luaA_wibox_set_height);
|
(lua_class_propfunc_t) luaA_wibox_set_height);
|
||||||
luaA_class_add_property(&wibox_class, A_TK_SHAPE_BOUNDING,
|
|
||||||
(lua_class_propfunc_t) luaA_wibox_set_shape_bounding,
|
|
||||||
(lua_class_propfunc_t) luaA_wibox_get_shape_bounding,
|
|
||||||
(lua_class_propfunc_t) luaA_wibox_set_shape_bounding);
|
|
||||||
luaA_class_add_property(&wibox_class, A_TK_SHAPE_CLIP,
|
|
||||||
(lua_class_propfunc_t) luaA_wibox_set_shape_clip,
|
|
||||||
(lua_class_propfunc_t) luaA_wibox_get_shape_clip,
|
|
||||||
(lua_class_propfunc_t) luaA_wibox_set_shape_clip);
|
|
||||||
|
|
||||||
signal_add(&wibox_class.signals, "mouse::enter");
|
signal_add(&wibox_class.signals, "mouse::enter");
|
||||||
signal_add(&wibox_class.signals, "mouse::leave");
|
signal_add(&wibox_class.signals, "mouse::leave");
|
||||||
|
@ -1294,8 +1189,6 @@ wibox_class_setup(lua_State *L)
|
||||||
signal_add(&wibox_class.signals, "property::ontop");
|
signal_add(&wibox_class.signals, "property::ontop");
|
||||||
signal_add(&wibox_class.signals, "property::orientation");
|
signal_add(&wibox_class.signals, "property::orientation");
|
||||||
signal_add(&wibox_class.signals, "property::screen");
|
signal_add(&wibox_class.signals, "property::screen");
|
||||||
signal_add(&wibox_class.signals, "property::shape_bounding");
|
|
||||||
signal_add(&wibox_class.signals, "property::shape_clip");
|
|
||||||
signal_add(&wibox_class.signals, "property::visible");
|
signal_add(&wibox_class.signals, "property::visible");
|
||||||
signal_add(&wibox_class.signals, "property::widgets");
|
signal_add(&wibox_class.signals, "property::widgets");
|
||||||
signal_add(&wibox_class.signals, "property::width");
|
signal_add(&wibox_class.signals, "property::width");
|
||||||
|
|
|
@ -41,8 +41,6 @@ struct wibox_t
|
||||||
widget_t *mouse_over;
|
widget_t *mouse_over;
|
||||||
/** Need update */
|
/** Need update */
|
||||||
bool need_update;
|
bool need_update;
|
||||||
/** Need shape update */
|
|
||||||
bool need_shape_update;
|
|
||||||
/** Cursor */
|
/** Cursor */
|
||||||
char *cursor;
|
char *cursor;
|
||||||
/** Background image */
|
/** Background image */
|
||||||
|
@ -55,14 +53,6 @@ struct wibox_t
|
||||||
draw_context_t ctx;
|
draw_context_t ctx;
|
||||||
/** Orientation */
|
/** Orientation */
|
||||||
orientation_t orientation;
|
orientation_t orientation;
|
||||||
/** The window's shape */
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
/** The window's content */
|
|
||||||
image_t *clip;
|
|
||||||
/** The window's content and border */
|
|
||||||
image_t *bounding;
|
|
||||||
} shape;
|
|
||||||
/** Has wibox an attached systray **/
|
/** Has wibox an attached systray **/
|
||||||
bool has_systray;
|
bool has_systray;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue