1
0
Fork 0
mirror of https://github.com/yshui/picom.git synced 2024-11-11 13:51:02 -05:00

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 e056fab708
commit 9adba98fc0
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);
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;
}
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;
}
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;
}
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;
}

View file

@ -321,10 +321,10 @@ void paint_one(session_t *ps, win *w, const region_t *reg_paint) {
} else {
// Painting parameters
const margin_t extents = win_calc_frame_extents(w);
const auto t = (int)extents.top;
const auto l = (int)extents.left;
const auto b = (int)extents.bottom;
const auto r = (int)extents.right;
const auto t = extents.top;
const auto l = extents.left;
const auto b = extents.bottom;
const auto r = extents.right;
#define COMP_BDR(cx, cy, cwid, chei) \
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.
typedef struct {
unsigned int top;
unsigned int left;
unsigned int bottom;
unsigned int right;
int top;
int left;
int bottom;
int right;
} margin_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) {
const margin_t extents = win_calc_frame_extents(w);
int x = (int)extents.left;
int y = (int)extents.top;
int width = max2(w->g.width - (int)(extents.left + extents.right), 0);
int height = max2(w->g.height - (int)(extents.top + extents.bottom), 0);
int x = extents.left;
int y = extents.top;
int width = max2(w->g.width - (extents.left + extents.right), 0);
int height = max2(w->g.height - (extents.top + extents.bottom), 0);
pixman_region32_fini(res);
if (width > 0 && height > 0) {
@ -141,13 +141,13 @@ void win_get_region_frame_local(const win *w, region_t *res) {
res,
(rect_t[]){
// 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
{.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
{.x1 = 0, .y1 = 0, .x2 = (int)extents.left, .y2 = w->g.height},
{.x1 = 0, .y1 = 0, .x2 = extents.left, .y2 = w->g.height},
// 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);
@ -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);
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] ||
w->frame_extents.right != extents[1] ||
w->frame_extents.top != extents[2] ||