Rename deco.c ssd.c

This commit is contained in:
Johan Malm 2021-03-20 14:41:39 +00:00
parent 15ffee79f9
commit a262b729df
9 changed files with 68 additions and 68 deletions

View file

@ -145,17 +145,17 @@ enum view_type {
#endif
};
enum deco_part {
LAB_DECO_NONE = 0,
LAB_DECO_BUTTON_CLOSE,
LAB_DECO_BUTTON_MAXIMIZE,
LAB_DECO_BUTTON_ICONIFY,
LAB_DECO_PART_TITLE,
LAB_DECO_PART_TOP,
LAB_DECO_PART_RIGHT,
LAB_DECO_PART_BOTTOM,
LAB_DECO_PART_LEFT,
LAB_DECO_END_MARKER
enum ssd_part {
LAB_SSD_NONE = 0,
LAB_SSD_BUTTON_CLOSE,
LAB_SSD_BUTTON_MAXIMIZE,
LAB_SSD_BUTTON_ICONIFY,
LAB_SSD_PART_TITLE,
LAB_SSD_PART_TOP,
LAB_SSD_PART_RIGHT,
LAB_SSD_PART_BOTTOM,
LAB_SSD_PART_LEFT,
LAB_SSD_END_MARKER
};
struct view_impl {
@ -345,10 +345,10 @@ void server_init(struct server *server);
void server_start(struct server *server);
void server_finish(struct server *server);
struct border deco_thickness(struct view *view);
struct wlr_box deco_max_extents(struct view *view);
struct wlr_box deco_box(struct view *view, enum deco_part deco_part);
enum deco_part deco_at(struct view *view, double lx, double ly);
struct border ssd_thickness(struct view *view);
struct wlr_box ssd_max_extents(struct view *view);
struct wlr_box ssd_box(struct view *view, enum ssd_part ssd_part);
enum ssd_part ssd_at(struct view *view, double lx, double ly);
void action(struct server *server, const char *action, const char *command);

View file

@ -140,7 +140,7 @@ process_cursor_motion(struct server *server, uint32_t time)
double sx, sy;
struct wlr_seat *wlr_seat = server->seat.seat;
struct wlr_surface *surface = NULL;
int view_area = LAB_DECO_NONE;
int view_area = LAB_SSD_NONE;
char *cursor_name = NULL;
struct view *view =
desktop_view_at(server, server->seat.cursor->x, server->seat.cursor->y,
@ -178,7 +178,7 @@ process_cursor_motion(struct server *server, uint32_t time)
}
if (resize_edges) {
cursor_name_set_by_server = true;
} else if (view_area != LAB_DECO_NONE) {
} else if (view_area != LAB_SSD_NONE) {
cursor_name = XCURSOR_DEFAULT;
cursor_name_set_by_server = true;
} else if (cursor_name_set_by_server) {
@ -319,16 +319,16 @@ cursor_button(struct wl_listener *listener, void *data)
}
switch (view_area) {
case LAB_DECO_BUTTON_CLOSE:
case LAB_SSD_BUTTON_CLOSE:
view->impl->close(view);
break;
case LAB_DECO_BUTTON_ICONIFY:
case LAB_SSD_BUTTON_ICONIFY:
view_minimize(view);
break;
case LAB_DECO_PART_TITLE:
case LAB_SSD_PART_TITLE:
interactive_begin(view, LAB_INPUT_STATE_MOVE, 0);
break;
case LAB_DECO_BUTTON_MAXIMIZE:
case LAB_SSD_BUTTON_MAXIMIZE:
view_maximize(view, !view->maximized);
break;
}

View file

@ -246,8 +246,8 @@ desktop_view_at(struct server *server, double lx, double ly,
if (!view->server_side_deco) {
continue;
}
*view_area = deco_at(view, lx, ly);
if (*view_area != LAB_DECO_NONE) {
*view_area = ssd_at(view, lx, ly);
if (*view_area != LAB_SSD_NONE) {
return view;
}
}

View file

@ -2,7 +2,6 @@ labwc_sources = files(
'action.c',
'cursor.c',
'damage.c',
'deco.c',
'desktop.c',
'interactive.c',
'keyboard.c',
@ -12,6 +11,7 @@ labwc_sources = files(
'output.c',
'seat.c',
'server.c',
'ssd.c',
'subsurface.c',
'theme.c',
'view.c',

View file

@ -432,11 +432,11 @@ render_icon(struct output *output, pixman_region32_t *output_damage,
}
static bool
isbutton(enum deco_part deco_part)
isbutton(enum ssd_part ssd_part)
{
return deco_part == LAB_DECO_BUTTON_CLOSE ||
deco_part == LAB_DECO_BUTTON_MAXIMIZE ||
deco_part == LAB_DECO_BUTTON_ICONIFY;
return ssd_part == LAB_SSD_BUTTON_CLOSE ||
ssd_part == LAB_SSD_BUTTON_MAXIMIZE ||
ssd_part == LAB_SSD_BUTTON_ICONIFY;
}
static void
@ -451,14 +451,14 @@ render_deco(struct view *view, struct output *output,
/* render border */
float *color = theme->window_active_handle_bg_color;
enum deco_part border[4] = {
LAB_DECO_PART_TOP,
LAB_DECO_PART_RIGHT,
LAB_DECO_PART_BOTTOM,
LAB_DECO_PART_LEFT,
enum ssd_part border[4] = {
LAB_SSD_PART_TOP,
LAB_SSD_PART_RIGHT,
LAB_SSD_PART_BOTTOM,
LAB_SSD_PART_LEFT,
};
for (int i = 0; i < 4; i++) {
struct wlr_box box = deco_box(view, border[i]);
struct wlr_box box = ssd_box(view, border[i]);
scale_box(&box, output->wlr_output->scale);
render_rect(output, output_damage, &box, color);
}
@ -470,16 +470,16 @@ render_deco(struct view *view, struct output *output,
} else {
color = theme->window_inactive_title_bg_color;
}
struct wlr_box box = deco_box(view, LAB_DECO_PART_TITLE);
struct wlr_box box = ssd_box(view, LAB_SSD_PART_TITLE);
scale_box(&box, output->wlr_output->scale);
render_rect(output, output_damage, &box, color);
/* button background */
struct wlr_cursor *cur = view->server->seat.cursor;
enum deco_part deco_part = deco_at(view, cur->x, cur->y);
box = deco_box(view, deco_part);
enum ssd_part ssd_part = ssd_at(view, cur->x, cur->y);
box = ssd_box(view, ssd_part);
scale_box(&box, output->wlr_output->scale);
if (isbutton(deco_part) &&
if (isbutton(ssd_part) &&
wlr_box_contains_point(&box, cur->x, cur->y)) {
color = (float[4]){ 0.5, 0.5, 0.5, 0.5 };
render_rect(output, output_damage, &box, color);
@ -487,28 +487,28 @@ render_deco(struct view *view, struct output *output,
/* buttons */
if (view->surface == seat->keyboard_state.focused_surface) {
box = deco_box(view, LAB_DECO_BUTTON_CLOSE);
box = ssd_box(view, LAB_SSD_BUTTON_CLOSE);
scale_box(&box, output->wlr_output->scale);
render_icon(output, output_damage, &box,
theme->xbm_close_active_unpressed);
box = deco_box(view, LAB_DECO_BUTTON_MAXIMIZE);
box = ssd_box(view, LAB_SSD_BUTTON_MAXIMIZE);
scale_box(&box, output->wlr_output->scale);
render_icon(output, output_damage, &box,
theme->xbm_maximize_active_unpressed);
box = deco_box(view, LAB_DECO_BUTTON_ICONIFY);
box = ssd_box(view, LAB_SSD_BUTTON_ICONIFY);
scale_box(&box, output->wlr_output->scale);
render_icon(output, output_damage, &box,
theme->xbm_iconify_active_unpressed);
} else {
box = deco_box(view, LAB_DECO_BUTTON_CLOSE);
box = ssd_box(view, LAB_SSD_BUTTON_CLOSE);
scale_box(&box, output->wlr_output->scale);
render_icon(output, output_damage, &box,
theme->xbm_close_inactive_unpressed);
box = deco_box(view, LAB_DECO_BUTTON_MAXIMIZE);
box = ssd_box(view, LAB_SSD_BUTTON_MAXIMIZE);
scale_box(&box, output->wlr_output->scale);
render_icon(output, output_damage, &box,
theme->xbm_maximize_inactive_unpressed);
box = deco_box(view, LAB_DECO_BUTTON_ICONIFY);
box = ssd_box(view, LAB_SSD_BUTTON_ICONIFY);
scale_box(&box, output->wlr_output->scale);
render_icon(output, output_damage, &box,
theme->xbm_iconify_inactive_unpressed);

View file

@ -11,7 +11,7 @@
#define BORDER_WIDTH (2)
struct border
deco_thickness(struct view *view)
ssd_thickness(struct view *view)
{
struct border border = {
.top = rc.title_height + BORDER_WIDTH,
@ -23,9 +23,9 @@ deco_thickness(struct view *view)
}
struct wlr_box
deco_max_extents(struct view *view)
ssd_max_extents(struct view *view)
{
struct border border = deco_thickness(view);
struct border border = ssd_thickness(view);
struct wlr_box box = {
.x = view->x - border.left,
.y = view->y - border.top,
@ -36,54 +36,54 @@ deco_max_extents(struct view *view)
}
struct wlr_box
deco_box(struct view *view, enum deco_part deco_part)
ssd_box(struct view *view, enum ssd_part ssd_part)
{
struct wlr_box box = { 0 };
assert(view);
switch (deco_part) {
case LAB_DECO_BUTTON_CLOSE:
switch (ssd_part) {
case LAB_SSD_BUTTON_CLOSE:
box.width = rc.title_height;
box.height = rc.title_height;
box.x = view->x + view->w - rc.title_height;
box.y = view->y - rc.title_height;
break;
case LAB_DECO_BUTTON_MAXIMIZE:
case LAB_SSD_BUTTON_MAXIMIZE:
box.width = rc.title_height;
box.height = rc.title_height;
box.x = view->x + view->w - rc.title_height * 2;
box.y = view->y - rc.title_height;
break;
case LAB_DECO_BUTTON_ICONIFY:
case LAB_SSD_BUTTON_ICONIFY:
box.width = rc.title_height;
box.height = rc.title_height;
box.x = view->x + view->w - rc.title_height * 3;
box.y = view->y - rc.title_height;
break;
case LAB_DECO_PART_TITLE:
case LAB_SSD_PART_TITLE:
box.x = view->x;
box.y = view->y - rc.title_height;
box.width = view->w;
box.height = rc.title_height;
break;
case LAB_DECO_PART_TOP:
case LAB_SSD_PART_TOP:
box.x = view->x - BORDER_WIDTH;
box.y = view->y - rc.title_height - BORDER_WIDTH;
box.width = view->w + 2 * BORDER_WIDTH;
box.height = BORDER_WIDTH;
break;
case LAB_DECO_PART_RIGHT:
case LAB_SSD_PART_RIGHT:
box.x = view->x + view->w;
box.y = view->y - rc.title_height;
box.width = BORDER_WIDTH;
box.height = view->h + rc.title_height;
break;
case LAB_DECO_PART_BOTTOM:
case LAB_SSD_PART_BOTTOM:
box.x = view->x - BORDER_WIDTH;
box.y = view->y + view->h;
box.width = view->w + 2 * BORDER_WIDTH;
box.height = +BORDER_WIDTH;
break;
case LAB_DECO_PART_LEFT:
case LAB_SSD_PART_LEFT:
box.x = view->x - BORDER_WIDTH;
box.y = view->y - rc.title_height;
box.width = BORDER_WIDTH;
@ -95,15 +95,15 @@ deco_box(struct view *view, enum deco_part deco_part)
return box;
}
enum deco_part
deco_at(struct view *view, double lx, double ly)
enum ssd_part
ssd_at(struct view *view, double lx, double ly)
{
enum deco_part deco_part;
for (deco_part = 0; deco_part < LAB_DECO_END_MARKER; ++deco_part) {
struct wlr_box box = deco_box(view, deco_part);
enum ssd_part ssd_part;
for (ssd_part = 0; ssd_part < LAB_SSD_END_MARKER; ++ssd_part) {
struct wlr_box box = ssd_box(view, ssd_part);
if (wlr_box_contains_point(&box, lx, ly)) {
return deco_part;
return ssd_part;
}
}
return LAB_DECO_NONE;
return LAB_SSD_NONE;
}

View file

@ -77,7 +77,7 @@ view_maximize(struct view *view, bool maximize)
.height = output->height,
};
if (view->server_side_deco) {
struct border border = deco_thickness(view);
struct border border = ssd_thickness(view);
box.x += border.left;
box.y += border.top;
box.width -= border.right + border.left;

View file

@ -254,7 +254,7 @@ xdg_toplevel_view_map(struct view *view)
view->server_side_deco = has_ssd(view);
if (view->server_side_deco) {
view->margin = deco_thickness(view);
view->margin = ssd_thickness(view);
}
update_padding(view);
position_xdg_toplevel_view(view);

View file

@ -124,7 +124,7 @@ want_deco(struct view *view)
static void
top_left_edge_boundary_check(struct view *view)
{
struct wlr_box deco = deco_max_extents(view);
struct wlr_box deco = ssd_max_extents(view);
if (deco.x < 0) {
view->x -= deco.x;
}
@ -148,7 +148,7 @@ map(struct view *view)
view->surface = view->xwayland_surface->surface;
view->server_side_deco = want_deco(view);
view->margin = deco_thickness(view);
view->margin = ssd_thickness(view);
top_left_edge_boundary_check(view);