From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Timo Savola Newsgroups: gmane.emacs.devel Subject: GtkPlug patch Date: Tue, 27 Dec 2005 01:09:42 +0200 Message-ID: <1135638582.8912.53.camel@localhost.localdomain> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-/D4Ho5RiyfIB0AyimlJY" X-Trace: sea.gmane.org 1135657078 32620 80.91.229.2 (27 Dec 2005 04:17:58 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 27 Dec 2005 04:17:58 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Dec 27 05:17:56 2005 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Er6HV-0001lq-Sl for ged-emacs-devel@m.gmane.org; Tue, 27 Dec 2005 05:17:50 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Er6Ik-0005II-EZ for ged-emacs-devel@m.gmane.org; Mon, 26 Dec 2005 23:19:06 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Er1Tu-00088Q-0w for emacs-devel@gnu.org; Mon, 26 Dec 2005 18:10:18 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Er1Tr-00087G-Ra for emacs-devel@gnu.org; Mon, 26 Dec 2005 18:10:16 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Er1Tr-00086l-Jk for emacs-devel@gnu.org; Mon, 26 Dec 2005 18:10:15 -0500 Original-Received: from [213.243.153.37] (helo=smtp1.pp.htv.fi) by monty-python.gnu.org with esmtp (Exim 4.34) id 1Er1Tk-0008UL-Ro for emacs-devel@gnu.org; Mon, 26 Dec 2005 18:10:09 -0500 Original-Received: from [192.168.1.104] (cs78235208.pp.htv.fi [62.78.235.208]) by smtp1.pp.htv.fi (Postfix) with ESMTP id 7306D7FC24 for ; Tue, 27 Dec 2005 01:08:51 +0200 (EET) Original-To: emacs-devel@gnu.org X-Mailer: Evolution 2.4.1 X-Mailman-Approved-At: Mon, 26 Dec 2005 23:18:50 -0500 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:48400 Archived-At: --=-/D4Ho5RiyfIB0AyimlJY Content-Type: text/plain Content-Transfer-Encoding: 7bit Hi. I wanted to add XEmbed[1] support to Emacs and noticed that it's really easy to accomplish with the new GTK support. The attached patches implement that: emacs-parentid.patch Add the --parent-id command-line option to set the parent-id frame option (which was already implemented). emacs-parent-fix.patch For some reason x-create-frame resets parent_desc to the root window after first setting it according to the parent-id option. This patch removes that seemingly redundant assignment. emacs-gtkplug.patch Creates a GtkPlug instead of GtkWindow when parent_desc is set. I created the patches against the CVS version dated 2005-12-19 because I failed to "make bootstrap" for HEAD (batch-update-autoloads failed at vc-annotate-car-last-cons). embedder.py is a PyGTK test program that can be used with command: ./embedder.py path/to/patched/emacs I'm looking forward to getting this feature into Emacs. Please criticize my implementation (I've never hacked Emacs before) or provide instructions if I can do something more to help. (Please put me to CC when replying.) timo [1] http://freedesktop.org/Standards/xembed-spec --=-/D4Ho5RiyfIB0AyimlJY Content-Disposition: attachment; filename=emacs-gtkplug.patch Content-Type: text/x-patch; name=emacs-gtkplug.patch; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit diff -u -r1.70 gtkutil.c --- src/gtkutil.c 20 Sep 2005 20:07:15 -0000 1.70 +++ src/gtkutil.c 26 Dec 2005 19:49:12 -0000 @@ -716,7 +716,11 @@ BLOCK_INPUT; - wtop = gtk_window_new (GTK_WINDOW_TOPLEVEL); + if (f->output_data.x->explicit_parent) + wtop = gtk_plug_new (f->output_data.x->parent_desc); + else + wtop = gtk_window_new (GTK_WINDOW_TOPLEVEL); + xg_set_screen (wtop, f); wvbox = gtk_vbox_new (FALSE, 0); --=-/D4Ho5RiyfIB0AyimlJY Content-Disposition: attachment; filename=emacs-parentid.patch Content-Type: text/x-patch; name=emacs-parentid.patch; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit diff -u -r1.390 startup.el --- lisp/startup.el 22 Nov 2005 03:32:50 -0000 1.390 +++ lisp/startup.el 26 Dec 2005 19:48:55 -0000 @@ -149,7 +149,8 @@ ("--vertical-scroll-bars" 0 x-handle-switch vertical-scroll-bars t) ("--line-spacing" 1 x-handle-numeric-switch line-spacing) ("--border-color" 1 x-handle-switch border-color) - ("--smid" 1 x-handle-smid)) + ("--smid" 1 x-handle-smid) + ("--parent-id" 1 x-handle-parent-id)) "Alist of X Windows options. Each element has the form (NAME NUMARGS HANDLER FRAME-PARAM VALUE) diff -u -r1.184 x-win.el --- lisp/term/x-win.el 2 Nov 2005 21:43:21 -0000 1.184 +++ lisp/term/x-win.el 26 Dec 2005 19:48:59 -0000 @@ -181,6 +181,15 @@ (setq initial-frame-alist (cons (cons 'name x-resource-name) initial-frame-alist))) +;; Handle the --parent-id option. +(defun x-handle-parent-id (switch) + (or (consp x-invocation-args) + (error "%s: missing argument to `%s' option" (invocation-name) switch)) + (setq parent-id (string-to-number (car x-invocation-args)) + x-invocation-args (cdr x-invocation-args)) + (setq initial-frame-alist (cons (cons 'parent-id parent-id) + initial-frame-alist))) + (defvar x-display-name nil "The X display name specifying server and X frame.") diff -u -r1.380 emacs.c --- src/emacs.c 23 Nov 2005 07:19:03 -0000 1.380 +++ src/emacs.c 26 Dec 2005 19:49:03 -0000 @@ -322,6 +322,7 @@ --title, -T TITLE title for initial Emacs frame\n\ --vertical-scroll-bars, -vb enable vertical scroll bars\n\ --xrm XRESOURCES set additional X resources\n\ +--parent-id XID set parent window\n\ --help display this help and exit\n\ --version output version information and exit\n\ \n" @@ -1859,6 +1860,7 @@ { "-title", 0, 10, 1 }, { "-name", "--name", 10, 1 }, { "-xrm", "--xrm", 10, 1 }, + { "-parent-id", "--parent-id", 10, 1 }, { "-r", "--reverse-video", 5, 0 }, { "-rv", 0, 5, 0 }, { "-reverse", 0, 5, 0 }, --=-/D4Ho5RiyfIB0AyimlJY Content-Disposition: attachment; filename=emacs-parent-fix.patch Content-Type: text/x-patch; name=emacs-parent-fix.patch; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit diff -u -r1.649 xfns.c --- src/xfns.c 8 Dec 2005 15:48:56 -0000 1.649 +++ src/xfns.c 26 Dec 2005 20:50:33 -0000 @@ -3265,8 +3265,6 @@ x_default_parameter (f, parms, Qfullscreen, Qnil, "fullscreen", "Fullscreen", RES_TYPE_SYMBOL); - f->output_data.x->parent_desc = FRAME_X_DISPLAY_INFO (f)->root_window; - /* Compute the size of the X window. */ window_prompting = x_figure_window_size (f, parms, 1); --=-/D4Ho5RiyfIB0AyimlJY Content-Disposition: attachment; filename=embedder.py Content-Type: text/x-python; name=embedder.py; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit #!/usr/bin/env python import sys import os import gobject import gtk failure = False child = None def on_socket_map(socket, command): global child, failure try: child = os.spawnvp(os.P_NOWAIT, command[0], command + ['--parent-id', str(socket.get_id())]) gobject.child_watch_add(child, on_child_exited) except: failure = True raise def on_child_exited(pid, condition): gtk.main_quit() print 'Child exit condition:', condition def on_window_delete(window, event): gtk.main_quit() os.kill(child, 15) return False def main(args): window = gtk.Window() window.set_default_size(640, 480) window.set_title('Embedder') window.set_property('border-width', 4) window.connect('delete-event', on_window_delete) frame = gtk.Frame() frame.set_property('shadow-type', gtk.SHADOW_IN) window.add(frame) socket = gtk.Socket() socket.connect_after('map', on_socket_map, args) frame.add(socket) window.show_all() if failure: sys.exit(1) gtk.main() if __name__ == '__main__': main(sys.argv[1:]) --=-/D4Ho5RiyfIB0AyimlJY Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --=-/D4Ho5RiyfIB0AyimlJY--