[PATCH weston v2 1/2] launcher: don't try to switch to the current vt

Giulio Camuffo giuliocamuffo at gmail.com
Wed Jun 29 09:57:11 UTC 2016


Signed-off-by: Giulio Camuffo <giuliocamuffo at gmail.com>
---

v2: this was split from the following commit

 libweston/launcher-direct.c        | 12 ++++++++++++
 libweston/launcher-impl.h          |  1 +
 libweston/launcher-logind.c        |  8 ++++++++
 libweston/launcher-util.c          |  7 ++++++-
 libweston/launcher-weston-launch.c | 12 ++++++++++++
 5 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/libweston/launcher-direct.c b/libweston/launcher-direct.c
index 29d9c28..0ff99a4 100644
--- a/libweston/launcher-direct.c
+++ b/libweston/launcher-direct.c
@@ -305,6 +305,17 @@ launcher_direct_destroy(struct weston_launcher *launcher_base)
 	free(launcher);
 }
 
+static int
+launcher_direct_get_vt(struct weston_launcher *base)
+{
+	struct launcher_direct *launcher = wl_container_of(base, launcher, base);
+	struct stat s;
+	if (fstat(launcher->tty, &s) < 0)
+		return -1;
+
+	return minor(s.st_rdev);
+}
+
 struct launcher_interface launcher_direct_iface = {
 	launcher_direct_connect,
 	launcher_direct_destroy,
@@ -312,4 +323,5 @@ struct launcher_interface launcher_direct_iface = {
 	launcher_direct_close,
 	launcher_direct_activate_vt,
 	launcher_direct_restore,
+	launcher_direct_get_vt,
 };
diff --git a/libweston/launcher-impl.h b/libweston/launcher-impl.h
index 742721b..0bc3245 100644
--- a/libweston/launcher-impl.h
+++ b/libweston/launcher-impl.h
@@ -34,6 +34,7 @@ struct launcher_interface {
 	void (* close) (struct weston_launcher *launcher, int fd);
 	int (* activate_vt) (struct weston_launcher *launcher, int vt);
 	void (* restore) (struct weston_launcher *launcher);
+	int (* get_vt) (struct weston_launcher *launcher);
 };
 
 struct weston_launcher {
diff --git a/libweston/launcher-logind.c b/libweston/launcher-logind.c
index f755ec3..4680402 100644
--- a/libweston/launcher-logind.c
+++ b/libweston/launcher-logind.c
@@ -829,6 +829,13 @@ launcher_logind_destroy(struct weston_launcher *launcher)
 	free(wl);
 }
 
+static int
+launcher_logind_get_vt(struct weston_launcher *launcher)
+{
+	struct launcher_logind *wl = wl_container_of(launcher, wl, base);
+	return wl->vtnr;
+}
+
 struct launcher_interface launcher_logind_iface = {
 	launcher_logind_connect,
 	launcher_logind_destroy,
@@ -836,4 +843,5 @@ struct launcher_interface launcher_logind_iface = {
 	launcher_logind_close,
 	launcher_logind_activate_vt,
 	launcher_logind_restore,
+	launcher_logind_get_vt,
 };
diff --git a/libweston/launcher-util.c b/libweston/launcher-util.c
index 03b9d63..5fbfdcf 100644
--- a/libweston/launcher-util.c
+++ b/libweston/launcher-util.c
@@ -97,8 +97,13 @@ switch_vt_binding(struct weston_keyboard *keyboard,
 		  uint32_t time, uint32_t key, void *data)
 {
 	struct weston_compositor *compositor = data;
+	struct weston_launcher *launcher = compositor->launcher;
+	int vt = key - KEY_F1 + 1;
 
-	weston_launcher_activate_vt(compositor->launcher, key - KEY_F1 + 1);
+	if (vt == launcher->iface->get_vt(launcher))
+		return;
+
+	weston_launcher_activate_vt(launcher, vt);
 }
 
 WL_EXPORT void
diff --git a/libweston/launcher-weston-launch.c b/libweston/launcher-weston-launch.c
index ad919f1..b74975a 100644
--- a/libweston/launcher-weston-launch.c
+++ b/libweston/launcher-weston-launch.c
@@ -290,6 +290,17 @@ launcher_weston_launch_destroy(struct weston_launcher *launcher_base)
 	free(launcher);
 }
 
+static int
+launcher_weston_launch_get_vt(struct weston_launcher *base)
+{
+	struct launcher_weston_launch *launcher = wl_container_of(base, launcher, base);
+	struct stat s;
+	if (fstat(launcher->tty, &s) < 0)
+		return -1;
+
+	return minor(s.st_rdev);
+}
+
 struct launcher_interface launcher_weston_launch_iface = {
 	launcher_weston_launch_connect,
 	launcher_weston_launch_destroy,
@@ -297,4 +308,5 @@ struct launcher_interface launcher_weston_launch_iface = {
 	launcher_weston_launch_close,
 	launcher_weston_launch_activate_vt,
 	launcher_weston_launch_restore,
+	launcher_weston_launch_get_vt,
 };
-- 
2.9.0



More information about the wayland-devel mailing list