From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Third Newsgroups: gmane.emacs.bugs Subject: bug#28620: Interact directly on Emacs bug#28620: mouse drag event records wrong release window Date: Wed, 4 Oct 2017 19:59:00 +0100 Message-ID: <20171004185900.GA52514@breton.holly.idiocy.org> References: <8360bx340d.fsf@gnu.org> <8360bw19es.fsf@gnu.org> <20171003224017.GA51637@breton.holly.idiocy.org> <20171004163048.GA52414@breton.holly.idiocy.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1507143741 23821 195.159.176.226 (4 Oct 2017 19:02:21 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 4 Oct 2017 19:02:21 +0000 (UTC) User-Agent: Mutt/1.9.0 (2017-09-02) Cc: 28620@debbugs.gnu.org To: rswgnu@gmail.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Oct 04 21:02:17 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dzovw-0005fK-61 for geb-bug-gnu-emacs@m.gmane.org; Wed, 04 Oct 2017 21:02:16 +0200 Original-Received: from localhost ([::1]:36524 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dzow3-0004WQ-NP for geb-bug-gnu-emacs@m.gmane.org; Wed, 04 Oct 2017 15:02:23 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43588) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dzoty-0002b2-Ma for bug-gnu-emacs@gnu.org; Wed, 04 Oct 2017 15:00:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dzotm-0007Un-UF for bug-gnu-emacs@gnu.org; Wed, 04 Oct 2017 15:00:14 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:40524) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dzotm-0007UC-N9 for bug-gnu-emacs@gnu.org; Wed, 04 Oct 2017 15:00:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dzotm-0003a7-7m for bug-gnu-emacs@gnu.org; Wed, 04 Oct 2017 15:00:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Third Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 04 Oct 2017 19:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 28620 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 28620-submit@debbugs.gnu.org id=B28620.150714355213678 (code B ref 28620); Wed, 04 Oct 2017 19:00:02 +0000 Original-Received: (at 28620) by debbugs.gnu.org; 4 Oct 2017 18:59:12 +0000 Original-Received: from localhost ([127.0.0.1]:49205 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dzosx-0003YY-OZ for submit@debbugs.gnu.org; Wed, 04 Oct 2017 14:59:12 -0400 Original-Received: from mail-wm0-f53.google.com ([74.125.82.53]:57089) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dzosv-0003YL-IM for 28620@debbugs.gnu.org; Wed, 04 Oct 2017 14:59:10 -0400 Original-Received: by mail-wm0-f53.google.com with SMTP id l68so11216829wmd.5 for <28620@debbugs.gnu.org>; Wed, 04 Oct 2017 11:59:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=BDM5OzNuT5AKydOWrVaGBDzgpunHeB65zmc7uSIYe74=; b=JbCyFW53s+JmMVMAuWuOeM80QLpBa5J48ZIWC/3G7WdztAHcXPjn7/JD9wxta1Olsx AAOF5AOaFkM30lQzhuw4853kfvGVoYIGrqDsnhqU/3qOlpE9K5zlNptoP2AtjixXg4S/ rKCUfEae0j/Q6j7VuW+1Xf2X/3cDqMPb0FcBW5W+e/eK6YTvvehjmFbOcY2G/jtSD2y7 qw4chOcOP5LnxfkICLEsftmnsiRnQV7XelXpVODWA9wpRPDAWLAvq6EJUyeVvLZcVcqf szm9YFlmbhsZMwMeRK3QX3SmT7aZHGiOWKUVvLauDWz+wOFqzizqFc3LFZcaK9cdxcfd 1nog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=BDM5OzNuT5AKydOWrVaGBDzgpunHeB65zmc7uSIYe74=; b=sWhmB4NmtBidyjY7oupnV4Ekmv94TctwPMNWWUF6Tx3ZOn1BAPS96eeziZizIkwcVS 38e+sp/bySfyJs6Azc30TT38VY9nx0NS8ZQn1nwR0YKcOBL0JJ0WSNIkbCHJMVHdrA2L +HM35Qwg76ATgdcpTKVlgcFUoKP/YaOr/22/2Bvs6Dj69RxDnUjPmfB182/wuHWlsxZu WTRQlCz0J+f67rBNMj65sLR+jJM0uRZ3gucJZpXysgXBmwVyKxYxxrlbVWFowB/WVu99 EzIxgLO+mq9ze/Qf/rheQgfdlw61cYSILi/6dxdCvK9smR5JOefXR3pxzRYn5HbgGW9Q rpoA== X-Gm-Message-State: AHPjjUjAkDLoVraY6JvihsaSQNg5FIyZrJG7ViAe+P1SjuAb/nr9K/UD uzDl7VqXd/q5FeuG357DLXg= X-Google-Smtp-Source: AOwi7QBIeDl7NnP7zlsYueGvIIzb2+cEhZ3DhxlSuo4U3XrXscTjJU/QZ4b/zTHzlgB1VxqSmN4dsg== X-Received: by 10.28.107.17 with SMTP id g17mr18354981wmc.58.1507143543396; Wed, 04 Oct 2017 11:59:03 -0700 (PDT) Original-Received: from breton.holly.idiocy.org (ip6-2001-08b0-03f8-8129-ad89-e054-05c6-3eca.holly.idiocy.org. [2001:8b0:3f8:8129:ad89:e054:5c6:3eca]) by smtp.gmail.com with ESMTPSA id b11sm151549wrd.91.2017.10.04.11.59.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Oct 2017 11:59:02 -0700 (PDT) Content-Disposition: inline In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:137915 Archived-At: On Wed, Oct 04, 2017 at 01:26:18PM -0400, Robert Weiner wrote: > On Wed, Oct 4, 2017 at 12:30 PM, Alan Third wrote: > > > On Tue, Oct 03, 2017 at 08:15:53PM -0400, Robert Weiner wrote: > > > On Tue, Oct 3, 2017 at 6:40 PM, Alan Third wrote: > > > > As far as I can tell ns_mouse_position returns the frame stored in > > > > dpyinfo->last_mouse_frame, which is set by EmacsView::mouseDown, > > however: > > > > > > > > If the user clicks a view that isn’t in the key window, by default > > > > the window is brought forward and made key, but the mouse event is > > > > not dispatched. > > > > > > > > > > ​What does "the mouse event is not dispatched mean"? Does it mean Emacs > > > never sees the event? Maybe Emacs sees only that the window has been > > > selected by the window manager and based on that switches to the selected > > > window of the frame? > > > > Precisely that. > > > > ​So how is it that Emacs processes a drag event when the mouse button is > released in the new frame if it never sees the mouseUp (drag release) > event?​ If I drag across frames, on mouseUp, the key binding associated > with mouseUp (mouse-1 as opposed to down-mouse-1 is run). The NSEvent is delivered to the EmacsView belonging to the frame where the drag was initiated. I don’t think there’s anything we can do to change that. > > The mouse wheel code is also handled in mouseDown, the difference is > > that macOS always sends the mouse wheel event to the emacs frame under > > the mouse pointer, whereas the mouse click event is not sent when the > > frame is not already key (i.e. selected). > > > > ​Can you show some sample code that would make macOS send the mouse drag > release event to the frame under the mouse pointer just as the scroll wheel > code does. I have looked at this mouseUp code in nsterm.m but cannot get > it to do this. I have managed to inject a focus in event to the mouseUp​ > function and make its event frame the key frame (selected frame) but its > event frame is the wrong one (it always has the frame of the mouseDown > event). I don’t believe it’s possible. As I described before we’d have to do something like: [...] get a list of NSWindows, iterate over them to find out which one the mouse pointer is over, convert that NSWindow back to an Emacs frame, and [return it]. > > AFAICT Emacs does the right thing here, exactly the same thing as > > every other macOS app. > > > ​As Eli noted, this does not happen under MS Windows. I want to have > behavior that allows for drags across frames. The present code does not, > so whether it is consistent with Mac UI guidelines, it is not useful for > that purpose. I would like your help in figuring out how to enable such > behavior as you seem to understand the macOS event flow well. But which behaviour? I can’t work out exactly what we’re talking about here. Are you trying to get cross‐frame dragging working or are you genuinely concerned that Emacs doesn’t receive a click event when the frame is selected using the mouse? These seem like two different things to me. > > There’s nothing fancy here, emacsframe is an instance variable > > associated with the EmacsView that macOS sends the mouse event to. > > > ​So show me how and where I could set that variable to the frame of the > mouse position at the point of mouseUp​ and I will test it and let people > know if it works. Fns_frame_list_z_order in nsfns.m does some of what’s described above... But... It looks like there’s maybe a neater way to get the current frame under the mouse... Lisp_Object frame = Qnil; NSWindow *w = [NSApp windowWithWindowNumber: [NSWindow windowNumberAtPoint:[NSEvent mouseLocation] belowWindowWithWindowNumber:0]]; if (w != nil) XSETFRAME (frame, ((EmacsView *)[w delegate])->emacsframe); I’ve not tested this, so it may not work at all. Note that [NSEvent mouseLocation] returns an NSPoint indicating where the mouse is *right now*. It would probably be more sensible to use any co‐ordinates provided by the event itself. -- Alan Third