From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dov Grobgeld Newsgroups: gmane.emacs.devel Subject: Re: Stylus drawing input? Date: Tue, 24 Jan 2023 10:03:02 +0200 Message-ID: References: <87pmbhpjkc.fsf@web.de> <87cz7eq5uh.fsf@web.de> <0C19A13B-EEFF-486B-BED3-36A4AEF629D8@yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9620"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org, tomas@tuxteam.de To: Po Lu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Jan 24 09:04:10 2023 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 1pKEHp-0002KZ-Kz for ged-emacs-devel@m.gmane-mx.org; Tue, 24 Jan 2023 09:04:09 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKEH5-0003iD-Ay; Tue, 24 Jan 2023 03:03:24 -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 1pKEH1-0003hv-01 for emacs-devel@gnu.org; Tue, 24 Jan 2023 03:03:19 -0500 Original-Received: from mail-lj1-x22a.google.com ([2a00:1450:4864:20::22a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pKEGz-0003b3-6d for emacs-devel@gnu.org; Tue, 24 Jan 2023 03:03:18 -0500 Original-Received: by mail-lj1-x22a.google.com with SMTP id n5so15831810ljc.9 for ; Tue, 24 Jan 2023 00:03:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=b7tkFtPLxf6lGhnjxSIFZ51nz3HpJnedLHck9OcrGTA=; b=hGIj14WhaoTOnFMaWrYXiedhrv50sjBrdDd/H3ypRrgZrFgX7GjxaW5DXi2WqpIJ0K Sw+E0F53XlYD7D5xqZR/ihvfcKG1PC3Kn/D17QK3NXhndD29xYF22Qo+jnnxFhm5SDqw Pvwl+ylTZ8Ca5HLxmPRdd7OeawPNClohRGH4a728X/SXyzLQhAE7aLq15HALYVzUxz80 rI1EYc6DWSF0Kp2Ef7kQYu200v7OGl3NBelAWFJR9th93xU50/cL8ZUSMq01/on/7497 PhOIbMxvDMe5W1w4z7b2daTdgHZc2Ww9Q0fqu4nG3W49b4inNmiF2z+fgG95OK/hPP0/ M/8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=b7tkFtPLxf6lGhnjxSIFZ51nz3HpJnedLHck9OcrGTA=; b=WWY5EgkvbtZGK2UX9xAFCaRbA+n4IPtYKOzf6xvGCpcIrk0GAoLtQ/ZsaeRbYbhNLe SNsBrbtk8GvHcGgi8TfPlZCFITZzEaZVXD3Y5I+gRBLs1eP/Fwv552q6enXRUYYz5cDN lGAzmMMqRy2CGAQjTTm68bJYaVsElMFgCbEtkuV1T4a56ul2cJYcFqXVaTTnWc4DuaWd C2OFsYwF39N375EbmSXAw8Erf4C7vAxQay+BADd8gFrFsqEW3j2QzYQ0h4cgadtv8oSQ zC4AqviqMTSatAYBgYLnbXitSOYHk+vjWFnI3vxGXv9ET92N4O6xPGl++9RSC8+jzIUq /AUA== X-Gm-Message-State: AFqh2kq7VzIsUGJmEJHYT0OlT08mlL9gT3RDNsfqDDPtjRrnUoH62ieR y5D42SnSUlMXBhnEQ8U2pMzaYHHRR0LiiC6sYe4= X-Google-Smtp-Source: AMrXdXsTwmCdGa4oPXK1ThwlPzBr7Fq19sqnLEfqew6FAszVRpRZrjIxCl7wYaNr++ut2aTjkuVUzJqC8AwudLGwzq4= X-Received: by 2002:a05:651c:1315:b0:28b:8da3:57b0 with SMTP id u21-20020a05651c131500b0028b8da357b0mr2250456lja.403.1674547395082; Tue, 24 Jan 2023 00:03:15 -0800 (PST) In-Reply-To: <0C19A13B-EEFF-486B-BED3-36A4AEF629D8@yahoo.com> Received-SPF: pass client-ip=2a00:1450:4864:20::22a; envelope-from=dov.grobgeld@gmail.com; helo=mail-lj1-x22a.google.com 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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:302639 Archived-At: Thanks. I need some guidance on how feasible the following is and how I would go about doing it. 1. How do I draw vector graphics object in an emacs buffer. I.e. line-to, move-to, close-path, fill etc. Do I need to generate the pixels on my own (can be done e.g. with the agg library or with libcairo) and then place the image as on overlay (how?), or is there higher lever interface? Is it accessible from elisp or from C? 2. How can I trace the x,y input coordinates of mouse movement. E.g. I'd like to run a command to enter capture mode, and then catch subsequent motion events of the mouse, until the mouse button is raised. The resulting object should be a list of motion coordinates. 3. How would I do the same for a stylus while catching additional pressure data? 4. Given some vector graphics objects drawn on the screen, how would I do mouse hit detection, so that doing a mouse click on the object, returns the object id? (This I can do "offline" though, by drawing a "label image" of the buffer contents on mouse press end then finding the label of the object under the mouse.) Thanks! On Tue, Jan 24, 2023 at 1:47 AM Po Lu wrote: > > Emacs 29 already has native support for version 2 of the the X Input extension and its various input devices. > > See the node Touchscreen Events in the Emacs Lisp reference manual. This is not yet supported on the PGTK build. > > On January 24, 2023 5:15:58 AM GMT+08:00, Dov Grobgeld wrote: > >On X11, to read stylus input, we need to use XInput extension. > > > >Gdk, used in gtk, has a good abstraction to it that allows doing code > >like the following to distinguish between mouse and stylus input in > >its motion notify callback, and in this case extract the pressure. > > > > int on_motion_notify_event(GdkEventMotion *event) > > { > > // The pressure value is: > > // found=false for mouse motion > > // 0 for proximity stylus motion > > // >0 for the pen touching the pad > > double pressure=-1; > > int found = gdk_event_get_axis((GdkEvent*)event, > >GDK_AXIS_PRESSURE, &pressure); > > GdkDeviceTool *tool = gdk_event_get_device_tool((GdkEvent*)event); > > > > // For mouse the tool isn't defined, so we set a default -1 > > GdkDeviceToolType tool_type = (GdkDeviceToolType)(-1); > > if (tool) > > // true for stylus only > > tool_type = gdk_device_tool_get_tool_type (tool); > > > > printf("motion_notify: tool_type=%d, > >x=%.3f},y=%.3f},found_stylus=%d,pressure=%.3f\n", > > (int)tool_type, > > event->x, event->y, found, pressure); > > return TRUE; > > } > > > >To support styluses (i.e. to distinguish them from mouse events) we > >need something similar in emacs. > > > >Regards, > > > > > >On Mon, Jan 16, 2023 at 10:27 AM wrote: > >> > >> On Mon, Jan 16, 2023 at 08:45:55AM +0100, Dr. Arne Babenhauserheide wrote: > >> > PS: Here is a website with a description that does not rely on unfree > >> > platforms: https://misohena.jp/blog/2021-09-21-emacs-easy-draw.html > >> > > >> > The clearest description is a gif, though: > >> > https://misohena.jp/blog/wp-content/uploads/2021-09-21-edraw-example.gif > >> > >> Thanks for the non-github link! > >> > >> Cheers > >> -- > >> t > >