mirror of
https://github.com/jjsullivan5196/wvkbd.git
synced 2025-03-13 02:42:47 +01:00
Use output dimensions to detect landscape mode
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. Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
This commit is contained in:
parent
b974877be4
commit
f540cf36fa
19
main.c
19
main.c
@ -251,21 +251,24 @@ static void
|
|||||||
display_handle_geometry(void *data, struct wl_output *wl_output, int x, int y,
|
display_handle_geometry(void *data, struct wl_output *wl_output, int x, int y,
|
||||||
int physical_width, int physical_height, int subpixel,
|
int physical_width, int physical_height, int subpixel,
|
||||||
const char *make, const char *model, int transform) {
|
const char *make, const char *model, int transform) {
|
||||||
if (transform % 2 == 0 && keyboard.landscape) {
|
// Swap width and height on rotated displays
|
||||||
keyboard.landscape = false;
|
if (transform % 2 != 0) {
|
||||||
height = normal_height;
|
int tmp = physical_width;
|
||||||
} else if (transform % 2 != 0 && !keyboard.landscape) {
|
physical_width = physical_height;
|
||||||
keyboard.landscape = true;
|
physical_height = tmp;
|
||||||
height = landscape_height;
|
|
||||||
} else {
|
|
||||||
return; // no changes
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool landscape = physical_width > physical_height;
|
||||||
|
if (landscape == keyboard.landscape) return;
|
||||||
|
keyboard.landscape = landscape;
|
||||||
|
|
||||||
enum layout_id layer;
|
enum layout_id layer;
|
||||||
if (keyboard.landscape) {
|
if (keyboard.landscape) {
|
||||||
layer = keyboard.landscape_layers[0];
|
layer = keyboard.landscape_layers[0];
|
||||||
|
height = landscape_height;
|
||||||
} else {
|
} else {
|
||||||
layer = keyboard.layers[0];
|
layer = keyboard.layers[0];
|
||||||
|
height = normal_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
keyboard.layout = &keyboard.layouts[layer];
|
keyboard.layout = &keyboard.layouts[layer];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user