From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?UTF-8?Q?Cl=c3=a9ment_Pit-Claudel?= Newsgroups: gmane.emacs.devel Subject: Re: x-export-frames for non-Cairo builds Date: Fri, 26 Jan 2018 11:08:17 -0500 Message-ID: References: <83372tm491.fsf@gnu.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 1516983285 17340 195.159.176.226 (26 Jan 2018 16:14:45 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 26 Jan 2018 16:14:45 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jan 26 17:14:41 2018 Return-path: Envelope-to: ged-emacs-devel@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 1ef6dp-0002QT-Ph for ged-emacs-devel@m.gmane.org; Fri, 26 Jan 2018 17:14:13 +0100 Original-Received: from localhost ([::1]:36331 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef6fq-00047P-Hg for ged-emacs-devel@m.gmane.org; Fri, 26 Jan 2018 11:16:18 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33450) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef6eZ-0003e3-66 for emacs-devel@gnu.org; Fri, 26 Jan 2018 11:15:00 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef6eV-0000lQ-W7 for emacs-devel@gnu.org; Fri, 26 Jan 2018 11:14:59 -0500 Original-Received: from mail-io0-x231.google.com ([2607:f8b0:4001:c06::231]:37709) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef6eV-0000l4-RL; Fri, 26 Jan 2018 11:14:55 -0500 Original-Received: by mail-io0-x231.google.com with SMTP id f89so949942ioj.4; Fri, 26 Jan 2018 08:14:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=qDkvj3qlEbCFn0b6u1Q3UiA1jMUyv8WFd7IK5xxPuJA=; b=WoBG7Jdby/LTKc+lrSEQvMWqgzHGHoJMXWo/GOh4MxD/boJH8tBdBIwwV7qoAtVuya MbzN1R4atY2JVO9kbwBcsKOUioRYNzFfERvuJTw+Xq8TMpHva+XgcxJAx9d32zZfjMsO jl/R+7SxqZppcApXi6FcIonUnTiHScGA2AWk2AjBcAJmGegVJ0Xj8dsUq5bfrP4FTGg4 TSfEdIBA/muwDt/lFbI8+ZAv4VcOc28PgYmfzlNbdX+Kzmfy84etziT2UyCoh24STLaq cOqNha1X5Z2NhCpM8XjAewXSRxqKJ9BadpJYojPdz38kPFmJXU6jbrawibUnq1PkluBc pZ6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=qDkvj3qlEbCFn0b6u1Q3UiA1jMUyv8WFd7IK5xxPuJA=; b=DCbKh/bZJJ09VVVni74X2PBlXiTV/OaRfz22a1d9RxLLJ1wW30Qv7Nta/bAv2YoRZe huQScrd+ez45YR/EHmK+0V0lnclq+M5QylZPoElclCIuTBUucmUY5rj43jc8901LKpfz hLzYqmqD/ZuNY9gJ/YXaeDwdNJt5ooPMmbDgMgsc6WnLIHNKj8s8Ia5jAz+/4x+8cSsz 5jibzmqvSzDahUKwZlxtnVul2A2AuWGno3Ke8eHc/akdAy+UANJvsg1JMtcbatpKgr1B k5bZOd9j8WKksJyUne+WOWbQCX9CjznPpsQtJz0DTP6XYNdKCS07gexX9JaAmKC0a6Si 2Dtg== X-Gm-Message-State: AKwxytd0TEyX2jjswm3KpxmoCUVn4VIemLa5b2+8wrpRlOYHwNTaKoRZ /tkJoAWz2+hMA4kBif1uzZidS6iF X-Google-Smtp-Source: AH8x224gvA6iM1+MFo4MCgUsyudhwQGWcy7V7gLvus7k59IiQGS9VAxhj4l94SuH7H9tz6MXP7uUDQ== X-Received: by 10.107.19.149 with SMTP id 21mr16355037iot.109.1516982898641; Fri, 26 Jan 2018 08:08:18 -0800 (PST) Original-Received: from [18.26.2.123] (26-2-123.dynamic.csail.mit.edu. [18.26.2.123]) by smtp.gmail.com with ESMTPSA id w6sm674279itc.5.2018.01.26.08.08.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Jan 2018 08:08:18 -0800 (PST) In-Reply-To: <83372tm491.fsf@gnu.org> Content-Language: en-GB X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4001:c06::231 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:222255 Archived-At: On 2018-01-26 03:08, Eli Zaretskii wrote: >> From: Clément Pit-Claudel >> Date: Thu, 25 Jan 2018 18:25:55 -0500 >> >> I'd like to capture screenshots of Emacs frames from inside Emacs (currently I use `import' or `xwd', but they don't always work well). >> On Cairo there's x-export-frame, but I don't think there's an equivalent function for other builds. >> >> The following draft seems to work nicely for me (on GTK3) >> >> DEFUN ("x-export-png", Fx_export_png, Sx_export_png, 0, 1, 0, >> doc: /* Save FRAME as 'screenshot.png'. */) >> (Lisp_Object frame) >> { > > Please, not another x-FOO function that is very likely to have 4 > different implementations. Instead, please define a single function > whose name does NOT start with "x-", and make it have a GTK-specific > and a Cairo-specific implementation, which (the implementations) > ideally should not be exported to Lisp. Thanks; understood. I will prepare a patch. >> GdkWindow *w = gtk_widget_get_window (FRAME_GTK_WIDGET (f)); >> GdkPixbuf *pb = gdk_pixbuf_get_from_window(w, 0, 0, width, height); >> gdk_pixbuf_save (pb, "/tmp/screenshot.png", "png", NULL, NULL); > > That hard-coded file name is a no-no. Yes, of course. Sorry if it was unclear that I didn't intend to propose to merge this code as-is ^^ > The function should probably > accept an optional file name, and by default use some defcustom, which > I think should be a relative file name, i.e. created in the current > directory. AFAIU, the image format should also be an optional > argument (even though not all GUI frames will support that). OK, these are great ideas. But do you think it's better to save the image, rather than what x-export-frame currently does? >> * Assuming proper error checking, documentation, and adjustments, would there be interest in merging this? > > Yes. Implementations for other window-systems are welcome. Super. >> * Where should this code go? Should it be merged into x-export-frames? > > frame.c looks like the best place to me. Great. I hope someone can comment on gdk_pixbuf_get_from_drawable/gdk_pixbuf_xlib_get_from_drawable :) Thanks again, Clément.