1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

dtappbuilder: ensure the resize box always inside the main window to avoid the

rendering glitch.
This commit is contained in:
Liang Chang 2021-02-21 06:52:32 +08:00
parent 915ba5d5a9
commit 3a99e98d6a

View file

@ -72,6 +72,16 @@ static void make_rect(
RESIZE_DIR dir RESIZE_DIR dir
); );
static void
make_rect_in_rect(
XRectangle *pr,
XRectangle *new_r,
XRectangle *r,
int x,
int y,
RESIZE_DIR dir
);
static void undo_resize( static void undo_resize(
ABUndoRec undo_rec ABUndoRec undo_rec
); );
@ -355,9 +365,9 @@ abobjP_resize_object_outline(
static Widget parent; static Widget parent;
static Window rootwin; static Window rootwin;
static Display *dpy; static Display *dpy;
static XRectangle orig_r, r; static XRectangle orig_r, r, p_rect;
static int last_x, last_y; static int last_x, last_y;
int x,y; int x, y, x_tmp, y_tmp;
char buf[80]; char buf[80];
if (event->type == MotionNotify) if (event->type == MotionNotify)
@ -399,6 +409,16 @@ abobjP_resize_object_outline(
rootwin = RootWindowOfScreen(XtScreen(xy_widget)); rootwin = RootWindowOfScreen(XtScreen(xy_widget));
x_get_widget_rect(xy_widget, &orig_r); x_get_widget_rect(xy_widget, &orig_r);
x_get_widget_rect(parent, &p_rect);
XTranslateCoordinates(dpy, XtWindow(parent),
rootwin, p_rect.x, p_rect.y, &x_tmp, &y_tmp,
&win);
p_rect.x = x_tmp;
p_rect.y = y_tmp;
if (obj_has_border_frame(obj)) /* We have a border-frame to deal with */ if (obj_has_border_frame(obj)) /* We have a border-frame to deal with */
{ {
XRectangle pane_r; XRectangle pane_r;
@ -412,8 +432,8 @@ abobjP_resize_object_outline(
else else
border_w = 0; border_w = 0;
orig_r.width--; if (orig_r.width > 0) orig_r.width--;
orig_r.height--; if (orig_r.height > 0) orig_r.height--;
r = orig_r; r = orig_r;
@ -431,7 +451,7 @@ abobjP_resize_object_outline(
} }
else /* erase previous outline */ else /* erase previous outline */
{ {
make_rect(&resize_rect, &r, last_x, last_y, dir); make_rect_in_rect(&p_rect, &resize_rect, &r, last_x, last_y, dir);
x_fullscreen_box(xy_widget, rootwin, x_fullscreen_box(xy_widget, rootwin,
resize_rect.x, resize_rect.y, resize_rect.x, resize_rect.y,
rect_right(&resize_rect), rect_right(&resize_rect),
@ -439,7 +459,7 @@ abobjP_resize_object_outline(
} }
make_rect(&resize_rect, &r, x, y, dir); make_rect_in_rect(&p_rect, &resize_rect, &r, x, y, dir);
x_fullscreen_box(xy_widget, rootwin, x_fullscreen_box(xy_widget, rootwin,
resize_rect.x, resize_rect.y, resize_rect.x, resize_rect.y,
rect_right(&resize_rect), rect_right(&resize_rect),
@ -508,8 +528,8 @@ abobj_resize(
XTranslateCoordinates(dpy, rootwin, XtWindow(parent), XTranslateCoordinates(dpy, rootwin, XtWindow(parent),
orig_x , orig_y, &trans_x, &trans_y, &win); orig_x , orig_y, &trans_x, &trans_y, &win);
resize_rect.width++; resize_rect.width++; if (!resize_rect.width) --resize_rect.width;
resize_rect.height++; resize_rect.height++; if (!resize_rect.height) --resize_rect.height;
/* Ensure new geometry fits within parent /* Ensure new geometry fits within parent
*/ */
@ -843,6 +863,35 @@ make_rect (
} }
} }
/*
* calculate resize rect based on resize-direction & obj dimensions & a
* boundary.
*/
static void
make_rect_in_rect(
XRectangle *pr,
XRectangle *new_r,
XRectangle *r,
int x,
int y,
RESIZE_DIR dir
)
{
int x_tmp, y_tmp;
int pr_right = rect_right(pr);
int pr_bottom = rect_bottom(pr);
if (x < pr->x) x_tmp = pr->x;
else if (x > pr_right) x_tmp = pr_right;
else x_tmp = x;
if (y < pr->y) y_tmp = pr->y;
else if (y > pr_bottom) y_tmp = pr_bottom;
else y_tmp = y;
make_rect(new_r, r, x_tmp, y_tmp, dir);
}
/* /*
* Function for undoing RESIZE * Function for undoing RESIZE
*/ */