mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-04-25 06:46:30 -04:00
feat: ipc to get cursor position
This commit is contained in:
parent
fc13b0ff15
commit
83056027f2
3 changed files with 60 additions and 3 deletions
37
mmsg/mmsg.c
37
mmsg/mmsg.c
|
|
@ -42,6 +42,7 @@ static int32_t eflag;
|
||||||
static int32_t kflag;
|
static int32_t kflag;
|
||||||
static int32_t bflag;
|
static int32_t bflag;
|
||||||
static int32_t Aflag;
|
static int32_t Aflag;
|
||||||
|
static int32_t pflag;
|
||||||
|
|
||||||
static uint32_t occ, seltags, total_clients, urg;
|
static uint32_t occ, seltags, total_clients, urg;
|
||||||
|
|
||||||
|
|
@ -288,6 +289,28 @@ static void dwl_ipc_output_keymode(void *data,
|
||||||
printf("keymode %s\n", keymode);
|
printf("keymode %s\n", keymode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void dwl_ipc_output_cursor_x(void *data,
|
||||||
|
struct zdwl_ipc_output_v2 *dwl_ipc_output,
|
||||||
|
int32_t x) {
|
||||||
|
if (!pflag)
|
||||||
|
return;
|
||||||
|
char *output_name = data;
|
||||||
|
if (output_name)
|
||||||
|
printf("%s ", output_name);
|
||||||
|
printf("cursor_x %d\n", x);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dwl_ipc_output_cursor_y(void *data,
|
||||||
|
struct zdwl_ipc_output_v2 *dwl_ipc_output,
|
||||||
|
int32_t y) {
|
||||||
|
if (!pflag)
|
||||||
|
return;
|
||||||
|
char *output_name = data;
|
||||||
|
if (output_name)
|
||||||
|
printf("%s ", output_name);
|
||||||
|
printf("cursor_y %d\n", y);
|
||||||
|
}
|
||||||
|
|
||||||
static void dwl_ipc_output_fullscreen(void *data,
|
static void dwl_ipc_output_fullscreen(void *data,
|
||||||
struct zdwl_ipc_output_v2 *dwl_ipc_output,
|
struct zdwl_ipc_output_v2 *dwl_ipc_output,
|
||||||
uint32_t is_fullscreen) {
|
uint32_t is_fullscreen) {
|
||||||
|
|
@ -427,6 +450,8 @@ static const struct zdwl_ipc_output_v2_listener dwl_ipc_output_listener = {
|
||||||
.kb_layout = dwl_ipc_output_kb_layout,
|
.kb_layout = dwl_ipc_output_kb_layout,
|
||||||
.keymode = dwl_ipc_output_keymode,
|
.keymode = dwl_ipc_output_keymode,
|
||||||
.scalefactor = dwl_ipc_output_scalefactor,
|
.scalefactor = dwl_ipc_output_scalefactor,
|
||||||
|
.cursor_x = dwl_ipc_output_cursor_x,
|
||||||
|
.cursor_y = dwl_ipc_output_cursor_y,
|
||||||
.frame = dwl_ipc_output_frame,
|
.frame = dwl_ipc_output_frame,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -504,7 +529,7 @@ static void usage(void) {
|
||||||
"\t%s [-OTLq]\n"
|
"\t%s [-OTLq]\n"
|
||||||
"\t%s [-o <output>] -s [-t <tags>] [-l <layout>] [-c <tags>] [-d "
|
"\t%s [-o <output>] -s [-t <tags>] [-l <layout>] [-c <tags>] [-d "
|
||||||
"<cmd>,<arg1>,<arg2>,<arg3>,<arg4>,<arg5>]\n"
|
"<cmd>,<arg1>,<arg2>,<arg3>,<arg4>,<arg5>]\n"
|
||||||
"\t%s [-o <output>] (-g | -w) [-OotlcvmfxekbA]\n",
|
"\t%s [-o <output>] (-g | -w) [-OotlcvmfxekbAp]\n",
|
||||||
argv0, argv0, argv0);
|
argv0, argv0, argv0);
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
@ -752,6 +777,12 @@ int32_t main(int32_t argc, char *argv[]) {
|
||||||
usage();
|
usage();
|
||||||
mode |= GET;
|
mode |= GET;
|
||||||
break;
|
break;
|
||||||
|
case 'p':
|
||||||
|
pflag = 1;
|
||||||
|
if (mode == SET)
|
||||||
|
usage();
|
||||||
|
mode |= GET;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "bad option %c\n", ARGC());
|
fprintf(stderr, "bad option %c\n", ARGC());
|
||||||
usage();
|
usage();
|
||||||
|
|
@ -762,9 +793,9 @@ int32_t main(int32_t argc, char *argv[]) {
|
||||||
if (mode & GET && !output_name &&
|
if (mode & GET && !output_name &&
|
||||||
!(oflag || tflag || lflag || Oflag || Tflag || Lflag || cflag ||
|
!(oflag || tflag || lflag || Oflag || Tflag || Lflag || cflag ||
|
||||||
vflag || mflag || fflag || xflag || eflag || kflag || bflag ||
|
vflag || mflag || fflag || xflag || eflag || kflag || bflag ||
|
||||||
Aflag || dflag))
|
Aflag || pflag || dflag))
|
||||||
oflag = tflag = lflag = cflag = vflag = mflag = fflag = xflag = eflag =
|
oflag = tflag = lflag = cflag = vflag = mflag = fflag = xflag = eflag =
|
||||||
kflag = bflag = Aflag = 1;
|
kflag = bflag = Aflag = pflag = 1;
|
||||||
|
|
||||||
display = wl_display_connect(NULL);
|
display = wl_display_connect(NULL);
|
||||||
if (!display)
|
if (!display)
|
||||||
|
|
|
||||||
|
|
@ -248,6 +248,20 @@ I would probably just submit raphi's patchset but I don't think that would be po
|
||||||
<arg name="scalefactor" type="uint" summary="scale factor of monitor."/>
|
<arg name="scalefactor" type="uint" summary="scale factor of monitor."/>
|
||||||
</event>
|
</event>
|
||||||
|
|
||||||
|
<event name="cursor_x" since="2">
|
||||||
|
<description summary="cursor x position">
|
||||||
|
Indicates the x coordinate of the cursor.
|
||||||
|
</description>
|
||||||
|
<arg name="x" type="int" summary="x coordinate of the cursor"/>
|
||||||
|
</event>
|
||||||
|
|
||||||
|
<event name="cursor_y" since="2">
|
||||||
|
<description summary="cursor y position">
|
||||||
|
Indicates the y coordinate of the cursor.
|
||||||
|
</description>
|
||||||
|
<arg name="y" type="int" summary="y coordinate of the cursor"/>
|
||||||
|
</event>
|
||||||
|
|
||||||
</interface>
|
</interface>
|
||||||
|
|
||||||
</protocol>
|
</protocol>
|
||||||
|
|
|
||||||
|
|
@ -211,6 +211,18 @@ void dwl_ipc_output_printstatus_to(DwlIpcOutput *ipc_output) {
|
||||||
monitor->wlr_output->scale * 100);
|
monitor->wlr_output->scale * 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (wl_resource_get_version(ipc_output->resource) >=
|
||||||
|
ZDWL_IPC_OUTPUT_V2_CURSOR_X_SINCE_VERSION) {
|
||||||
|
zdwl_ipc_output_v2_send_cursor_x(ipc_output->resource,
|
||||||
|
(int32_t)cursor->x);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wl_resource_get_version(ipc_output->resource) >=
|
||||||
|
ZDWL_IPC_OUTPUT_V2_CURSOR_Y_SINCE_VERSION) {
|
||||||
|
zdwl_ipc_output_v2_send_cursor_y(ipc_output->resource,
|
||||||
|
(int32_t)cursor->y);
|
||||||
|
}
|
||||||
|
|
||||||
zdwl_ipc_output_v2_send_frame(ipc_output->resource);
|
zdwl_ipc_output_v2_send_frame(ipc_output->resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue