From patchwork Fri Jan 27 17:13:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Tissoires X-Patchwork-Id: 9542393 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C52FF604A0 for ; Fri, 27 Jan 2017 17:41:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B7147276D6 for ; Fri, 27 Jan 2017 17:41:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ABE6927F85; Fri, 27 Jan 2017 17:41:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 65710276D6 for ; Fri, 27 Jan 2017 17:41:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933929AbdA0Ris (ORCPT ); Fri, 27 Jan 2017 12:38:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39414 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933803AbdA0Rhy (ORCPT ); Fri, 27 Jan 2017 12:37:54 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4593B80491; Fri, 27 Jan 2017 17:13:30 +0000 (UTC) Received: from plouf.banquise.eu.com (ovpn-117-6.ams2.redhat.com [10.36.117.6]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v0RHDMtZ021227; Fri, 27 Jan 2017 12:13:28 -0500 From: Benjamin Tissoires To: Dmitry Torokhov , Greg Kroah-Hartman , Jiri Slaby , Samuel Thibault Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] tty/vt/keyboard: reset the LEDs state at each console change Date: Fri, 27 Jan 2017 18:13:17 +0100 Message-Id: <20170127171318.2596-4-benjamin.tissoires@redhat.com> In-Reply-To: <20170127171318.2596-1-benjamin.tissoires@redhat.com> References: <20170127171318.2596-1-benjamin.tissoires@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 27 Jan 2017 17:13:30 +0000 (UTC) Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When switching between consoles, the LEDs state is correctly assigned, as long as the kernel manages the console. When switching back from Gnome, the VT is not aware of the current state of the LEDs. So if Gnome changes them, the kernel still bellieves they are off, and it won't turn them off when switching to a new TTY. To keep the LEDs status in sync with the actual modifiers, simply force a reset of the LEDs when we detect a vt change. Signed-off-by: Benjamin Tissoires --- drivers/tty/vt/keyboard.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c index ca1d614..410b21e 100644 --- a/drivers/tty/vt/keyboard.c +++ b/drivers/tty/vt/keyboard.c @@ -137,6 +137,8 @@ static unsigned char ledioctl; static bool caps_as_controlllock; static bool task_caps_as_controlllock; +static int saved_cur_kbd_console = -1; + /* * Notifier list for console keyboard events */ @@ -1482,6 +1484,12 @@ static void kbd_event(struct input_handle *handle, unsigned int event_type, /* We are called with interrupts disabled, just take the lock */ spin_lock(&kbd_event_lock); + /* reset the led state on console switch */ + if (saved_cur_kbd_console != fg_console) { + ledstate = -1U; + saved_cur_kbd_console = fg_console; + } + if (event_type == EV_MSC && event_code == MSC_RAW && HW_RAW(handle->dev)) kbd_rawcode(value); if (event_type == EV_KEY)