3 Commits 6ba71726d5 ... cb355324d6

Author SHA1 Message Date
  Leon Plickat cb355324d6 Selection box filler 4 years ago
  Leon Plickat eefd6d82b9 README update 4 years ago
  Leon Plickat 237d2ae49c Shadows 4 years ago
4 changed files with 123 additions and 46 deletions
  1. 1 0
      README.md
  2. 8 0
      include/colors.h
  3. 1 0
      include/server.h
  4. 113 46
      output.c

+ 1 - 0
README.md

@@ -22,6 +22,7 @@ These are the differences between wio and wio+.
   gaps between the windows)
 * Different defaults
 * Primitive fullscreen with "Fill" menu entry
+* Shadows
 
 ## Planned changes
 

+ 8 - 0
include/colors.h

@@ -9,6 +9,10 @@ static const float selection_box[4] = {
 	255.0f, 0.0f, 0.0f, 1.0f,
 };
 
+static const float selection_filler[4] = {
+	0x66 / 255.0f, 0x66 / 255.0f, 0x66 / 255.0f, 0.4f,
+};
+
 static const float active_border[4] = {
 	255.0f, 255.0f, 255.0f, 1.0f,
 };
@@ -17,6 +21,10 @@ static const float inactive_border[4] = {
 	0x78 / 255.0f, 0xAD / 255.0f, 0x84 / 255.0f, 1.0f,
 };
 
+static const float shadow[4] = {
+	0x00 / 255.0f, 0x00 / 255.0f, 0x00 / 255.0f, 0.4f,
+};
+
 static const float menu_selected[4] = {
 	0x3D / 255.0f, 0x7D / 255.0f, 0x42 / 255.0f, 1.0f,
 };

+ 1 - 0
include/server.h

@@ -17,6 +17,7 @@
 static const int window_border = 10;
 static const int inner_gaps    = 20;
 static const int outer_gaps    = 40;
+static const int shadow_width  = 10;
 
 enum wio_input_state {
 	INPUT_STATE_NONE = 0,

+ 113 - 46
output.c

@@ -170,57 +170,124 @@ static void render_menu(struct wio_output *output) {
 	server->menu.height = text_height;
 }
 
-static void render_view_border(struct wlr_renderer *renderer,
-		struct wio_output *output, struct wio_view *view,
-		int x, int y, int width, int height,
-		int selection) {
+static void render_view_border(struct wlr_renderer *renderer, struct wio_output *output, struct wio_view *view, int x, int y, int width, int height, int selection)
+{
 	float color[4];
-	if (selection) {
+	if (selection)
 		memcpy(color, selection_box, sizeof(color));
-	} else if (!view || view->xdg_surface->toplevel->current.activated) {
+	else if (!view || view->xdg_surface->toplevel->current.activated)
 		memcpy(color, active_border, sizeof(color));
-	} else {
+	else
 		memcpy(color, inactive_border, sizeof(color));
-	}
+
 	struct wlr_output *wlr_output = output->wlr_output;
-	int scale = wlr_output->scale;
-	double ox = 0, oy = 0;
-	wlr_output_layout_output_coords(
-			output->server->output_layout, wlr_output, &ox, &oy);
-	ox *= scale, oy *= scale;
-	struct wlr_box borders;
-	// Top
-	borders.x = (x - window_border) * scale;
-	borders.x += ox;
-	borders.y = (y - window_border) * scale;
-	borders.y += oy;
-	borders.width = (width + window_border * 2) * scale;
-	borders.height = window_border * scale;
-	wlr_render_rect(renderer, &borders, color, wlr_output->transform_matrix);
-	// Right
-	borders.x = (x + width) * scale;
-	borders.x += ox;
-	borders.y = (y - window_border) * scale;
-	borders.y += oy;
-	borders.width = window_border * scale;
-	borders.height = (height + window_border * 2) * scale;
-	wlr_render_rect(renderer, &borders, color, wlr_output->transform_matrix);
-	// Bottom
-	borders.x = (x - window_border) * scale;
-	borders.x += ox;
-	borders.y = (y + height) * scale;
-	borders.y += oy;
-	borders.width = (width + window_border * 2) * scale;
-	borders.height = window_border * scale;
-	wlr_render_rect(renderer, &borders, color, wlr_output->transform_matrix);
-	// Left
-	borders.x = (x - window_border) * scale;
-	borders.x += ox;
-	borders.y = (y - window_border) * scale;
-	borders.y += oy;
-	borders.width = window_border * scale;
-	borders.height = (height + window_border * 2) * scale;
-	wlr_render_rect(renderer, &borders, color, wlr_output->transform_matrix);
+	int                scale      = wlr_output->scale;
+	double             ox         = 0;
+	double             oy         = 0;
+	struct wlr_box     borders;
+
+	wlr_output_layout_output_coords(output->server->output_layout,
+			wlr_output,
+			&ox,
+			&oy);
+	ox *= scale;
+	oy *= scale;
+
+	/* Top */
+	borders.x       = (x - window_border) * scale;
+	borders.x      += ox;
+	borders.y       = (y - window_border) * scale;
+	borders.y      += oy;
+	borders.width   = (width + window_border * 2) * scale;
+	borders.height  = window_border * scale;
+	wlr_render_rect(renderer,
+			&borders,
+			color,
+			wlr_output->transform_matrix);
+
+	/* Right */
+	borders.x       = (x + width) * scale;
+	borders.x      += ox;
+	borders.y       = (y - window_border) * scale;
+	borders.y      += oy;
+	borders.width   = window_border * scale;
+	borders.height  = (height + window_border * 2) * scale;
+	wlr_render_rect(renderer,
+			&borders,
+			color,
+			wlr_output->transform_matrix);
+
+	/* Bottom */
+	borders.x       = (x - window_border) * scale;
+	borders.x      += ox;
+	borders.y       = (y + height) * scale;
+	borders.y      += oy;
+	borders.width   = (width + window_border * 2) * scale;
+	borders.height  = window_border * scale;
+	wlr_render_rect(renderer,
+			&borders,
+			color,
+			wlr_output->transform_matrix);
+
+	/* Left */
+	borders.x       = (x - window_border) * scale;
+	borders.x      += ox;
+	borders.y       = (y - window_border) * scale;
+	borders.y      += oy;
+	borders.width   = window_border * scale;
+	borders.height  = (height + window_border * 2) * scale;
+	wlr_render_rect(renderer,
+			&borders,
+			color,
+			wlr_output->transform_matrix);
+
+	/* Filler */
+	if (selection)
+	{
+		memcpy(color, selection_filler, sizeof(color));
+		borders.x       = x * scale;
+		borders.x      += ox;
+		borders.y       = y * scale;
+		borders.y      += oy;
+		borders.width   = width * scale;
+		borders.height  = height * scale;
+		wlr_render_rect(renderer,
+				&borders,
+				color,
+				wlr_output->transform_matrix);
+	}
+
+	/* Shadow */
+	else if (shadow_width)
+	{
+		memcpy(color, shadow, sizeof(color));
+
+		/* Right */
+		borders.x       = (x + width) * scale;
+		borders.x      += window_border * scale;
+		borders.x      += ox;
+		borders.y       = (y + shadow_width - window_border) * scale;
+		borders.y      += oy;
+		borders.width   = shadow_width * scale;
+		borders.height  = (height + window_border * 2) * scale;
+		wlr_render_rect(renderer,
+				&borders,
+				color,
+				wlr_output->transform_matrix);
+
+		/* Bottom */
+		borders.x       = (x + shadow_width - window_border) * scale;
+		borders.x      += ox;
+		borders.y       = (y + height) * scale;
+		borders.y      += window_border * scale;
+		borders.y      += oy;
+		borders.width   = (width + window_border * 2 - shadow_width) * scale;
+		borders.height  = shadow_width * scale;
+		wlr_render_rect(renderer,
+				&borders,
+				color,
+				wlr_output->transform_matrix);
+	}
 }
 
 struct render_data_layer {