Improvement #41: Enable/disable redirection through D-Bus

- Add "redirected_force" to D-Bus opts_get to forcefully
  redirect/unredirect windows.

- Add D-Bus method "repaint", to, namely, repaint the screen.
This commit is contained in:
Richard Grenville 2013-07-26 12:52:16 +08:00
parent b1e0ef8ecd
commit b46deb5162
4 changed files with 39 additions and 11 deletions

View File

@ -51,3 +51,13 @@ dbus-send --print-reply --dest="$service" "$object" "${interface}.opts_get" stri
sleep 3
dbus-send --print-reply --dest="$service" "$object" "${interface}.reset"
# Undirect window
sleep 3
dbus-send --print-reply --dest="$service" "$object" "${interface}.opts_set" string:redirected_force uint16:0
# Revert back to auto
sleep 3
dbus-send --print-reply --dest="$service" "$object" "${interface}.opts_set" string:redirected_force uint16:2
# Force repaint
dbus-send --print-reply --dest="$service" "$object" "${interface}.repaint"

View File

@ -460,6 +460,8 @@ typedef struct {
/// Whether to unredirect all windows if a full-screen opaque window
/// is detected.
bool unredir_if_possible;
/// Forced redirection setting through D-Bus.
switch_t redirected_force;
/// Whether to enable D-Bus support.
bool dbus;
/// Path to log file.
@ -647,9 +649,6 @@ typedef struct {
XserverRegion all_damage_last[CGLX_MAX_BUFFER_AGE];
/// Whether all windows are currently redirected.
bool redirected;
/// Whether there's a highest full-screen window, and all windows could
/// be unredirected.
bool unredir_possible;
/// Pre-generated alpha pictures.
Picture *alpha_picts;
/// Whether all reg_ignore of windows should expire in this paint.

View File

@ -1076,7 +1076,7 @@ get_alpha_pict_o(session_t *ps, opacity_t o) {
static win *
paint_preprocess(session_t *ps, win *list) {
// Initialize unredir_possible
ps->unredir_possible = false;
bool unredir_possible = false;
win *w;
win *t = NULL, *next = NULL;
@ -1229,13 +1229,13 @@ paint_preprocess(session_t *ps, win *list) {
last_reg_ignore = w->reg_ignore;
if (is_highest && to_paint) {
if (ps->o.unredir_if_possible && is_highest && to_paint) {
is_highest = false;
// Disable unredirection for multi-screen setups
if (WMODE_SOLID == w->mode
&& (!w->frame_opacity || !win_has_frame(w))
&& win_is_fullscreen(ps, w))
ps->unredir_possible = true;
unredir_possible = true;
}
// Reset flags
@ -1259,12 +1259,13 @@ paint_preprocess(session_t *ps, win *list) {
}
// If possible, unredirect all windows and stop painting
if (ps->o.unredir_if_possible && ps->unredir_possible) {
if (UNSET != ps->o.redirected_force)
unredir_possible = !ps->o.redirected_force;
if (unredir_possible)
redir_stop(ps);
}
else {
else
redir_start(ps);
}
return t;
}
@ -6365,6 +6366,7 @@ session_init(session_t *ps_old, int argc, char **argv) {
.paint_on_overlay = false,
.resize_damage = 0,
.unredir_if_possible = false,
.redirected_force = UNSET,
.dbus = false,
.benchmark = 0,
.benchmark_wid = None,
@ -6435,7 +6437,6 @@ session_init(session_t *ps_old, int argc, char **argv) {
.all_damage_last = { None },
.time_start = { 0, 0 },
.redirected = false,
.unredir_possible = false,
.alpha_picts = NULL,
.reg_ignore_expire = false,
.idling = false,

View File

@ -582,6 +582,12 @@ cdbus_process(session_t *ps, DBusMessage *msg) {
cdbus_reply_bool(ps, msg, true);
success = true;
}
else if (cdbus_m_ismethod("repaint")) {
force_repaint(ps);
if (!dbus_message_get_no_reply(msg))
cdbus_reply_bool(ps, msg, true);
success = true;
}
else if (cdbus_m_ismethod("list_win")) {
success = cdbus_process_list_win(ps, msg);
}
@ -892,6 +898,7 @@ cdbus_process_opts_get(session_t *ps, DBusMessage *msg) {
cdbus_m_opts_get_do(detect_rounded_corners, cdbus_reply_bool);
cdbus_m_opts_get_do(paint_on_overlay, cdbus_reply_bool);
cdbus_m_opts_get_do(unredir_if_possible, cdbus_reply_bool);
cdbus_m_opts_get_do(redirected_force, cdbus_reply_enum);
cdbus_m_opts_get_do(logpath, cdbus_reply_string);
cdbus_m_opts_get_do(synchronize, cdbus_reply_bool);
@ -1064,6 +1071,16 @@ cdbus_process_opts_set(session_t *ps, DBusMessage *msg) {
return true;
}
// redirected_force
if (!strcmp("redirected_force", target)) {
cdbus_enum_t val = UNSET;
if (!cdbus_msg_get_arg(msg, 1, CDBUS_TYPE_ENUM, &val))
return false;
ps->o.redirected_force = val;
force_repaint(ps);
goto cdbus_process_opts_set_success;
}
#undef cdbus_m_opts_set_do
printf_errf("(): " CDBUS_ERROR_BADTGT_S, target);
@ -1117,6 +1134,7 @@ cdbus_process_introspect(session_t *ps, DBusMessage *msg) {
" <arg name='wid' type='" CDBUS_TYPE_WINDOW_STR "'/>\n"
" </signal>\n"
" <method name='reset' />\n"
" <method name='repaint' />\n"
" </interface>\n"
"</node>\n";