Support child frame border width

* src/pgtkfns.c (x_set_child_frame_border_width): Port code for X.
(pgtk_frame_parm_handlers): Add hook.
(Fx_create_frame): Get default parameter.
* src/pgtkterm.c (x_draw_stretch_glyph_string): Re-port code for X.
(pgtk_clear_under_internal_border): Re-port code for X.
This commit is contained in:
Yuuki Harano 2021-01-31 00:49:56 +09:00
parent 50c76b844b
commit ae18c8ec4f
2 changed files with 82 additions and 29 deletions

View file

@ -534,6 +534,24 @@ x_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
}
static void
x_set_child_frame_border_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{
int border = check_int_nonnegative (arg);
if (border != FRAME_CHILD_FRAME_BORDER_WIDTH (f))
{
f->child_frame_border_width = border;
if (FRAME_X_WINDOW (f))
{
adjust_frame_size (f, -1, -1, 3, false, Qchild_frame_border_width);
pgtk_clear_under_internal_border (f);
}
}
}
static void
x_set_internal_border_width (struct frame *f, Lisp_Object arg,
@ -963,6 +981,7 @@ frame_parm_handler pgtk_frame_parm_handlers[] = {
x_set_foreground_color,
x_set_icon_name,
x_set_icon_type,
x_set_child_frame_border_width,
x_set_internal_border_width, /* generic OK */
gui_set_right_divider_width,
gui_set_bottom_divider_width,
@ -1422,6 +1441,25 @@ This function is an internal primitive--use `make-frame' instead. */ )
if (!EQ (value, Qunbound))
parms = Fcons (Fcons (Qinternal_border_width, value), parms);
}
/* Same for child frames. */
if (NILP (Fassq (Qchild_frame_border_width, parms)))
{
Lisp_Object value;
value = gui_display_get_arg (dpyinfo, parms, Qchild_frame_border_width,
"childFrameBorderWidth", "childFrameBorderWidth",
RES_TYPE_NUMBER);
if (! EQ (value, Qunbound))
parms = Fcons (Fcons (Qchild_frame_border_width, value),
parms);
}
gui_default_parameter (f, parms, Qchild_frame_border_width,
make_fixnum (0),
"childFrameBorderWidth", "childFrameBorderWidth",
RES_TYPE_NUMBER);
gui_default_parameter (f, parms, Qinternal_border_width,
make_fixnum (0),
"internalBorderWidth", "internalBorderWidth",

View file

@ -2367,14 +2367,29 @@ x_draw_stretch_glyph_string (struct glyph_string *s)
else if (!s->background_filled_p)
{
int background_width = s->background_width;
int x = s->x, left_x = window_box_left_offset (s->w, TEXT_AREA);
int x = s->x, text_left_x = window_box_left_offset (s->w, TEXT_AREA);
/* Don't draw into left margin, fringe or scrollbar area
except for header line and mode line. */
if (x < left_x && !s->row->mode_line_p)
/* Don't draw into left fringe or scrollbar area except for
header line and mode line. */
if (x < text_left_x && !s->row->mode_line_p)
{
background_width -= left_x - x;
x = left_x;
int left_x = WINDOW_LEFT_SCROLL_BAR_AREA_WIDTH (s->w);
int right_x = text_left_x;
if (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (s->w))
left_x += WINDOW_LEFT_FRINGE_WIDTH (s->w);
else
right_x -= WINDOW_LEFT_FRINGE_WIDTH (s->w);
/* Adjust X and BACKGROUND_WIDTH to fit inside the space
between LEFT_X and RIGHT_X. */
if (x < left_x)
{
background_width -= left_x - x;
x = left_x;
}
if (x + background_width > right_x)
background_width = right_x - x;
}
if (background_width > 0)
x_draw_glyph_string_bg_rect (s, x, s->y, background_width, s->height);
@ -5261,37 +5276,37 @@ pgtk_clear_under_internal_border (struct frame *f)
int border = FRAME_INTERNAL_BORDER_WIDTH (f);
int width = FRAME_PIXEL_WIDTH (f);
int height = FRAME_PIXEL_HEIGHT (f);
int margin = 0;
struct face *face = FACE_FROM_ID_OR_NULL (f, INTERNAL_BORDER_FACE_ID);
int margin = FRAME_TOP_MARGIN_HEIGHT (f);
int face_id =
(FRAME_PARENT_FRAME (f)
? (!NILP (Vface_remapping_alist)
? lookup_basic_face (NULL, f, CHILD_FRAME_BORDER_FACE_ID)
: CHILD_FRAME_BORDER_FACE_ID)
: (!NILP (Vface_remapping_alist)
? lookup_basic_face (NULL, f, INTERNAL_BORDER_FACE_ID)
: INTERNAL_BORDER_FACE_ID));
struct face *face = FACE_FROM_ID_OR_NULL (f, face_id);
block_input ();
struct
{
int x, y, w, h;
} rects[] = {
{0, margin, width, border},
{0, 0, border, height},
{width - border, 0, border, height},
{0, height - border, width, border},
};
if (face)
{
for (int i = 0; i < 4; i++)
{
int x = rects[i].x;
int y = rects[i].y;
int w = rects[i].w;
int h = rects[i].h;
fill_background_by_face (f, face, x, y, w, h);
}
#define x_fill_rectangle(f, gc, x, y, w, h) \
fill_background_by_face (f, face, x, y, w, h)
x_fill_rectangle (f, gc, 0, margin, width, border);
x_fill_rectangle (f, gc, 0, 0, border, height);
x_fill_rectangle (f, gc, width - border, 0, border, height);
x_fill_rectangle (f, gc, 0, height - border, width, border);
#undef x_fill_rectangle
}
else
{
for (int i = 0; i < 4; i++)
pgtk_clear_area (f, rects[i].x, rects[i].y, rects[i].w,
rects[i].h);
#define x_clear_area(f, x, y, w, h) pgtk_clear_area (f, x, y, w, h)
x_clear_area (f, 0, 0, border, height);
x_clear_area (f, 0, margin, width, border);
x_clear_area (f, width - border, 0, border, height);
x_clear_area (f, 0, height - border, width, border);
#undef x_clear_area
}
unblock_input ();