加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
cmd_get_display_geometry.c 1.41 KB
一键复制 编辑 原始数据 按行查看 历史
Jordan Sissel 提交于 2021-08-03 17:11 . Fix compiler warnings. (#344)
#include "xdo_cmd.h"
int cmd_get_display_geometry(context_t *context) {
int ret = 0;
char *cmd = context->argv[0];
int c;
int screen = DefaultScreen(context->xdo->xdpy);
int shell_output = False;
enum { opt_unused, opt_help, opt_screen, opt_shell };
static struct option longopts[] = {
{ "help", no_argument, NULL, opt_help },
{ "screen", required_argument, NULL, opt_screen },
{ "shell", no_argument, NULL, opt_shell },
{ 0, 0, 0, 0 },
};
static const char *usage = "Usage: %s\n";
int option_index;
while ((c = getopt_long_only(context->argc, context->argv, "+h",
longopts, &option_index)) != -1) {
switch (c) {
case 'h':
case opt_help:
printf(usage, cmd);
consume_args(context, context->argc);
return EXIT_SUCCESS;
break;
case opt_screen:
screen = atoi(optarg);
break;
case opt_shell:
shell_output = True;
break;
default:
fprintf(stderr, usage, cmd);
return EXIT_FAILURE;
}
}
consume_args(context, optind);
unsigned int width = 0;
unsigned int height = 0;
ret = xdo_get_viewport_dimensions(context->xdo, &width, &height, screen);
if (shell_output) {
xdotool_output(context, "WIDTH=%d", width);
xdotool_output(context, "HEIGHT=%d", height);
} else {
xdotool_output(context, "%d %d", width, height);
}
return ret;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化