about summary refs log tree commit diff
path: root/main.c
diff options
context:
space:
mode:
authorArenM <aren@peacevolution.org>2022-07-04 23:46:18 -0400
committerZach DeCook <zachdecook@librem.one>2022-07-11 01:09:04 -0400
commit8e52756a9c00e9ac7816c1ca0261d8077a8be0a5 (patch)
tree6a95c6105b9a03084b723eaa64ddbe78beb590fa /main.c
parent6566a7f57d695d888650d43225844f9641414919 (diff)
downloadsuggpicker-8e52756a9c00e9ac7816c1ca0261d8077a8be0a5.tar.gz
Use output dimensions to detect landscape mode
Based off of a commit in wvkbd

Most displays are in landscape mode by default, so checking to see if
it's rotated will produce the exact opposite of the expected results.
Diffstat (limited to 'main.c')
-rw-r--r--main.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/main.c b/main.c
index 563baae..ad9ffef 100644
--- a/main.c
+++ b/main.c
@@ -238,14 +238,19 @@ static void
 display_handle_geometry(void *data, struct wl_output *wl_output, int x, int y,
                         int physical_width, int physical_height, int subpixel,
                         const char *make, const char *model, int transform) {
-	if (transform % 2 == 0 && keyboard.landscape) {
-		keyboard.landscape = false;
-		height = normal_height;
-	} else if (transform % 2 != 0 && !keyboard.landscape) {
-		keyboard.landscape = true;
+	// Swap width and height on rotated displays
+	if (transform % 2 != 0) {
+		int tmp = physical_width;
+		physical_width = physical_height;
+		physical_height = tmp;
+	}
+	bool landscape = physical_width > physical_height;
+	if (landscape == keyboard.landscape) return;
+	keyboard.landscape = landscape;
+	if (keyboard.landscape) {
 		height = landscape_height;
 	} else {
-		return; // no changes
+		height = normal_height;
 	}
 
 	zwlr_layer_surface_v1_set_size(layer_surface, 0, height);