From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: James Cherti Newsgroups: gmane.emacs.devel Subject: Re: Disabling mouse input Date: Sun, 3 Nov 2024 07:34:11 -0500 Message-ID: References: <86sesaytjn.fsf@gnu.org> <4p6cs2adzzqihjdustvlklr3ykrrz7eq7rtz2ciywcyevgmoej@klyfgnsjtnti> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20842"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla Thunderbird To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Nov 03 13:35:11 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1t7Zoz-0005F0-Ux for ged-emacs-devel@m.gmane-mx.org; Sun, 03 Nov 2024 13:35:10 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t7ZoJ-00040L-5j; Sun, 03 Nov 2024 07:34:29 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t7ZoB-000407-QH for emacs-devel@gnu.org; Sun, 03 Nov 2024 07:34:20 -0500 Original-Received: from dormouse.elm.relay.mailchannels.net ([23.83.212.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t7Zo8-0000KO-NW for emacs-devel@gnu.org; Sun, 03 Nov 2024 07:34:19 -0500 X-Sender-Id: dreamhost|x-authsender|contact@jamescherti.com Original-Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id C87BA2C2E0A for ; Sun, 3 Nov 2024 12:34:14 +0000 (UTC) Original-Received: from pdx1-sub0-mail-a204.dreamhost.com (100-107-242-58.trex-nlb.outbound.svc.cluster.local [100.107.242.58]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 67A4D2C1914 for ; Sun, 3 Nov 2024 12:34:14 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1730637254; a=rsa-sha256; cv=none; b=m/u67+kD3HU9fXqhGPywM36B4oRc6MdapdVA1AzS7ZyY4jzUbpAtCjXal+wNIp7csKnicr pq4kve+AVQP+KaYfgmZun0APZJLiXslsQ5tkYnvG1H7uPmgettaSci1vwjANeE/i7W+Hqa 4ZjfeOLn3uVb+xzWjnsWuik5WKs8G6l17MuJtDgd0PBOEri0d9qEYMfgniDlF1/qxpT7sp ndbAUKp8OFoSAZxkjn6ct/gqXu+1XiCZUuyl5n/wJ9zVMHGGU9lvmupbcdSUcy1MAXcbAX nF2zYkis2n5nCDMSziutcxpbg2BOHBe/bAPq4YGJj1WjYYgFfSbkwPQ9hXN5Kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1730637254; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=zIy/9S2qQ28fyrMnXW1jE6qWWfpvnWF+LvFIPHaNZ5E=; b=Ao4gHER6Eh3mPVNbvJ+Z9zuWWv0+qz+AV5HNGEM9/ll2h4/TCkyYkQZYUBQCfSqFbH77nW iFa7KdQ3nVFvVcpW3FjdpyKY1XgHDC+Pz9YC5MIO1REYprzL//GL+k3jI6MZmH5dSg4Cf8 4saIHIi6bqEWeS5RY+bGHoSJ809uErdGUMASrwis5mZG4wQ02ng0l8vohlbk8kF2aZBJcg TiHeWf5KiH4zSMBJMdHdMarqc5yF2gOzsOpjWaWTMU2gncnxbjpSaajXMjH/VAalo9C0pq wD3um//IRFtPFnaCekX/gVaz3853Dax59gKQnNYgXPahx1HeDYiOmulBAhEW1Q== ARC-Authentication-Results: i=1; rspamd-5cc7c5c758-lrcq5; auth=pass smtp.auth=dreamhost smtp.mailfrom=contact@jamescherti.com X-Sender-Id: dreamhost|x-authsender|contact@jamescherti.com X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|contact@jamescherti.com X-MailChannels-Auth-Id: dreamhost X-Oafish-Chemical: 431d1f2d74b032a3_1730637254633_3367881234 X-MC-Loop-Signature: 1730637254633:2712981367 X-MC-Ingress-Time: 1730637254633 Original-Received: from pdx1-sub0-mail-a204.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.107.242.58 (trex/7.0.2); Sun, 03 Nov 2024 12:34:14 +0000 Original-Received: from [192.168.5.23] (bras-base-toroon0648w-grc-11-142-198-74-25.dsl.bell.ca [142.198.74.25]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: contact@jamescherti.com) by pdx1-sub0-mail-a204.dreamhost.com (Postfix) with ESMTPSA id 4XhDYf1GC9z6s for ; Sun, 3 Nov 2024 04:34:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jamescherti.com; s=dreamhost; t=1730637254; bh=zIy/9S2qQ28fyrMnXW1jE6qWWfpvnWF+LvFIPHaNZ5E=; h=Date:Subject:To:From:Content-Type:Content-Transfer-Encoding; b=CuBD8Y0hRHPn2PJJjWXlwIhU7tg1LoSgNB5vcuqfdazFj885t6Xz/D3msn0ilGTZh RaP5R7UKjoGi04kXGsAud/mmo3D7+Flqms4pC4ll3dwvR/NsXGq6G/sXTW6mhgrET5 14wVPh+0xlvnY5iBgj19dQJwMYY9yfX05u2G0fkjEmDIkBxrt1DZtfjPoMUtRCQaR9 EBeu5ffKnCQLpSXJvx6TE9IDvet2rlVhbwxhwD67QZST44gkqAJMIhT21GQ6fQPvxV QqMrN1Fl3KXRmjGYg+NCkWlcUjUuNw34YaBj5Y02/lrH3gssxttVmftyZoqCXuYxFH KAPyAYap+W7jw== Content-Language: en-US In-Reply-To: Received-SPF: pass client-ip=23.83.212.50; envelope-from=contact@jamescherti.com; helo=dormouse.elm.relay.mailchannels.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:325053 Archived-At: I prefer not to disable the touchpad at the OS level, as I still use it in other applications like the web browser. My main goal is to avoid accidental clicks or cursor movement in Emacs when I’m coding for extended periods. By disabling the mouse only within Emacs, I can prevent these distractions while reinforcing a keyboard-centric workflow, which helps me maintain my flow and avoid the slower habit of relying on the mouse to move the cursor, for example. -- James Cherti https://www.jamescherti.com/ On 2024-11-02 12:30, Dov Grobgeld wrote: > Why not disable the touchpad on the OS level? E.g. under X11 you can do it with: > > xinput set-prop 12 "Device Enabled" 0 > > where 12 is the id of the touchpad as seen by "xinput list". This also > prevents accidentally losing the focus of the emacs window. An > additional benefit is that this only turns off the touchpad, and if > you are using an external mouse, it still works. > > This is what I do when working on my laptop, and I have a keybinding > in my window manager that toggles the enabling of the touchpad. > > (Most laptops also have a low level driver option of turning off the > touchpad, but in my experience this doesn't always work under Linux.) > > Regards, > Dov > > On Sat, Nov 2, 2024 at 4:33 PM James Cherti wrote: >> Your code snippet provides an interesting solution. Thank you for >> sharing it, Stefan. >> >> -- >> James Cherti >> https://www.jamescherti.com/ >> >> On 2024-11-02 09:38, Stefan Monnier wrote: >>>>> (This should not surprise anyone, because input events are handled in >>>>> C, not in Lisp, and so disabling this in Lisp is expected to be >>>>> impossible.) >>>> Well, everyone I talked to was sure it must be possible in >>>> Lisp, so I figured somebody would ask eventually. >>> My first intuition would be to do something like: >>> >>> (define-key input-decode-map [wheel-down] (lambda (_prompt) [])) >>> (define-key input-decode-map [wheel-up] (lambda (_prompt) [])) >>> (define-key input-decode-map [mouse-1] (lambda (_prompt) [])) >>> (define-key input-decode-map [mouse-2] (lambda (_prompt) [])) >>> (define-key input-decode-map [mouse-3] (lambda (_prompt) [])) >>> >>> If that works, then you'll probably want to add more bindings for those >>> cases where you hit the "mouse" while holding a modifier, i.e. something like: >>> >>> (dolist (modifier '(control meta nil)) >>> (dolist (base '(wheel-down wheel-up mouse-1 mouse-2 mouse-3)) >>> (define-key input-decode-map >>> (vector (event-convert-list (list modifier base))) >>> (lambda (_prompt) [])))) >>> >>> >>> - Stefan >>> >>>