mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-10 09:26:10 +00:00
overlay: Allow simple positioning and resizing
Using window.size=<width>x<height> or window.size=<scale>% in the config file, or --size=<scale>% or --size=<width>x<height> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
parent
c9f0173764
commit
1e65d5ac2f
@ -740,6 +740,7 @@ int main(int argc, char **argv)
|
||||
{"config", 1, 0, 'c'},
|
||||
{"geometry", 1, 0, 'G'},
|
||||
{"position", 1, 0, 'P'},
|
||||
{"size", 1, 0, 'S'},
|
||||
{NULL, 0, 0, 0,}
|
||||
};
|
||||
struct overlay_context ctx;
|
||||
@ -751,7 +752,7 @@ int main(int argc, char **argv)
|
||||
config_init(&config);
|
||||
|
||||
opterr = 0;
|
||||
while ((i = getopt_long(argc, argv, "c:f", long_options, &index)) != -1) {
|
||||
while ((i = getopt_long(argc, argv, "c:f:", long_options, &index)) != -1) {
|
||||
switch (i) {
|
||||
case 'c':
|
||||
config_parse_string(&config, optarg);
|
||||
@ -762,6 +763,9 @@ int main(int argc, char **argv)
|
||||
case 'P':
|
||||
config_set_value(&config, "window", "position", optarg);
|
||||
break;
|
||||
case 'S':
|
||||
config_set_value(&config, "window", "size", optarg);
|
||||
break;
|
||||
case 'f':
|
||||
daemonize = 0;
|
||||
break;
|
||||
|
@ -80,12 +80,13 @@ x11_position(Screen *scr, int width, int height,
|
||||
geometry = config_get_value(config, "window", "geometry");
|
||||
if (geometry) {
|
||||
sscanf(geometry, "%dx%d+%d+%d", w, h, x, y);
|
||||
if (*w < width)
|
||||
*w = width;
|
||||
if (*h < height)
|
||||
*h = height;
|
||||
if (*w < width/2)
|
||||
*w = width/2;
|
||||
if (*h < height/2)
|
||||
*h = height/2;
|
||||
} else {
|
||||
position = get_position(config);
|
||||
|
||||
if (position != POS_UNSET) {
|
||||
if (width == -1) {
|
||||
*w = scr->width;
|
||||
@ -94,10 +95,7 @@ x11_position(Screen *scr, int width, int height,
|
||||
case 0:
|
||||
case 2: *w >>= 1; break;
|
||||
}
|
||||
} else if (width > scr->width) {
|
||||
*w = scr->width;
|
||||
} else
|
||||
*w = width;
|
||||
}
|
||||
|
||||
if (height == -1) {
|
||||
*h = scr->height;
|
||||
@ -106,11 +104,41 @@ x11_position(Screen *scr, int width, int height,
|
||||
case 0:
|
||||
case 2: *h >>= 1; break;
|
||||
}
|
||||
} else if (height > scr->height)
|
||||
*h = scr->height;
|
||||
else
|
||||
*h = height;
|
||||
}
|
||||
}
|
||||
|
||||
geometry = config_get_value(config, "window", "size");
|
||||
if (geometry) {
|
||||
int size_w, size_h;
|
||||
float scale_x, scale_y;
|
||||
|
||||
if (sscanf(geometry, "%dx%d", &size_w, &size_h) == 2) {
|
||||
*w = size_w;
|
||||
*h = size_h;
|
||||
} else if (sscanf(geometry, "%f%%x%f%%", &scale_x, &scale_y) == 2) {
|
||||
if (*w != -1)
|
||||
*w = (*w * scale_x) / 100.;
|
||||
if (*h != -1)
|
||||
*h = (*h * scale_y) / 100.;
|
||||
} else if (sscanf(geometry, "%f%%", &scale_x) == 1) {
|
||||
if (*w != -1)
|
||||
*w = (*w * scale_x) / 100.;
|
||||
if (*h != -1)
|
||||
*h = (*h * scale_x) / 100.;
|
||||
}
|
||||
if ((unsigned)*w < width/2)
|
||||
*w = width/2;
|
||||
if ((unsigned)*h < height/2)
|
||||
*h = height/2;
|
||||
}
|
||||
|
||||
if ((unsigned)*w > scr->width)
|
||||
*w = scr->width;
|
||||
|
||||
if ((unsigned)*h > scr->height)
|
||||
*h = scr->height;
|
||||
|
||||
if (position != POS_UNSET) {
|
||||
switch (position & 7) {
|
||||
default:
|
||||
case 0: *x = 0; break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user