unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* GtkPlug patch
@ 2005-12-26 23:09 Timo Savola
  2005-12-29  7:02 ` Timo Savola
  2006-01-03 13:41 ` Lőrentey Károly
  0 siblings, 2 replies; 22+ messages in thread
From: Timo Savola @ 2005-12-26 23:09 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 1146 bytes --]

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


[-- Attachment #2: emacs-gtkplug.patch --]
[-- Type: text/x-patch, Size: 435 bytes --]

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);

[-- Attachment #3: emacs-parentid.patch --]
[-- Type: text/x-patch, Size: 2035 bytes --]

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 },

[-- Attachment #4: emacs-parent-fix.patch --]
[-- Type: text/x-patch, Size: 439 bytes --]

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);
 

[-- Attachment #5: embedder.py --]
[-- Type: text/x-python, Size: 1020 bytes --]

#!/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:])

[-- Attachment #6: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2006-01-05 10:34 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-26 23:09 GtkPlug patch Timo Savola
2005-12-29  7:02 ` Timo Savola
2005-12-31 11:06   ` Jan Djärv
2005-12-31 11:23     ` Jan Djärv
2005-12-31 17:24     ` mr mike
2006-01-01  2:14       ` Richard M. Stallman
2006-01-01 15:57         ` Jan Djärv
2006-01-02  0:25           ` Richard M. Stallman
2006-01-02  9:18             ` Timo Savola
2006-01-02  9:51               ` Timo Savola
2006-01-02 23:48               ` Richard M. Stallman
2006-01-03  8:45                 ` Timo Savola
2006-01-03  7:53             ` Jan D.
2006-01-03 18:27               ` Richard M. Stallman
2006-01-03 18:37                 ` David Kastrup
2006-01-03 20:29                   ` Timo Savola
2006-01-04  6:15                     ` Richard M. Stallman
2006-01-04 22:11                     ` Jan D.
2006-01-04 22:09                   ` Jan D.
2006-01-05  6:13                     ` Timo Savola
2006-01-05 10:34                       ` Jan D.
2006-01-03 13:41 ` Lőrentey Károly

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).