mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-13 19:52:20 +00:00
Merge /u/l-chang/cdesktopenv1/ branch master into master
https://sourceforge.net/p/cdesktopenv/code/merge-requests/26/
This commit is contained in:
commit
8092b720f0
4 changed files with 85 additions and 36 deletions
|
@ -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,15 +528,15 @@ 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
|
||||||
*/
|
*/
|
||||||
if (trans_x < 0)
|
if (trans_x < 0)
|
||||||
{
|
{
|
||||||
resize_rect.x = 0;
|
resize_rect.x = 0;
|
||||||
resize_rect.width += trans_x;
|
resize_rect.width = max(0, resize_rect.width + trans_x);
|
||||||
|
|
||||||
if (obj_is_pane(obj) || obj_is_separator(obj)) /* If a pane, attach to parent's edge */
|
if (obj_is_pane(obj) || obj_is_separator(obj)) /* If a pane, attach to parent's edge */
|
||||||
obj_set_attachment(xy_obj, AB_CP_WEST, AB_ATTACH_OBJ, obj_get_parent(xy_obj), 0);
|
obj_set_attachment(xy_obj, AB_CP_WEST, AB_ATTACH_OBJ, obj_get_parent(xy_obj), 0);
|
||||||
|
@ -535,7 +555,7 @@ abobj_resize(
|
||||||
if (trans_y < 0)
|
if (trans_y < 0)
|
||||||
{
|
{
|
||||||
resize_rect.y = 0;
|
resize_rect.y = 0;
|
||||||
resize_rect.height += trans_y;
|
resize_rect.height = max(0, resize_rect.height + trans_y);
|
||||||
|
|
||||||
if (obj_is_pane(obj) || obj_is_separator(obj)) /* If a pane, attach to parent's edge */
|
if (obj_is_pane(obj) || obj_is_separator(obj)) /* If a pane, attach to parent's edge */
|
||||||
obj_set_attachment(xy_obj, AB_CP_NORTH, AB_ATTACH_OBJ, obj_get_parent(xy_obj), 0);
|
obj_set_attachment(xy_obj, AB_CP_NORTH, AB_ATTACH_OBJ, obj_get_parent(xy_obj), 0);
|
||||||
|
@ -553,7 +573,7 @@ abobj_resize(
|
||||||
|
|
||||||
if (resize_rect.x + (short)resize_rect.width >= (short)p_rect.width)
|
if (resize_rect.x + (short)resize_rect.width >= (short)p_rect.width)
|
||||||
{
|
{
|
||||||
resize_rect.width = (short)p_rect.width - resize_rect.x - 1;
|
resize_rect.width = max(0, (short)p_rect.width - resize_rect.x - 1);
|
||||||
|
|
||||||
if (obj_is_pane(obj) || obj_is_separator(obj)) /* If a pane, attach to parent's edge */
|
if (obj_is_pane(obj) || obj_is_separator(obj)) /* If a pane, attach to parent's edge */
|
||||||
obj_set_attachment(xy_obj, AB_CP_EAST, AB_ATTACH_OBJ, obj_get_parent(xy_obj), 0);
|
obj_set_attachment(xy_obj, AB_CP_EAST, AB_ATTACH_OBJ, obj_get_parent(xy_obj), 0);
|
||||||
|
@ -569,7 +589,7 @@ abobj_resize(
|
||||||
|
|
||||||
if (resize_rect.y + (short)resize_rect.height > (short)p_rect.height)
|
if (resize_rect.y + (short)resize_rect.height > (short)p_rect.height)
|
||||||
{
|
{
|
||||||
resize_rect.height = (short)p_rect.height - resize_rect.y - 1;
|
resize_rect.height = max(0, (short)p_rect.height - resize_rect.y - 1);
|
||||||
|
|
||||||
if (obj_is_pane(obj) || obj_is_separator(obj)) /* If a pane, attach to parent's edge */
|
if (obj_is_pane(obj) || obj_is_separator(obj)) /* If a pane, attach to parent's edge */
|
||||||
obj_set_attachment(xy_obj, AB_CP_SOUTH, AB_ATTACH_OBJ, obj_get_parent(xy_obj), 0);
|
obj_set_attachment(xy_obj, AB_CP_SOUTH, AB_ATTACH_OBJ, obj_get_parent(xy_obj), 0);
|
||||||
|
@ -794,55 +814,84 @@ make_rect (
|
||||||
{
|
{
|
||||||
case NORTH:
|
case NORTH:
|
||||||
new_r->x = r->x;
|
new_r->x = r->x;
|
||||||
new_r->y = y;
|
new_r->y = min(y, rect_bottom(r));
|
||||||
new_r->width = r->width;
|
new_r->width = r->width;
|
||||||
new_r->height = (r->y + r->height) - y;
|
new_r->height = max(0, r->y + r->height - y);
|
||||||
break;
|
break;
|
||||||
case SOUTH:
|
case SOUTH:
|
||||||
new_r->x = r->x;
|
new_r->x = r->x;
|
||||||
new_r->y = r->y;
|
new_r->y = r->y;
|
||||||
new_r->width = r->width;
|
new_r->width = r->width;
|
||||||
new_r->height = y - r->y;
|
new_r->height = max(0, y - r->y);
|
||||||
break;
|
break;
|
||||||
case EAST:
|
case EAST:
|
||||||
new_r->x = r->x;
|
new_r->x = r->x;
|
||||||
new_r->y = r->y;
|
new_r->y = r->y;
|
||||||
new_r->width = x - r->x;
|
new_r->width = max(0, x - r->x);
|
||||||
new_r->height = r->height;
|
new_r->height = r->height;
|
||||||
break;
|
break;
|
||||||
case WEST:
|
case WEST:
|
||||||
new_r->x = x;
|
new_r->x = min(x, rect_right(r));
|
||||||
new_r->y = r->y;
|
new_r->y = r->y;
|
||||||
new_r->width = (r->x + r->width) - x;
|
new_r->width = max(0, r->x + r->width - x);
|
||||||
new_r->height = r->height;
|
new_r->height = r->height;
|
||||||
break;
|
break;
|
||||||
case NORTH_EAST:
|
case NORTH_EAST:
|
||||||
new_r->x = r->x;
|
new_r->x = r->x;
|
||||||
new_r->y = y;
|
new_r->y = min(y, rect_bottom(r));
|
||||||
new_r->width = x - r->x;
|
new_r->width = max(0, x - r->x);
|
||||||
new_r->height = (r->y + r->height) - y;
|
new_r->height = max(0, r->y + r->height - y);
|
||||||
break;
|
break;
|
||||||
case NORTH_WEST:
|
case NORTH_WEST:
|
||||||
new_r->x = x;
|
new_r->x = min(x, rect_right(r));
|
||||||
new_r->y = y;
|
new_r->y = min(y, rect_bottom(r));
|
||||||
new_r->width = (r->x + r->width) - x;
|
new_r->width = max(0, r->x + r->width - x);
|
||||||
new_r->height = (r->y + r->height) - y;
|
new_r->height = max(0, r->y + r->height - y);
|
||||||
break;
|
break;
|
||||||
case SOUTH_EAST:
|
case SOUTH_EAST:
|
||||||
new_r->x = r->x;
|
new_r->x = r->x;
|
||||||
new_r->y = r->y;
|
new_r->y = r->y;
|
||||||
new_r->width = x - r->x;
|
new_r->width = max(0, x - r->x);
|
||||||
new_r->height = y - r->y;
|
new_r->height = max(0, y - r->y);
|
||||||
break;
|
break;
|
||||||
case SOUTH_WEST:
|
case SOUTH_WEST:
|
||||||
new_r->x = x;
|
new_r->x = min(x, rect_right(r));
|
||||||
new_r->y = r->y;
|
new_r->y = r->y;
|
||||||
new_r->width = (r->x + r->width) - x;
|
new_r->width = max(0, r->x + r->width - x);
|
||||||
new_r->height = y - r->y;
|
new_r->height = max(0, y - r->y);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1063,9 +1063,7 @@ abobj_set_num_columns(
|
||||||
(obj_is_text(obj) || obj_is_term_pane(obj)))
|
(obj_is_text(obj) || obj_is_term_pane(obj)))
|
||||||
{
|
{
|
||||||
objxm_obj_set_ui_arg(subObj, AB_ARG_INT, XmNcolumns, num_cols);
|
objxm_obj_set_ui_arg(subObj, AB_ARG_INT, XmNcolumns, num_cols);
|
||||||
/*
|
if (obj_is_text(obj)) obj_clear_flag(obj, InstantiatedFlag);
|
||||||
obj_clear_flag(obj, InstantiatedFlag);
|
|
||||||
*/
|
|
||||||
obj_clear_flag(subObj, InstantiatedFlag);
|
obj_clear_flag(subObj, InstantiatedFlag);
|
||||||
}
|
}
|
||||||
else if (obj_is_choice(obj))
|
else if (obj_is_choice(obj))
|
||||||
|
|
|
@ -174,6 +174,8 @@ termp_initialize(
|
||||||
{
|
{
|
||||||
obj_set_num_rows(obj, 6);
|
obj_set_num_rows(obj, 6);
|
||||||
obj_set_num_columns(obj, 12);
|
obj_set_num_columns(obj, 12);
|
||||||
|
obj_set_width(obj, termp_init_width);
|
||||||
|
obj_set_height(obj, termp_init_width);
|
||||||
}
|
}
|
||||||
obj_set_process_string(obj, "/bin/csh");
|
obj_set_process_string(obj, "/bin/csh");
|
||||||
|
|
||||||
|
|
|
@ -720,7 +720,7 @@ ui_size_to_row_col(
|
||||||
XFontStruct *font;
|
XFontStruct *font;
|
||||||
unsigned long charwidth;
|
unsigned long charwidth;
|
||||||
unsigned long lineheight;
|
unsigned long lineheight;
|
||||||
Dimension pane_width, pane_height;
|
int pane_width, pane_height;
|
||||||
|
|
||||||
if (XtIsSubclass(text, dtTermWidgetClass))
|
if (XtIsSubclass(text, dtTermWidgetClass))
|
||||||
XtVaGetValues(text,
|
XtVaGetValues(text,
|
||||||
|
@ -776,8 +776,8 @@ ui_size_to_row_col(
|
||||||
pane_width = width - (vsb_width + spacing) - (2*p_margin_w);
|
pane_width = width - (vsb_width + spacing) - (2*p_margin_w);
|
||||||
pane_height = height - (hsb_height + spacing) - (2*p_margin_h);
|
pane_height = height - (hsb_height + spacing) - (2*p_margin_h);
|
||||||
|
|
||||||
*row_ptr = (int)((pane_height - (2*margin_h))/lineheight);
|
*row_ptr = (int)(max(0, pane_height - 2 * margin_h) / lineheight);
|
||||||
*col_ptr = (int)((pane_width - (2*margin_w))/charwidth);
|
*col_ptr = (int)(max(0, pane_width - 2 * margin_w) / charwidth);
|
||||||
|
|
||||||
/* For some reason, above calculations result in rows being 1 too
|
/* For some reason, above calculations result in rows being 1 too
|
||||||
* large for a scrolled list widget; put in workaround until
|
* large for a scrolled list widget; put in workaround until
|
||||||
|
|
Loading…
Reference in a new issue