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 #endif
}; };
enum deco_part { enum ssd_part {
LAB_DECO_NONE = 0, LAB_SSD_NONE = 0,
LAB_DECO_BUTTON_CLOSE, LAB_SSD_BUTTON_CLOSE,
LAB_DECO_BUTTON_MAXIMIZE, LAB_SSD_BUTTON_MAXIMIZE,
LAB_DECO_BUTTON_ICONIFY, LAB_SSD_BUTTON_ICONIFY,
LAB_DECO_PART_TITLE, LAB_SSD_PART_TITLE,
LAB_DECO_PART_TOP, LAB_SSD_PART_TOP,
LAB_DECO_PART_RIGHT, LAB_SSD_PART_RIGHT,
LAB_DECO_PART_BOTTOM, LAB_SSD_PART_BOTTOM,
LAB_DECO_PART_LEFT, LAB_SSD_PART_LEFT,
LAB_DECO_END_MARKER LAB_SSD_END_MARKER
}; };
struct view_impl { struct view_impl {
@ -345,10 +345,10 @@ void server_init(struct server *server);
void server_start(struct server *server); void server_start(struct server *server);
void server_finish(struct server *server); void server_finish(struct server *server);
struct border deco_thickness(struct view *view); struct border ssd_thickness(struct view *view);
struct wlr_box deco_max_extents(struct view *view); struct wlr_box ssd_max_extents(struct view *view);
struct wlr_box deco_box(struct view *view, enum deco_part deco_part); struct wlr_box ssd_box(struct view *view, enum ssd_part ssd_part);
enum deco_part deco_at(struct view *view, double lx, double ly); enum ssd_part ssd_at(struct view *view, double lx, double ly);
void action(struct server *server, const char *action, const char *command); 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; double sx, sy;
struct wlr_seat *wlr_seat = server->seat.seat; struct wlr_seat *wlr_seat = server->seat.seat;
struct wlr_surface *surface = NULL; struct wlr_surface *surface = NULL;
int view_area = LAB_DECO_NONE; int view_area = LAB_SSD_NONE;
char *cursor_name = NULL; char *cursor_name = NULL;
struct view *view = struct view *view =
desktop_view_at(server, server->seat.cursor->x, server->seat.cursor->y, 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) { if (resize_edges) {
cursor_name_set_by_server = true; 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 = XCURSOR_DEFAULT;
cursor_name_set_by_server = true; cursor_name_set_by_server = true;
} else if (cursor_name_set_by_server) { } else if (cursor_name_set_by_server) {
@ -319,16 +319,16 @@ cursor_button(struct wl_listener *listener, void *data)
} }
switch (view_area) { switch (view_area) {
case LAB_DECO_BUTTON_CLOSE: case LAB_SSD_BUTTON_CLOSE:
view->impl->close(view); view->impl->close(view);
break; break;
case LAB_DECO_BUTTON_ICONIFY: case LAB_SSD_BUTTON_ICONIFY:
view_minimize(view); view_minimize(view);
break; break;
case LAB_DECO_PART_TITLE: case LAB_SSD_PART_TITLE:
interactive_begin(view, LAB_INPUT_STATE_MOVE, 0); interactive_begin(view, LAB_INPUT_STATE_MOVE, 0);
break; break;
case LAB_DECO_BUTTON_MAXIMIZE: case LAB_SSD_BUTTON_MAXIMIZE:
view_maximize(view, !view->maximized); view_maximize(view, !view->maximized);
break; break;
} }

View file

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

View file

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

View file

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

View file

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

View file

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