Commit ea113b66 authored by Joakim Verona's avatar Joakim Verona

initial move from git to bzr

parent 85350e06
;;test like:
;; cd /path/to/xwidgets-emacs-dir
;; make all&& src/emacs -q --eval "(progn (load \"`pwd`/lisp/xwidget-test.el\") (xwidget-demo-basic))"
;; you should see:
;; - a gtk button
;; - a gtk toggle button
;; - a gtk slider button
;; - an xembed window(using gtk_socket) showing another emacs instance
;; - an xembed window(using gtk_socket) showing an uzbl web browser if its installed
;;the widgets will move when you type in the buffer. good!
;;there will be redrawing issues when widgets change rows, etc. bad!
;;its currently difficult to give kbd focus to the xembedded emacs,
;;but try evaling the following:
;; (xwidget-set-keyboard-grab 3 1)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; demo functions
(require 'xwidget)
(defun xwidget-demo-basic ()
(interactive)
(insert "xwidgetdemo<<< a button. another button\n")
(xwidget-insert (point-min) 1 "button" 40 50 1)
(xwidget-insert 15 2 "toggle" 60 30 2)
(xwidget-insert 30 3 "emacs" 400 200 3)
(xwidget-insert 20 4 "slider" 100 50 4)
(xwidget-insert 40 3 "uzbl" 400 400 5)
(define-key (current-local-map) [xwidget-event] 'xwidget-handler-demo-basic)
)
(defun xwidget-demo-single ()
(interactive)
(insert "xwidgetdemo<<< a button. another button\n")
(xwidget-insert (point-min) 1 "1" 200 300 1)
(define-key (current-local-map) [xwidget-event] 'xwidget-handler-demo-basic)
)
;it doesnt seem gtk_socket_steal works very well. its deprecated.
; xwininfo -int
; then (xwidget-embed-steal 3 <winid>)
(defun xwidget-demo-grab ()
(interactive)
(insert "0 <<< grabbed appp will appear here\n")
(xwidget-insert 1 1 3 "1" 1000 1000)
(define-key (current-local-map) [xwidget-event] 'xwidget-handler-demo-grab)
)
;ive basically found these xembeddable things:
;openvrml
;emacs
;mplayer
;surf
;uzbl
;try the openvrml:
;/usr/libexec/openvrml-xembed 0 ~/Desktop/HelloWorld.wrl
(defun xwidget-handler-demo-basic ()
(interactive)
(message "stuff happened to xwidget %S" last-input-event)
(let*
((xwidget-event-type (nth 2 last-input-event))
(xwidget-id (nth 1 last-input-event)))
(cond ( (eq xwidget-event-type 'xembed-ready)
(let*
((xembed-id (nth 3 last-input-event)))
(message "xembed ready %S" xembed-id)
;;will start emacs/uzbl in a xembed socket when its ready
(cond
((eq 3 xwidget-id)
(start-process "xembed" "*xembed*" (format "%ssrc/emacs" default-directory) "-q" "--parent-id" (number-to-string xembed-id) ) )
((eq 5 xwidget-id)
(start-process "xembed2" "*xembed2*" "uzbl" "-s" (number-to-string xembed-id) "http://www.fsf.org" ) )
)
)))))
(defun xwidget-handler-demo-grab ()
(interactive)
(message "stuff happened to xwidget %S" last-input-event)
(let*
((xwidget-event-type (nth 2 last-input-event)))
(cond ( (eq xwidget-event-type 'xembed-ready)
(let*
((xembed-id (nth 3 last-input-event)))
(message "xembed ready %S" xembed-id)
)
))))
(defun xwidget-dummy-hook ()
(message "xwidget dummy hook called"))
; (xwidget-resize-hack 1 200 200)
;(xwidget-demo-basic)
\ No newline at end of file
;; xwidget.el - api functions for xwidgets
;; see xwidget.c for more api functions
(require 'xwidget-internal)
(defun xwidget-insert (pos type title width height &optional id)
"Insert an xwidget at POS, given ID, TYPE, TITLE WIDTH and HEIGHT.
Return ID
ID will be made optional, but it isnt implemented yet!
currently interface is lame:
:type 1=button, 2=toggle btn, 3=xembed socket(id will be printed to stdout)
obviously these should be symbols
:xwidget-id 1, MUST be unique and < 100 !
if slightly wrong, emacs WILL CRASH
These issues are of course fixable but I will continue to
hand-wave issues like these until the hard parts are solved.
"
(goto-char pos)
(put-text-property (point) (+ 1 (point)) 'display (list 'xwidget ':xwidget-id id ':type type ':title title ':width width ':height height))
id)
(defun xwidget-resize-at (pos width height)
"Resize xwidget at postion POS to WIDTH and HEIGHT."
(let*
((xwidget-prop (cdr (get-text-property pos 'display)))
(id (plist-get xwidget-prop ':xwidget-id)))
(setq xwidget-prop (plist-put xwidget-prop ':width width))
(setq xwidget-prop (plist-put xwidget-prop ':height height))
(put-text-property pos (+ 1 pos) 'display (cons 'xwidget xwidget-prop))
(message "prop %s" xwidget-prop)
(message "id %d w %d h %d" id width height)
(xwidget-resize-internal id width height)
))
;; use declare here?
;; (declare-function xwidget-resize-internal "xwidget.c" )
;; check-declare-function?
(provide 'xwidget)
......@@ -337,8 +337,10 @@ obj= dispnew.o frame.o scroll.o xdisp.o menu.o $(XMENU_OBJ) window.o \
process.o callproc.o \
region-cache.o sound.o atimer.o \
doprnt.o strftime.o intervals.o textprop.o composite.o md5.o \
xwidget.o \
$(MSDOS_OBJ) $(MSDOS_X_OBJ) $(NS_OBJ) $(CYGWIN_OBJ) $(FONT_OBJ)
xwidget.o: xwidget.c xwidget.h
## Object files used on some machine or other.
## These go in the DOC file on all machines in case they are needed.
SOME_MACHINE_OBJECTS = dosfns.o msdos.o \
......
......@@ -24,7 +24,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#define DISPEXTERN_H_INCLUDED
#ifdef HAVE_X_WINDOWS
#include <X11/Xlib.h>
#ifdef USE_X_TOOLKIT
#include <X11/Intrinsic.h>
......@@ -113,7 +112,7 @@ enum window_part
/* If GLYPH_DEBUG is non-zero, additional checks are activated. Turn
it off by defining the macro GLYPH_DEBUG to zero. */
#define GLYPH_DEBUG 1
#ifndef GLYPH_DEBUG
#define GLYPH_DEBUG 0
#endif
......@@ -281,7 +280,10 @@ enum glyph_type
IMAGE_GLYPH,
/* Glyph is a space of fractional width and/or height. */
STRETCH_GLYPH
STRETCH_GLYPH,
/* Glyph is an external widget drawn by the GUI toolkit. */
XWIDGET_GLYPH
};
......@@ -331,7 +333,7 @@ struct glyph
/* Which kind of glyph this is---character, image etc. Value
should be an enumerator of type enum glyph_type. */
unsigned type : 2;
unsigned type : 3;
/* 1 means this glyph was produced from multibyte text. Zero
means it was produced from unibyte text, i.e. charsets aren't
......@@ -415,6 +417,8 @@ struct glyph
/* Image ID for image glyphs (type == IMAGE_GLYPH). */
unsigned img_id;
unsigned xwidget_id;
/* Sub-structure for type == STRETCH_GLYPH. */
struct
{
......@@ -1262,6 +1266,8 @@ struct glyph_string
/* Image, if any. */
struct image *img;
int xwidget_id;
/* Slice */
struct glyph_slice slice;
......@@ -1912,7 +1918,9 @@ enum display_element_type
IT_TRUNCATION,
/* Continuation glyphs. See the comment for IT_TRUNCATION. */
IT_CONTINUATION
IT_CONTINUATION,
IT_XWIDGET
};
......@@ -1961,6 +1969,7 @@ enum it_method {
GET_FROM_C_STRING,
GET_FROM_IMAGE,
GET_FROM_STRETCH,
GET_FROM_XWIDGET,
NUM_IT_METHODS
};
......@@ -2162,6 +2171,12 @@ struct it
struct {
Lisp_Object object;
} stretch;
/* method == GET_FROM_XWIDGET */
struct {
Lisp_Object object;
int xwidget_lalala;
} xwidget;
} u;
/* current text and display positions. */
......@@ -2275,6 +2290,10 @@ struct it
/* If what == IT_IMAGE, the id of the image to display. */
int image_id;
/* If what == IT_XWIDGET*/
int xwidget_id;
/* Values from `slice' property. */
struct it_slice slice;
......@@ -3334,3 +3353,4 @@ extern Lisp_Object x_default_parameter P_ ((struct frame *, Lisp_Object,
/* arch-tag: c65c475f-1c1e-4534-8795-990b8509fd65
(do not change this comment) */
......@@ -3638,6 +3638,7 @@ update_single_window (w, force_p)
{
if (w->must_be_updated_p)
{
printf("window %d must be updated\n");
struct frame *f = XFRAME (WINDOW_FRAME (w));
/* Record that this is not a frame-based redisplay. */
......@@ -4000,6 +4001,10 @@ update_window (w, force_p)
add_window_display_history (w, w->current_matrix->method, paused_p);
#endif
if ((XWINDOW(FRAME_SELECTED_WINDOW (SELECTED_FRAME()))) == (w))
xwidget_end_redisplay(w->current_matrix);
clear_glyph_matrix (desired_matrix);
return paused_p;
......
......@@ -54,6 +54,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "buffer.h"
#include "window.h"
#include "xwidget.h"
#include "systty.h"
#include "blockinput.h"
#include "syssignal.h"
......@@ -1642,6 +1644,7 @@ main (int argc, char **argv)
syms_of_xfns ();
syms_of_xmenu ();
syms_of_fontset ();
syms_of_xwidget();
syms_of_xsettings ();
#ifdef HAVE_X_SM
syms_of_xsmfns ();
......
......@@ -500,6 +500,10 @@ struct frame
/* All display backends seem to need these two pixel values. */
unsigned long background_pixel;
unsigned long foreground_pixel;
/* xwidgets need the gtk container to place gtk widgets*/
//GtkWidget *gwfixed;
void *gwfixed;//JAVE TODO i dont feel like fixing all compilation errors right now
};
#define FRAME_KBOARD(f) ((f)->terminal->kboard)
......
......@@ -754,6 +754,10 @@ xg_pix_to_gcolor (w, pixel, c)
/* Create and set up the GTK widgets for frame F.
Return 0 if creation failed, non-zero otherwise. */
int
xg_create_frame_widgets (f)
FRAME_PTR f;
......@@ -775,7 +779,7 @@ xg_create_frame_widgets (f)
xg_set_screen (wtop, f);
wvbox = gtk_vbox_new (FALSE, 0);
wfixed = gtk_fixed_new (); /* Must have this to place scroll bars */
f->gwfixed = wfixed = gtk_fixed_new (); /* Must have this to place scroll bars */
if (! wtop || ! wvbox || ! wfixed)
{
......
......@@ -28,6 +28,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "window.h"
#include "blockinput.h"
#include "region-cache.h"
#include "xwidget.h"
#ifndef NULL
#define NULL 0
......@@ -2001,6 +2002,8 @@ void
modify_region (struct buffer *buffer, EMACS_INT start, EMACS_INT end,
int preserve_chars_modiff)
{
// printf("modify region\n");
xwidget_modify_region();
struct buffer *old_buffer = current_buffer;
if (buffer != old_buffer)
......
......@@ -485,6 +485,7 @@ Lisp_Object Qsave_session;
#ifdef HAVE_DBUS
Lisp_Object Qdbus_event;
#endif
Lisp_Object Qxwidget_event;
Lisp_Object Qconfig_changed_event;
/* Lisp_Object Qmouse_movement; - also an event header */
......@@ -4161,7 +4162,7 @@ kbd_buffer_get_event (kbp, used_mouse_menu, end_time)
kbd_fetch_ptr = event + 1;
}
#endif
else if (event->kind == CONFIG_CHANGED_EVENT)
else if (event->kind == CONFIG_CHANGED_EVENT || event->kind == XWIDGET_EVENT)
{
obj = make_lispy_event (event);
kbd_fetch_ptr = event + 1;
......@@ -6060,6 +6061,8 @@ make_lispy_event (event)
return apply_modifiers (event->modifiers, event->arg);
return event->arg;
case USER_SIGNAL_EVENT:
/* A user signal. */
{
......@@ -6078,6 +6081,11 @@ make_lispy_event (event)
return Fcons (Qdbus_event, event->arg);
}
#endif /* HAVE_DBUS */
case XWIDGET_EVENT:
{
printf("cool, an xwidget event arrived in make_lispy_event!\n");
return Fcons (Qxwidget_event,event->arg);
}
case CONFIG_CHANGED_EVENT:
return Fcons (Qconfig_changed_event,
......@@ -11729,6 +11737,11 @@ syms_of_keyboard ()
staticpro (&Qdbus_event);
#endif
Qxwidget_event = intern ("xwidget-event");
staticpro (&Qxwidget_event);
Qmenu_enable = intern ("menu-enable");
Qconfig_changed_event = intern_c_string ("config-changed-event");
staticpro (&Qconfig_changed_event);
......
......@@ -208,6 +208,8 @@ enum event_kind
/* Non-key system events (e.g. application menu events) */
, NS_NONKEY_EVENT
#endif
/* events generated by xwidgets*/
, XWIDGET_EVENT
};
......
......@@ -51,6 +51,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "nsterm.h"
#endif
#include "xwidget.h"
Lisp_Object Qwindowp, Qwindow_live_p, Qwindow_configuration_p;
Lisp_Object Qdisplay_buffer;
......@@ -3666,6 +3667,7 @@ selected window before each command. */)
SET_PT (new_point);
}
xwidget_invalidate();
windows_or_buffers_changed++;
return window;
}
......
This diff is collapsed.
......@@ -3047,7 +3047,7 @@ unwind_create_frame (frame)
#if GLYPH_DEBUG
/* Check that reference counts are indeed correct. */
xassert (dpyinfo->reference_count == dpyinfo_refcount);
xassert (dpyinfo->image_cache->refcount == image_cache_refcount);
//xassert (dpyinfo->image_cache->refcount == image_cache_refcount); //FIXME doesnt compilex
#endif
return Qt;
}
......@@ -3285,8 +3285,9 @@ This function is an internal primitive--use `make-frame' instead. */)
/* With FRAME_X_DISPLAY_INFO set up, this unwind-protect is safe. */
record_unwind_protect (unwind_create_frame, frame);
#if GLYPH_DEBUG
image_cache_refcount = FRAME_IMAGE_CACHE (f)->refcount;
dpyinfo_refcount = dpyinfo->reference_count;
//JAVE TODO crashes
//image_cache_refcount = FRAME_IMAGE_CACHE (f)->refcount;
//dpyinfo_refcount = dpyinfo->reference_count;
#endif /* GLYPH_DEBUG */
/* These colors will be set anyway later, but it's important
......
......@@ -69,6 +69,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "coding.h"
#include "frame.h"
#include "dispextern.h"
#include "xwidget.h"
#include "fontset.h"
#include "termhooks.h"
#include "termopts.h"
......@@ -2419,7 +2420,7 @@ x_draw_image_foreground_1 (s, pixmap)
/* Draw part of the background of glyph string S. X, Y, W, and H
give the rectangle to draw. */
static void
void
x_draw_glyph_string_bg_rect (s, x, y, w, h)
struct glyph_string *s;
int x, y, w, h;
......@@ -2645,6 +2646,7 @@ x_draw_glyph_string (s)
{
int relief_drawn_p = 0;
//printf("x_draw_glyph_string: %d\n",s->first_glyph->type);
/* If S draws into the background of its successors, draw the
background of the successors first so that S can draw into it.
This makes S->next use XDrawString instead of XDrawImageString. */
......@@ -2702,6 +2704,11 @@ x_draw_glyph_string (s)
x_draw_image_glyph_string (s);
break;
case XWIDGET_GLYPH:
x_draw_glyph_string_background (s, 0);
x_draw_xwidget_glyph_string (s);
break;
case STRETCH_GLYPH:
x_draw_stretch_glyph_string (s);
break;
......@@ -5889,6 +5896,21 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
EVENT_INIT (inev.ie);
inev.ie.kind = NO_EVENT;
inev.ie.arg = Qnil;
/*try to let events escape to xwidgets if xwidget_owns_kbd. not as easy as it sounds... */
if(xwidget_owns_kbd){
printf("xwidgets own events now!\n");
//according to xembed spec it seems like the toolkit is responsible for forwarding of events, so
//try to let gtk have the event now
*finish = 0;
/*FINISH is X_EVENT_GOTO_OUT if caller should stop reading events.
*FINISH is zero if caller should continue reading events.
*FINISH is X_EVENT_DROP if event should not be passed to the toolkit.*/
goto OTHER;
}
if (pending_event_wait.eventtype == event.type)
pending_event_wait.eventtype = 0; /* Indicates we got it. */
......@@ -6377,11 +6399,15 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
Lisp_Object c;
#ifdef USE_GTK
/* Don't pass keys to GTK. A Tab will shift focus to the
tool bar in GTK 2.4. Keys will still go to menus and
dialogs because in that case popup_activated is TRUE
(see above). */
(see above).
*/
*finish = X_EVENT_DROP;
#endif
event.xkey.state
......
This diff is collapsed.
void x_draw_xwidget_glyph_string P_ ((struct glyph_string *s));
void syms_of_xwidget ();
extern Lisp_Object Qxwidget;
/* Test for xwidget (xwidget . spec) (car must be the symbol xwidget)*/
#define XWIDGETP(x) (CONSP (x) && EQ (XCAR (x), Qxwidget))
int valid_xwidget_p (Lisp_Object object) ;
#include <gtk/gtk.h>
/*
each xwidget instance is described by this struct.
*/
struct xwidget{
int id;
int type;
int hidden;
GtkWidget* widget;
GtkContainer* widgetwindow;
char* title;
int initialized;
int height;
int width;
int x; int y;
Lisp_Object message_hook;
int redisplayed;
GtkContainer* emacswindow;
};
struct xwidget_type
{
/* A symbol uniquely identifying the xwidget type, */
Lisp_Object *type;
/* Check that SPEC is a valid image specification for the given
image type. Value is non-zero if SPEC is valid. */
int (* valid_p) P_ ((Lisp_Object spec));
/* Next in list of all supported image types. */
struct xwidget_type *next;
};
static INLINE struct xwidget_type *lookup_xwidget_type (Lisp_Object symbol);
struct xwidget* xwidget_from_id(int id);
extern int xwidget_owns_kbd;
void xwidget_start_redisplay();
void xwidget_end_redisplay(struct glyph_matrix* matrix);
void xwidget_modify_region();
void xwidget_touch(struct xwidget* xw);
void xwidget_delete(struct xwidget* xw);
void assert_valid_xwidget_id(int id,char *str);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment