Use int in margin_t

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2019-03-30 10:19:31 +00:00
parent 9677750e3d
commit 63dd16ebac
No known key found for this signature in database
GPG Key ID: 37C999F617EA1A47
4 changed files with 26 additions and 21 deletions

View File

@ -803,19 +803,19 @@ static bool cdbus_process_win_get(session_t *ps, DBusMessage *msg) {
cdbus_m_win_get_do(frame_opacity, cdbus_reply_double); cdbus_m_win_get_do(frame_opacity, cdbus_reply_double);
if (!strcmp("left_width", target)) { if (!strcmp("left_width", target)) {
cdbus_reply_uint32(ps, msg, w->frame_extents.left); cdbus_reply_int32(ps, msg, w->frame_extents.left);
return true; return true;
} }
if (!strcmp("right_width", target)) { if (!strcmp("right_width", target)) {
cdbus_reply_uint32(ps, msg, w->frame_extents.right); cdbus_reply_int32(ps, msg, w->frame_extents.right);
return true; return true;
} }
if (!strcmp("top_width", target)) { if (!strcmp("top_width", target)) {
cdbus_reply_uint32(ps, msg, w->frame_extents.top); cdbus_reply_int32(ps, msg, w->frame_extents.top);
return true; return true;
} }
if (!strcmp("bottom_width", target)) { if (!strcmp("bottom_width", target)) {
cdbus_reply_uint32(ps, msg, w->frame_extents.bottom); cdbus_reply_int32(ps, msg, w->frame_extents.bottom);
return true; return true;
} }

View File

@ -321,10 +321,10 @@ void paint_one(session_t *ps, win *w, const region_t *reg_paint) {
} else { } else {
// Painting parameters // Painting parameters
const margin_t extents = win_calc_frame_extents(w); const margin_t extents = win_calc_frame_extents(w);
const auto t = (int)extents.top; const auto t = extents.top;
const auto l = (int)extents.left; const auto l = extents.left;
const auto b = (int)extents.bottom; const auto b = extents.bottom;
const auto r = (int)extents.right; const auto r = extents.right;
#define COMP_BDR(cx, cy, cwid, chei) \ #define COMP_BDR(cx, cy, cwid, chei) \
paint_region(ps, w, (cx), (cy), (cwid), (chei), w->frame_opacity * w->opacity, \ paint_region(ps, w, (cx), (cy), (cwid), (chei), w->frame_opacity * w->opacity, \

View File

@ -16,10 +16,10 @@ typedef enum {
/// A structure representing margins around a rectangle. /// A structure representing margins around a rectangle.
typedef struct { typedef struct {
unsigned int top; int top;
unsigned int left; int left;
unsigned int bottom; int bottom;
unsigned int right; int right;
} margin_t; } margin_t;
typedef uint32_t opacity_t; typedef uint32_t opacity_t;

View File

@ -121,10 +121,10 @@ static void win_get_region_local(const win *w, region_t *res) {
void win_get_region_noframe_local(const win *w, region_t *res) { void win_get_region_noframe_local(const win *w, region_t *res) {
const margin_t extents = win_calc_frame_extents(w); const margin_t extents = win_calc_frame_extents(w);
int x = (int)extents.left; int x = extents.left;
int y = (int)extents.top; int y = extents.top;
int width = max2(w->g.width - (int)(extents.left + extents.right), 0); int width = max2(w->g.width - (extents.left + extents.right), 0);
int height = max2(w->g.height - (int)(extents.top + extents.bottom), 0); int height = max2(w->g.height - (extents.top + extents.bottom), 0);
pixman_region32_fini(res); pixman_region32_fini(res);
if (width > 0 && height > 0) { if (width > 0 && height > 0) {
@ -141,13 +141,13 @@ void win_get_region_frame_local(const win *w, region_t *res) {
res, res,
(rect_t[]){ (rect_t[]){
// top // top
{.x1 = 0, .y1 = 0, .x2 = w->g.width, .y2 = (int)extents.top}, {.x1 = 0, .y1 = 0, .x2 = w->g.width, .y2 = extents.top},
// bottom // bottom
{.x1 = 0, .y1 = (int)(w->g.height - extents.bottom), .x2 = w->g.width, .y2 = w->g.height}, {.x1 = 0, .y1 = w->g.height - extents.bottom, .x2 = w->g.width, .y2 = w->g.height},
// left // left
{.x1 = 0, .y1 = 0, .x2 = (int)extents.left, .y2 = w->g.height}, {.x1 = 0, .y1 = 0, .x2 = extents.left, .y2 = w->g.height},
// right // right
{.x1 = (int)(w->g.width - extents.right), .y1 = 0, .x2 = w->g.width, .y2 = w->g.height}, {.x1 = w->g.width - extents.right, .y1 = 0, .x2 = w->g.width, .y2 = w->g.height},
}, },
4); 4);
@ -1358,7 +1358,12 @@ void win_update_frame_extents(session_t *ps, win *w, xcb_window_t client) {
wid_get_prop(ps, client, ps->atom_frame_extents, 4L, XCB_ATOM_CARDINAL, 32); wid_get_prop(ps, client, ps->atom_frame_extents, 4L, XCB_ATOM_CARDINAL, 32);
if (prop.nitems == 4) { if (prop.nitems == 4) {
const uint32_t *const extents = prop.c32; const int32_t extents[4] = {
to_int_checked(prop.c32[0]),
to_int_checked(prop.c32[1]),
to_int_checked(prop.c32[2]),
to_int_checked(prop.c32[3]),
};
const bool changed = w->frame_extents.left != extents[0] || const bool changed = w->frame_extents.left != extents[0] ||
w->frame_extents.right != extents[1] || w->frame_extents.right != extents[1] ||
w->frame_extents.top != extents[2] || w->frame_extents.top != extents[2] ||