aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2019-03-27 15:40:54 +0100
committerGerd Hoffmann <kraxel@redhat.com>2019-03-27 15:40:54 +0100
commit89dae63a0d2a084ff3f3efc933b79fb8dd715b75 (patch)
treec4f1e4ee68cb7f3dabd171b10b0929e16fc527ed
parentcf6e8218bab44447c6916dfd924e41de30beb8cb (diff)
downloadfbida-89dae63a0d2a084ff3f3efc933b79fb8dd715b75.tar.gz
even more logind console switching
-rw-r--r--drmtools.c2
-rw-r--r--fbcon.c8
-rw-r--r--logind.c47
3 files changed, 46 insertions, 11 deletions
diff --git a/drmtools.c b/drmtools.c
index 1d2656a..4f9295c 100644
--- a/drmtools.c
+++ b/drmtools.c
@@ -224,6 +224,7 @@ static int drm_show_fb(struct drmfb *fb)
{
int rc;
+ fprintf(stderr, "%s: fb %d\n", __func__, fb->id);
rc = drmModeSetCrtc(drm_fd, drm_enc->crtc_id, fb->id, 0, 0,
&drm_conn->connector_id, 1,
drm_mode);
@@ -251,7 +252,6 @@ static void drm_resume_display(void)
drm_init_fb(&fb1, drm_fmt, false);
if (fb2.mem)
drm_init_fb(&fb2, drm_fmt, false);
- drm_show_fb(fbc);
}
static void drm_flush_display(bool second)
diff --git a/fbcon.c b/fbcon.c
index 2f0f2bc..e9f66bd 100644
--- a/fbcon.c
+++ b/fbcon.c
@@ -179,21 +179,25 @@ static void cleanup_and_exit(int code)
static void console_switch_suspend(void)
{
+ fprintf(stderr, "%s: start ...\n", __func__);
+ active = false;
gfx->suspend_display();
libinput_suspend(kbd);
logind_release_control();
- active = false;
+ fprintf(stderr, "%s: ... done\n", __func__);
}
static void console_switch_resume(void)
{
- active = true;
+ fprintf(stderr, "%s: start ...\n", __func__);
logind_take_control();
libinput_resume(kbd);
gfx->resume_display();
state1.clear++;
state2.clear++;
dirty++;
+ active = true;
+ fprintf(stderr, "%s: ... done\n", __func__);
}
/* ---------------------------------------------------------------------- */
diff --git a/logind.c b/logind.c
index 6b1b77c..dec5670 100644
--- a/logind.c
+++ b/logind.c
@@ -25,6 +25,7 @@
static sd_bus *logind_dbus = NULL;
static sd_bus_slot *logind_signals;
+static const char *logind_session_path;
static void (*session_suspend)(void);
static void (*session_resume)(void);
@@ -129,7 +130,6 @@ static int logind_session_cb(sd_bus_message *m, void *data, sd_bus_error *ret_er
unsigned int maj, min;
int r;
-
if (strcmp(member, "PauseDevice") == 0) {
r = sd_bus_message_read(m, "uus", &maj, &min, &type);
if (r < 0) {
@@ -137,7 +137,8 @@ static int logind_session_cb(sd_bus_message *m, void *data, sd_bus_error *ret_er
return r;
}
fprintf(stderr, "signal : %s(%d,%d,%s)\n", member, maj, min, type);
- logind_pause_device_complete(maj, min);
+ if (strcmp(type, "pause") == 0)
+ logind_pause_device_complete(maj, min);
} else {
fprintf(stderr, "signal : %s(...)\n", member);
}
@@ -149,6 +150,9 @@ int logind_init(bool take_control,
void (*suspend)(void),
void (*resume)(void))
{
+ sd_bus_error error = SD_BUS_ERROR_NULL;
+ sd_bus_message *m = NULL;
+ const char *session_id;
int r;
r = sd_bus_open_system(&logind_dbus);
@@ -159,16 +163,38 @@ int logind_init(bool take_control,
if (take_control) {
r = logind_take_control();
- if (r < 0) {
- sd_bus_unref(logind_dbus);
- logind_dbus = NULL;
- return -1;
- }
+ if (r < 0)
+ goto err;
}
+ session_id = getenv("XDG_SESSION_ID");
+ fprintf(stderr, "call : GetSession(%s)\n", session_id);
+ r = sd_bus_call_method(logind_dbus,
+ "org.freedesktop.login1",
+ "/org/freedesktop/login1",
+ "org.freedesktop.login1.Manager",
+ "GetSession",
+ &error,
+ &m,
+ "s",
+ session_id);
+ if (r < 0) {
+ fprintf(stderr, "error : GetSession failed: %s\n",
+ error.message);
+ sd_bus_error_free(&error);
+ goto err;
+ }
+ r = sd_bus_message_read(m, "o", &logind_session_path);
+ if (r < 0) {
+ fprintf(stderr, "error : Parsing GetSession reply failed: %s\n",
+ strerror(-r));
+ goto err;
+ }
+ sd_bus_message_unref(m);
+
sd_bus_match_signal(logind_dbus, &logind_signals,
"org.freedesktop.login1",
- NULL,
+ logind_session_path,
NULL,
"PropertiesChanged",
logind_prop_cb,
@@ -187,6 +213,11 @@ int logind_init(bool take_control,
fprintf(stderr, "Opening input devices via logind.\n");
return 0;
+
+err:
+ sd_bus_unref(logind_dbus);
+ logind_dbus = NULL;
+ return -1;
}
int logind_dbus_fd(void)