parent
8cdcb77e12
commit
0cbd26f0da
|
@ -29,6 +29,9 @@ struct sway_idle_inhibitor_v1 {
|
||||||
struct wl_listener destroy;
|
struct wl_listener destroy;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool sway_idle_inhibit_v1_is_active(
|
||||||
|
struct sway_idle_inhibitor_v1 *inhibitor);
|
||||||
|
|
||||||
void sway_idle_inhibit_v1_check_active(
|
void sway_idle_inhibit_v1_check_active(
|
||||||
struct sway_idle_inhibit_manager_v1 *manager);
|
struct sway_idle_inhibit_manager_v1 *manager);
|
||||||
|
|
||||||
|
@ -38,6 +41,9 @@ void sway_idle_inhibit_v1_user_inhibitor_register(struct sway_view *view,
|
||||||
struct sway_idle_inhibitor_v1 *sway_idle_inhibit_v1_user_inhibitor_for_view(
|
struct sway_idle_inhibitor_v1 *sway_idle_inhibit_v1_user_inhibitor_for_view(
|
||||||
struct sway_view *view);
|
struct sway_view *view);
|
||||||
|
|
||||||
|
struct sway_idle_inhibitor_v1 *sway_idle_inhibit_v1_application_inhibitor_for_view(
|
||||||
|
struct sway_view *view);
|
||||||
|
|
||||||
void sway_idle_inhibit_v1_user_inhibitor_destroy(
|
void sway_idle_inhibit_v1_user_inhibitor_destroy(
|
||||||
struct sway_idle_inhibitor_v1 *inhibitor);
|
struct sway_idle_inhibitor_v1 *inhibitor);
|
||||||
|
|
||||||
|
|
|
@ -232,6 +232,8 @@ void view_get_constraints(struct sway_view *view, double *min_width,
|
||||||
uint32_t view_configure(struct sway_view *view, double lx, double ly, int width,
|
uint32_t view_configure(struct sway_view *view, double lx, double ly, int width,
|
||||||
int height);
|
int height);
|
||||||
|
|
||||||
|
bool view_inhibit_idle(struct sway_view *view);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not the view is the only visible view in its tree. If the view
|
* Whether or not the view is the only visible view in its tree. If the view
|
||||||
* is tiling, there may be floating views. If the view is floating, there may
|
* is tiling, there may be floating views. If the view is floating, there may
|
||||||
|
|
|
@ -77,6 +77,19 @@ struct sway_idle_inhibitor_v1 *sway_idle_inhibit_v1_user_inhibitor_for_view(
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct sway_idle_inhibitor_v1 *sway_idle_inhibit_v1_application_inhibitor_for_view(
|
||||||
|
struct sway_view *view) {
|
||||||
|
struct sway_idle_inhibitor_v1 *inhibitor;
|
||||||
|
wl_list_for_each(inhibitor, &server.idle_inhibit_manager_v1->inhibitors,
|
||||||
|
link) {
|
||||||
|
if (inhibitor->view == view &&
|
||||||
|
inhibitor->mode == INHIBIT_IDLE_APPLICATION) {
|
||||||
|
return inhibitor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void sway_idle_inhibit_v1_user_inhibitor_destroy(
|
void sway_idle_inhibit_v1_user_inhibitor_destroy(
|
||||||
struct sway_idle_inhibitor_v1 *inhibitor) {
|
struct sway_idle_inhibitor_v1 *inhibitor) {
|
||||||
if (!inhibitor) {
|
if (!inhibitor) {
|
||||||
|
@ -89,7 +102,7 @@ void sway_idle_inhibit_v1_user_inhibitor_destroy(
|
||||||
destroy_inhibitor(inhibitor);
|
destroy_inhibitor(inhibitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool check_active(struct sway_idle_inhibitor_v1 *inhibitor) {
|
bool sway_idle_inhibit_v1_is_active(struct sway_idle_inhibitor_v1 *inhibitor) {
|
||||||
switch (inhibitor->mode) {
|
switch (inhibitor->mode) {
|
||||||
case INHIBIT_IDLE_APPLICATION:
|
case INHIBIT_IDLE_APPLICATION:
|
||||||
// If there is no view associated with the inhibitor, assume visible
|
// If there is no view associated with the inhibitor, assume visible
|
||||||
|
@ -122,7 +135,7 @@ void sway_idle_inhibit_v1_check_active(
|
||||||
struct sway_idle_inhibitor_v1 *inhibitor;
|
struct sway_idle_inhibitor_v1 *inhibitor;
|
||||||
bool inhibited = false;
|
bool inhibited = false;
|
||||||
wl_list_for_each(inhibitor, &manager->inhibitors, link) {
|
wl_list_for_each(inhibitor, &manager->inhibitors, link) {
|
||||||
if ((inhibited = check_active(inhibitor))) {
|
if ((inhibited = sway_idle_inhibit_v1_is_active(inhibitor))) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <wlr/types/wlr_output.h>
|
#include <wlr/types/wlr_output.h>
|
||||||
#include <xkbcommon/xkbcommon.h>
|
#include <xkbcommon/xkbcommon.h>
|
||||||
#include "wlr-layer-shell-unstable-v1-protocol.h"
|
#include "wlr-layer-shell-unstable-v1-protocol.h"
|
||||||
|
#include "sway/desktop/idle_inhibit_v1.h"
|
||||||
|
|
||||||
static const int i3_output_id = INT32_MAX;
|
static const int i3_output_id = INT32_MAX;
|
||||||
static const int i3_scratch_id = INT32_MAX - 1;
|
static const int i3_scratch_id = INT32_MAX - 1;
|
||||||
|
@ -139,6 +140,22 @@ static const char *ipc_json_xwindow_type_description(struct sway_view *view) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static const char *ipc_json_user_idle_inhibitor_description(enum sway_idle_inhibit_mode mode) {
|
||||||
|
switch (mode) {
|
||||||
|
case INHIBIT_IDLE_FOCUS:
|
||||||
|
return "focus";
|
||||||
|
case INHIBIT_IDLE_FULLSCREEN:
|
||||||
|
return "fullscreen";
|
||||||
|
case INHIBIT_IDLE_OPEN:
|
||||||
|
return "open";
|
||||||
|
case INHIBIT_IDLE_VISIBLE:
|
||||||
|
return "visible";
|
||||||
|
case INHIBIT_IDLE_APPLICATION:
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
json_object *ipc_json_get_version(void) {
|
json_object *ipc_json_get_version(void) {
|
||||||
int major = 0, minor = 0, patch = 0;
|
int major = 0, minor = 0, patch = 0;
|
||||||
json_object *version = json_object_new_object();
|
json_object *version = json_object_new_object();
|
||||||
|
@ -492,6 +509,36 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object
|
||||||
|
|
||||||
json_object_object_add(object, "shell", json_object_new_string(view_get_shell(c->view)));
|
json_object_object_add(object, "shell", json_object_new_string(view_get_shell(c->view)));
|
||||||
|
|
||||||
|
json_object_object_add(object, "inhibit_idle",
|
||||||
|
json_object_new_boolean(view_inhibit_idle(c->view)));
|
||||||
|
|
||||||
|
json_object *idle_inhibitors = json_object_new_object();
|
||||||
|
|
||||||
|
struct sway_idle_inhibitor_v1 *user_inhibitor =
|
||||||
|
sway_idle_inhibit_v1_user_inhibitor_for_view(c->view);
|
||||||
|
|
||||||
|
if (user_inhibitor) {
|
||||||
|
json_object_object_add(idle_inhibitors, "user",
|
||||||
|
json_object_new_string(
|
||||||
|
ipc_json_user_idle_inhibitor_description(user_inhibitor->mode)));
|
||||||
|
} else {
|
||||||
|
json_object_object_add(idle_inhibitors, "user",
|
||||||
|
json_object_new_string("none"));
|
||||||
|
}
|
||||||
|
|
||||||
|
struct sway_idle_inhibitor_v1 *application_inhibitor =
|
||||||
|
sway_idle_inhibit_v1_application_inhibitor_for_view(c->view);
|
||||||
|
|
||||||
|
if (application_inhibitor) {
|
||||||
|
json_object_object_add(idle_inhibitors, "application",
|
||||||
|
json_object_new_string("enabled"));
|
||||||
|
} else {
|
||||||
|
json_object_object_add(idle_inhibitors, "application",
|
||||||
|
json_object_new_string("none"));
|
||||||
|
}
|
||||||
|
|
||||||
|
json_object_object_add(object, "idle_inhibitors", idle_inhibitors);
|
||||||
|
|
||||||
#if HAVE_XWAYLAND
|
#if HAVE_XWAYLAND
|
||||||
if (c->view->type == SWAY_VIEW_XWAYLAND) {
|
if (c->view->type == SWAY_VIEW_XWAYLAND) {
|
||||||
json_object_object_add(object, "window",
|
json_object_object_add(object, "window",
|
||||||
|
|
|
@ -379,6 +379,14 @@ node and will have the following properties:
|
||||||
|- shell
|
|- shell
|
||||||
: string
|
: string
|
||||||
: (Only views) The shell of the view, such as _xdg\_shell_ or _xwayland_
|
: (Only views) The shell of the view, such as _xdg\_shell_ or _xwayland_
|
||||||
|
|- inhibit_idle
|
||||||
|
: boolean
|
||||||
|
: (Only views) Whether the view is inhibiting the idle state
|
||||||
|
|- idle_inhibitors
|
||||||
|
: object
|
||||||
|
: (Only views) An object containing the state of the _application_ and _user_ idle inhibitors.
|
||||||
|
_application_ can be _enabled_ or _none_.
|
||||||
|
_user_ can be _focus_, _fullscreen_, _open_, _visible_ or _none_.
|
||||||
|- window
|
|- window
|
||||||
: integer
|
: integer
|
||||||
: (Only xwayland views) The X11 window ID for the xwayland view
|
: (Only xwayland views) The X11 window ID for the xwayland view
|
||||||
|
@ -676,6 +684,11 @@ node and will have the following properties:
|
||||||
"app_id": null,
|
"app_id": null,
|
||||||
"visible": true,
|
"visible": true,
|
||||||
"shell": "xwayland",
|
"shell": "xwayland",
|
||||||
|
"inhibit_idle": true,
|
||||||
|
"idle_inhibitors": {
|
||||||
|
"application": "none",
|
||||||
|
"user": "visible",
|
||||||
|
},
|
||||||
"window_properties": {
|
"window_properties": {
|
||||||
"class": "URxvt",
|
"class": "URxvt",
|
||||||
"instance": "urxvt",
|
"instance": "urxvt",
|
||||||
|
@ -731,6 +744,11 @@ node and will have the following properties:
|
||||||
"app_id": "termite",
|
"app_id": "termite",
|
||||||
"visible": true,
|
"visible": true,
|
||||||
"shell": "xdg_shell",
|
"shell": "xdg_shell",
|
||||||
|
"inhibit_idle": false,
|
||||||
|
"idle_inhibitors": {
|
||||||
|
"application": "none",
|
||||||
|
"user": "fullscreen",
|
||||||
|
},
|
||||||
"nodes": [
|
"nodes": [
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
#include "sway/desktop.h"
|
#include "sway/desktop.h"
|
||||||
#include "sway/desktop/transaction.h"
|
#include "sway/desktop/transaction.h"
|
||||||
|
#include "sway/desktop/idle_inhibit_v1.h"
|
||||||
#include "sway/input/cursor.h"
|
#include "sway/input/cursor.h"
|
||||||
#include "sway/ipc-server.h"
|
#include "sway/ipc-server.h"
|
||||||
#include "sway/output.h"
|
#include "sway/output.h"
|
||||||
|
@ -164,6 +165,29 @@ uint32_t view_configure(struct sway_view *view, double lx, double ly, int width,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool view_inhibit_idle(struct sway_view *view) {
|
||||||
|
struct sway_idle_inhibitor_v1 *user_inhibitor =
|
||||||
|
sway_idle_inhibit_v1_user_inhibitor_for_view(view);
|
||||||
|
|
||||||
|
struct sway_idle_inhibitor_v1 *application_inhibitor =
|
||||||
|
sway_idle_inhibit_v1_application_inhibitor_for_view(view);
|
||||||
|
|
||||||
|
if (!user_inhibitor && !application_inhibitor) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!user_inhibitor) {
|
||||||
|
return sway_idle_inhibit_v1_is_active(application_inhibitor);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!application_inhibitor) {
|
||||||
|
return sway_idle_inhibit_v1_is_active(user_inhibitor);
|
||||||
|
}
|
||||||
|
|
||||||
|
return sway_idle_inhibit_v1_is_active(user_inhibitor)
|
||||||
|
|| sway_idle_inhibit_v1_is_active(application_inhibitor);
|
||||||
|
}
|
||||||
|
|
||||||
bool view_is_only_visible(struct sway_view *view) {
|
bool view_is_only_visible(struct sway_view *view) {
|
||||||
bool only_view = true;
|
bool only_view = true;
|
||||||
struct sway_container *con = view->container;
|
struct sway_container *con = view->container;
|
||||||
|
|
Loading…
Reference in a new issue