Browse Source

decorations: single pixel exposed edges on tiled windows

K. Lange 3 years ago
parent
commit
f7eb386d81
5 changed files with 76 additions and 20 deletions
  1. 32 5
      apps/compositor.c
  2. 5 1
      base/usr/include/toaru/decorations.h
  3. 7 2
      base/usr/include/toaru/yutani.h
  4. 30 7
      lib/decor-fancy.c
  5. 2 5
      lib/yutani.c

+ 32 - 5
apps/compositor.c

@@ -1342,10 +1342,8 @@ static void window_tile(yutani_globals_t * yg, yutani_server_window_t * window,
 
 	int w = yg->width / width_div;
 	int h = (yg->height - panel_h) / height_div;
-
-	/* Calculate, move, etc. */
-	window_move(yg, window, w * x, panel_h + h * y);
-
+	int _x = w * x;
+	int _y = panel_h + h * y;
 	if (x == width_div - 1) {
 		w = yg->width - w * x;
 	}
@@ -1353,8 +1351,37 @@ static void window_tile(yutani_globals_t * yg, yutani_server_window_t * window,
 		h = (yg->height - panel_h) - h * y;
 	}
 
+	int tile = YUTANI_RESIZE_TILED;
+
+	/* If not left most */
+	if (x > 0) {
+		_x -= 1;
+		w++;
+		tile &= ~YUTANI_RESIZE_TILE_LEFT;
+	}
+
+	/* If not right most */
+	if (x < width_div) {
+		w++;
+		tile &= ~YUTANI_RESIZE_TILE_RIGHT;
+	}
+
+	/* If not top most */
+	if (y > 0) {
+		_y -= 1;
+		h++;
+		tile &= ~YUTANI_RESIZE_TILE_UP;
+	}
+
+	/* If not bottom most */
+	if (y < height_div) {
+		h++;
+		tile &= ~YUTANI_RESIZE_TILE_DOWN;
+	}
+
+	window_move(yg, window, _x, _y);
 	yutani_msg_buildx_window_resize_alloc(response);
-	yutani_msg_buildx_window_resize(response, YUTANI_MSG_RESIZE_OFFER, window->wid, w, h, 0, YUTANI_RESIZE_TILED);
+	yutani_msg_buildx_window_resize(response, YUTANI_MSG_RESIZE_OFFER, window->wid, w, h, 0, tile);
 	pex_send(yg->server, window->owner, response->size, (char *)response);
 }
 

+ 5 - 1
base/usr/include/toaru/decorations.h

@@ -65,4 +65,8 @@ extern yutani_window_t * decor_show_default_menu(yutani_window_t * window, int y
 
 #define DECOR_FLAG_DECORATED   (1 << 0)
 #define DECOR_FLAG_NO_MAXIMIZE (1 << 1)
-#define DECOR_FLAG_TILED       (1 << 2)
+#define DECOR_FLAG_TILED       (0xF << 2)
+#define DECOR_FLAG_TILE_LEFT   (0x1 << 2)
+#define DECOR_FLAG_TILE_RIGHT  (0x2 << 2)
+#define DECOR_FLAG_TILE_UP     (0x4 << 2)
+#define DECOR_FLAG_TILE_DOWN   (0x8 << 2)

+ 7 - 2
base/usr/include/toaru/yutani.h

@@ -450,8 +450,13 @@ struct yutani_msg_clipboard {
  *
  * Flags provided in resize offers describing the window state.
  */
-#define YUTANI_RESIZE_NORMAL 0
-#define YUTANI_RESIZE_TILED  1
+#define YUTANI_RESIZE_NORMAL 0x00000000
+#define YUTANI_RESIZE_TILED  0x0000000f
+
+#define YUTANI_RESIZE_TILE_LEFT  0x00000001
+#define YUTANI_RESIZE_TILE_RIGHT 0x00000002
+#define YUTANI_RESIZE_TILE_UP    0x00000004
+#define YUTANI_RESIZE_TILE_DOWN  0x00000008
 
 typedef struct {
 	int x;

+ 30 - 7
lib/decor-fancy.c

@@ -52,11 +52,11 @@ static int get_bounds_fancy(yutani_window_t * window, struct decor_bounds * boun
 		bounds->left_width = 6;
 		bounds->right_width = 6;
 	} else {
-		/* TODO: Window type */
-		bounds->top_height = 27;
-		bounds->bottom_height = 0;
-		bounds->left_width = 0;
-		bounds->right_width = 0;
+		/* Any "exposed" edge gets an extra pixel. */
+		bounds->top_height = 27 + !(window->decorator_flags & DECOR_FLAG_TILE_UP);
+		bounds->bottom_height   = !(window->decorator_flags & DECOR_FLAG_TILE_DOWN);
+		bounds->left_width      = !(window->decorator_flags & DECOR_FLAG_TILE_LEFT);
+		bounds->right_width     = !(window->decorator_flags & DECOR_FLAG_TILE_RIGHT);
 	}
 
 	bounds->width = bounds->left_width + bounds->right_width;
@@ -81,11 +81,34 @@ static void render_decorations_fancy(yutani_window_t * window, gfx_context_t * c
 
 	if ((window->decorator_flags & DECOR_FLAG_TILED)) {
 		for (int i = 0; i < width; ++i) {
-			draw_sprite(ctx, sprites[decors_active + 1], i, -6);
+			draw_sprite(ctx, sprites[decors_active + 1], i, -6 + !(window->decorator_flags & DECOR_FLAG_TILE_UP));
 		}
+
+		uint32_t clear_color = rgb(62,62,62);
+		if (!(window->decorator_flags & DECOR_FLAG_TILE_DOWN)) {
+			/* Draw bottom line */
+			for (int i = 0; i < (int)window->width; ++i) {
+				GFX(ctx,i,window->height-1) = clear_color;
+			}
+		}
+
+		if (!(window->decorator_flags & DECOR_FLAG_TILE_LEFT)) {
+			/* Draw left line */
+			for (int i = 0; i < (int)window->height; ++i) {
+				GFX(ctx,0,i) = clear_color;
+			}
+		}
+
+		if (!(window->decorator_flags & DECOR_FLAG_TILE_RIGHT)) {
+			/* Draw right line */
+			for (int i = 0; i < (int)window->height; ++i) {
+				GFX(ctx,window->width-1,i) = clear_color;
+			}
+		}
+
 	} else {
 
-		uint32_t clear_color = ((window->decorator_flags & DECOR_FLAG_TILED) ? rgb(62,62,62) : 0);
+		uint32_t clear_color = 0x000000;
 
 		for (int j = (int)bounds.top_height; j < height - (int)bounds.bottom_height; ++j) {
 			for (int i = 0; i < (int)bounds.left_width; ++i) {

+ 2 - 5
lib/yutani.c

@@ -93,11 +93,8 @@ static void _handle_internal(yutani_t * y, yutani_msg_t * out) {
 				struct yutani_msg_window_resize * wr = (void *)out->data;
 				yutani_window_t * win = hashmap_get(y->windows, (void *)wr->wid);
 				if (win) {
-					if (wr->flags & YUTANI_RESIZE_TILED) {
-						win->decorator_flags |= (DECOR_FLAG_TILED);
-					} else {
-						win->decorator_flags &= ~(DECOR_FLAG_TILED);
-					}
+					win->decorator_flags &= ~(DECOR_FLAG_TILED);
+					win->decorator_flags |= (wr->flags & YUTANI_RESIZE_TILED) << 2;
 				}
 			}
 		default: