Mercurial > MadButterfly
annotate src/X_supp.c @ 693:8b7964869f7a
Update window with XImage through XSHM
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Mon, 09 Aug 2010 10:03:54 +0800 |
parents | 201cc86720a3 |
children | 7e64e0f70cb6 |
rev | line source |
---|---|
77 | 1 #include <stdio.h> |
78 | 2 #include <stdlib.h> |
3 #include <string.h> | |
77 | 4 #include <X11/Xlib.h> |
5 #include <X11/Xutil.h> | |
692
201cc86720a3
Fix compiling time warning about cairo xlib
Thinker K.F. Li <thinker@branda.to>
parents:
691
diff
changeset
|
6 #include <cairo-xlib.h> |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
350
diff
changeset
|
7 #include "mb_graph_engine.h" |
186
530bb7728546
Move header files to $(top_srcdir)/include/ and prefixed with 'mb_'.
Thinker K.F. Li <thinker@branda.to>
parents:
185
diff
changeset
|
8 #include "mb_redraw_man.h" |
530bb7728546
Move header files to $(top_srcdir)/include/ and prefixed with 'mb_'.
Thinker K.F. Li <thinker@branda.to>
parents:
185
diff
changeset
|
9 #include "mb_timer.h" |
530bb7728546
Move header files to $(top_srcdir)/include/ and prefixed with 'mb_'.
Thinker K.F. Li <thinker@branda.to>
parents:
185
diff
changeset
|
10 #include "mb_X_supp.h" |
77 | 11 |
691
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
12 #define XSHM 1 |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
13 |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
14 #ifdef XSHM |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
15 /* \sa http://www.xfree86.org/current/mit-shm.html */ |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
16 #include <sys/ipc.h> |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
17 #include <sys/shm.h> |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
18 #include <X11/extensions/XShm.h> |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
19 #endif |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
20 |
122
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
21 #define ERR -1 |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
22 #define OK 0 |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
23 |
224
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
24 #define ONLY_MOUSE_MOVE_RAW 1 |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
25 |
122
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
26 /*! \ingroup xkb |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
27 * @{ |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
28 */ |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
29 struct _X_kb_info { |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
30 int keycode_min, keycode_max; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
31 int ksym_per_code; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
32 KeySym *syms; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
33 subject_t *kbevents; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
34 ob_factory_t *ob_factory; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
35 }; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
36 |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
37 /* @} */ |
462
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
38 #define MAX_MONITORS 200 |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
39 typedef struct { |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
40 int type; |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
41 int fd; |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
42 mb_eventcb_t f; |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
43 void *arg; |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
44 } monitor_t; |
122
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
45 struct _X_MB_runtime { |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
46 Display *display; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
47 Window win; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
48 Visual *visual; |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
350
diff
changeset
|
49 mbe_surface_t *surface, *backend_surface; |
471
e98ae1407ca2
Remove mbe_set_source_surface() from graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
462
diff
changeset
|
50 mbe_pattern_t *surface_ptn; |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
350
diff
changeset
|
51 mbe_t *cr, *backend_cr; |
122
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
52 redraw_man_t *rdman; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
53 mb_tman_t *tman; |
259
e8a784a306d0
Initialize an image loader for X runtime
Thinker K.F. Li <thinker@branda.to>
parents:
249
diff
changeset
|
54 mb_img_ldr_t *img_ldr; |
122
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
55 int w, h; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
56 |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
57 X_kb_info_t kbinfo; |
462
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
58 monitor_t monitors[MAX_MONITORS]; |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
59 int n_monitor; |
122
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
60 |
224
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
61 #ifndef ONLY_MOUSE_MOVE_RAW |
122
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
62 /* States */ |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
63 shape_t *last; |
224
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
64 #endif |
691
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
65 |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
66 #ifdef XSHM |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
67 XImage *ximage; |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
68 XShmSegmentInfo shminfo; |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
69 #endif |
122
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
70 }; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
71 |
693
8b7964869f7a
Update window with XImage through XSHM
Thinker K.F. Li <thinker@branda.to>
parents:
692
diff
changeset
|
72 #ifdef XSHM |
8b7964869f7a
Update window with XImage through XSHM
Thinker K.F. Li <thinker@branda.to>
parents:
692
diff
changeset
|
73 static void |
8b7964869f7a
Update window with XImage through XSHM
Thinker K.F. Li <thinker@branda.to>
parents:
692
diff
changeset
|
74 XSHM_update(X_MB_runtime_t *xmb_rt) { |
8b7964869f7a
Update window with XImage through XSHM
Thinker K.F. Li <thinker@branda.to>
parents:
692
diff
changeset
|
75 GC gc; |
8b7964869f7a
Update window with XImage through XSHM
Thinker K.F. Li <thinker@branda.to>
parents:
692
diff
changeset
|
76 |
8b7964869f7a
Update window with XImage through XSHM
Thinker K.F. Li <thinker@branda.to>
parents:
692
diff
changeset
|
77 gc = DefaultGC(xmb_rt->display, DefaultScreen(xmb_rt->display)); |
8b7964869f7a
Update window with XImage through XSHM
Thinker K.F. Li <thinker@branda.to>
parents:
692
diff
changeset
|
78 if(xmb_rt->ximage) { /* support XSHM */ |
8b7964869f7a
Update window with XImage through XSHM
Thinker K.F. Li <thinker@branda.to>
parents:
692
diff
changeset
|
79 XShmPutImage(xmb_rt->display, |
8b7964869f7a
Update window with XImage through XSHM
Thinker K.F. Li <thinker@branda.to>
parents:
692
diff
changeset
|
80 xmb_rt->win, |
8b7964869f7a
Update window with XImage through XSHM
Thinker K.F. Li <thinker@branda.to>
parents:
692
diff
changeset
|
81 gc, |
8b7964869f7a
Update window with XImage through XSHM
Thinker K.F. Li <thinker@branda.to>
parents:
692
diff
changeset
|
82 xmb_rt->ximage, |
8b7964869f7a
Update window with XImage through XSHM
Thinker K.F. Li <thinker@branda.to>
parents:
692
diff
changeset
|
83 0, 0, 0, 0, |
8b7964869f7a
Update window with XImage through XSHM
Thinker K.F. Li <thinker@branda.to>
parents:
692
diff
changeset
|
84 xmb_rt->w, xmb_rt->h, 0); |
8b7964869f7a
Update window with XImage through XSHM
Thinker K.F. Li <thinker@branda.to>
parents:
692
diff
changeset
|
85 } |
8b7964869f7a
Update window with XImage through XSHM
Thinker K.F. Li <thinker@branda.to>
parents:
692
diff
changeset
|
86 } |
8b7964869f7a
Update window with XImage through XSHM
Thinker K.F. Li <thinker@branda.to>
parents:
692
diff
changeset
|
87 #endif |
8b7964869f7a
Update window with XImage through XSHM
Thinker K.F. Li <thinker@branda.to>
parents:
692
diff
changeset
|
88 |
122
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
89 /*! \defgroup xkb X Keyboard Handling |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
90 * |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
91 * Accept keyboard events from X server and delivery it to |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
92 * application through observer pattern. There is a subject, |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
93 * per X-connection, for that. |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
94 * @{ |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
95 */ |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
96 static int keycode2sym(X_kb_info_t *kbinfo, unsigned int keycode) { |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
97 int sym_idx; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
98 int sym; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
99 |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
100 sym_idx = kbinfo->ksym_per_code * (keycode - kbinfo->keycode_min); |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
101 sym = kbinfo->syms[sym_idx]; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
102 return sym; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
103 } |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
104 |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
105 static int X_kb_init(X_kb_info_t *kbinfo, Display *display, |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
106 redraw_man_t *rdman) { |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
107 int n_syms; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
108 ob_factory_t *factory; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
109 int r; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
110 |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
111 r = XDisplayKeycodes(display, |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
112 &kbinfo->keycode_min, |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
113 &kbinfo->keycode_max); |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
114 if(r == 0) |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
115 return ERR; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
116 |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
117 n_syms = kbinfo->keycode_max - kbinfo->keycode_min + 1; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
118 kbinfo->syms = XGetKeyboardMapping(display, kbinfo->keycode_min, |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
119 n_syms, |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
120 &kbinfo->ksym_per_code); |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
121 if(kbinfo->syms == NULL) |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
122 return ERR; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
123 |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
124 factory = rdman_get_ob_factory(rdman); |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
125 kbinfo->kbevents = subject_new(factory, kbinfo, OBJT_KB); |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
126 if(kbinfo->kbevents == NULL) |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
127 return ERR; |
192
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
128 /*! \todo Make sure ob_factory is still need. */ |
122
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
129 kbinfo->ob_factory = factory; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
130 |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
131 return OK; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
132 } |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
133 |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
134 static void X_kb_destroy(X_kb_info_t *kbinfo) { |
192
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
135 subject_free(kbinfo->kbevents); |
122
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
136 XFree(kbinfo->syms); |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
137 } |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
138 |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
139 /*! \brief Accept X keyboard events from handle_x_event() and dispatch it. |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
140 */ |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
141 static void X_kb_handle_event(X_kb_info_t *kbinfo, XKeyEvent *xkey) { |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
142 unsigned int code; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
143 int sym; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
144 X_kb_event_t event; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
145 |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
146 code = xkey->keycode; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
147 sym = keycode2sym(kbinfo, code); |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
148 if(xkey->type == KeyPress) |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
149 event.event.type = EVT_KB_PRESS; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
150 else if(xkey->type == KeyRelease) |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
151 event.event.type = EVT_KB_RELEASE; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
152 event.event.tgt = event.event.cur_tgt = kbinfo->kbevents; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
153 event.keycode = code; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
154 event.sym = sym; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
155 |
192
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
156 subject_notify(kbinfo->kbevents, &event.event); |
122
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
157 } |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
158 |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
159 /* @} */ |
77 | 160 |
78 | 161 static unsigned int get_button_state(unsigned int state) { |
162 unsigned int but = 0; | |
163 | |
164 if(state & Button1Mask) | |
165 but |= MOUSE_BUT1; | |
166 if(state & Button2Mask) | |
167 but |= MOUSE_BUT2; | |
168 if(state & Button3Mask) | |
169 but |= MOUSE_BUT3; | |
170 | |
171 return but; | |
172 } | |
173 | |
174 static unsigned int get_button(unsigned int button) { | |
175 switch(button) { | |
176 case Button1: | |
177 return MOUSE_BUT1; | |
178 case Button2: | |
179 return MOUSE_BUT2; | |
180 case Button3: | |
181 return MOUSE_BUT3; | |
182 } | |
183 return 0; | |
184 } | |
185 | |
186 /*! \brief Notify observers of the shape at specified | |
187 * position for mouse event. | |
188 * | |
189 * Observers of parent shapes may be called if the subject is not | |
190 * with SUBF_STOP_PROPAGATE flag. The subject of mouse event | |
191 * for a shape is returned by sh_get_mouse_event_subject(). | |
192 */ | |
224
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
193 static void notify_coord_or_shape(redraw_man_t *rdman, |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
194 mb_obj_t *obj, |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
195 co_aix x, co_aix y, int etype, |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
196 unsigned int state, |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
197 unsigned int button) { |
78 | 198 mouse_event_t mouse_event; |
199 subject_t *subject; | |
200 | |
201 mouse_event.event.type = etype; | |
202 mouse_event.x = x; | |
203 mouse_event.y = y; | |
204 mouse_event.but_state = state; | |
205 mouse_event.button = button; | |
206 | |
224
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
207 if(IS_MBO_SHAPES(obj)) |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
208 subject = sh_get_mouse_event_subject((shape_t *)obj); |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
209 else |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
210 subject = coord_get_mouse_event((coord_t *)obj); |
78 | 211 |
192
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
212 subject_notify(subject, (event_t *)&mouse_event); |
78 | 213 } |
214 | |
215 /*! \brief Dispatch all X events in the queue. | |
77 | 216 */ |
83 | 217 static void handle_x_event(X_MB_runtime_t *rt) { |
218 Display *display = rt->display; | |
219 redraw_man_t *rdman = rt->rdman; | |
350
892f4efe2e48
Prevent applications from hanging by massive mouse motion events.
Thinker K.F. Li <thinker@branda.to>
parents:
346
diff
changeset
|
220 XEvent evt, peek_evt; |
77 | 221 XMotionEvent *mevt; |
78 | 222 XButtonEvent *bevt; |
81 | 223 XExposeEvent *eevt; |
122
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
224 XKeyEvent *xkey; |
81 | 225 co_aix x, y, w, h; |
226 | |
227 int eflag = 0; | |
82 | 228 int ex1=0, ey1=0, ex2=0, ey2=0; |
81 | 229 |
84
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
230 shape_t *shape; |
224
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
231 coord_t *root; |
84
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
232 |
78 | 233 unsigned int state, button; |
84
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
234 int in_stroke; |
77 | 235 int r; |
236 | |
529 | 237 /* XXX: For some unknown reason, it causes a segmentation fault to |
238 * called XEventsQueued() after receiving first Expose event | |
239 * and before redraw for the event. | |
240 */ | |
77 | 241 while(XEventsQueued(display, QueuedAfterReading) > 0) { |
242 r = XNextEvent(display, &evt); | |
243 if(r == -1) | |
244 break; | |
245 | |
246 switch(evt.type) { | |
78 | 247 case ButtonPress: |
248 bevt = (XButtonEvent *)&evt; | |
249 x = bevt->x; | |
250 y = bevt->y; | |
251 state = get_button_state(bevt->state); | |
252 button = get_button(bevt->button); | |
253 | |
84
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
254 shape = find_shape_at_pos(rdman, x, y, |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
255 &in_stroke); |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
256 if(shape) |
224
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
257 notify_coord_or_shape(rdman, (mb_obj_t *)shape, |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
258 x, y, EVT_MOUSE_BUT_PRESS, |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
259 state, button); |
78 | 260 break; |
261 | |
262 case ButtonRelease: | |
263 bevt = (XButtonEvent *)&evt; | |
264 x = bevt->x; | |
265 y = bevt->y; | |
266 state = get_button_state(bevt->state); | |
267 button = get_button(bevt->button); | |
268 | |
84
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
269 shape = find_shape_at_pos(rdman, x, y, |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
270 &in_stroke); |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
271 if(shape) |
224
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
272 notify_coord_or_shape(rdman, (mb_obj_t *)shape, |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
273 x, y, EVT_MOUSE_BUT_RELEASE, |
84
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
274 state, button); |
78 | 275 break; |
276 | |
77 | 277 case MotionNotify: |
350
892f4efe2e48
Prevent applications from hanging by massive mouse motion events.
Thinker K.F. Li <thinker@branda.to>
parents:
346
diff
changeset
|
278 while(XEventsQueued(display, QueuedAfterReading) > 0) { |
892f4efe2e48
Prevent applications from hanging by massive mouse motion events.
Thinker K.F. Li <thinker@branda.to>
parents:
346
diff
changeset
|
279 r = XPeekEvent(display, &peek_evt); |
892f4efe2e48
Prevent applications from hanging by massive mouse motion events.
Thinker K.F. Li <thinker@branda.to>
parents:
346
diff
changeset
|
280 if(r == -1) |
892f4efe2e48
Prevent applications from hanging by massive mouse motion events.
Thinker K.F. Li <thinker@branda.to>
parents:
346
diff
changeset
|
281 break; |
892f4efe2e48
Prevent applications from hanging by massive mouse motion events.
Thinker K.F. Li <thinker@branda.to>
parents:
346
diff
changeset
|
282 if(peek_evt.type != MotionNotify) |
892f4efe2e48
Prevent applications from hanging by massive mouse motion events.
Thinker K.F. Li <thinker@branda.to>
parents:
346
diff
changeset
|
283 break; |
892f4efe2e48
Prevent applications from hanging by massive mouse motion events.
Thinker K.F. Li <thinker@branda.to>
parents:
346
diff
changeset
|
284 XNextEvent(display, &evt); |
892f4efe2e48
Prevent applications from hanging by massive mouse motion events.
Thinker K.F. Li <thinker@branda.to>
parents:
346
diff
changeset
|
285 } |
892f4efe2e48
Prevent applications from hanging by massive mouse motion events.
Thinker K.F. Li <thinker@branda.to>
parents:
346
diff
changeset
|
286 if(r == -1) |
892f4efe2e48
Prevent applications from hanging by massive mouse motion events.
Thinker K.F. Li <thinker@branda.to>
parents:
346
diff
changeset
|
287 break; |
892f4efe2e48
Prevent applications from hanging by massive mouse motion events.
Thinker K.F. Li <thinker@branda.to>
parents:
346
diff
changeset
|
288 |
77 | 289 mevt = (XMotionEvent *)&evt; |
290 x = mevt->x; | |
291 y = mevt->y; | |
78 | 292 state = get_button_state(mevt->state); |
77 | 293 |
84
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
294 shape = find_shape_at_pos(rdman, x, y, |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
295 &in_stroke); |
224
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
296 #ifdef ONLY_MOUSE_MOVE_RAW |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
297 if(shape != NULL) { |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
298 notify_coord_or_shape(rdman, (mb_obj_t *)shape, |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
299 x, y, EVT_MOUSE_MOVE_RAW, state, 0); |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
300 } else { |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
301 root = rdman_get_root(rdman); |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
302 notify_coord_or_shape(rdman, (mb_obj_t *)root, |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
303 x, y, EVT_MOUSE_MOVE_RAW, state, 0); |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
304 } |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
305 #else |
84
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
306 if(shape != NULL) { |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
307 if(rt->last != shape) { |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
308 if(rt->last) |
224
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
309 notify_coord_or_shape(rdman, rt->last, x, y, |
84
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
310 EVT_MOUSE_OUT, state, 0); |
224
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
311 notify_coord_or_shape(rdman, shape, x, y, |
84
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
312 EVT_MOUSE_OVER, state, 0); |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
313 rt->last = shape; |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
314 } else |
224
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
315 notify_coord_or_shape(rdman, shape, x, y, |
84
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
316 EVT_MOUSE_MOVE, state, 0); |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
317 } else { |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
318 if(rt->last) { |
224
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
319 notify_coord_or_shape(rdman, rt->last, x, y, |
84
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
320 EVT_MOUSE_OUT, state, 0); |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
321 rt->last = NULL; |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
322 } |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
323 } |
224
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
324 #endif |
77 | 325 break; |
326 | |
122
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
327 case KeyPress: |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
328 case KeyRelease: |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
329 xkey = &evt.xkey; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
330 X_kb_handle_event(&rt->kbinfo, xkey); |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
331 break; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
332 |
77 | 333 case Expose: |
81 | 334 eevt = &evt.xexpose; |
335 x = eevt->x; | |
336 y = eevt->y; | |
337 w = eevt->width; | |
338 h = eevt->height; | |
339 | |
340 if(eflag) { | |
341 if(x < ex1) | |
342 ex1 = x; | |
343 if(y < ey1) | |
344 ey1 = y; | |
345 if((x + w) > ex2) | |
346 ex2 = x + w; | |
347 if((y + h) > ey2) | |
348 ey2 = y + h; | |
349 } else { | |
350 ex1 = x; | |
351 ey1 = y; | |
352 ex2 = x + w; | |
353 ey2 = y + h; | |
354 eflag = 1; | |
355 } | |
77 | 356 break; |
357 } | |
358 } | |
81 | 359 if(eflag) { |
360 rdman_redraw_area(rdman, ex1, ey1, (ex2 - ex1), (ey2 - ey1)); | |
361 eflag = 0; | |
362 } | |
693
8b7964869f7a
Update window with XImage through XSHM
Thinker K.F. Li <thinker@branda.to>
parents:
692
diff
changeset
|
363 #ifdef XSHM |
8b7964869f7a
Update window with XImage through XSHM
Thinker K.F. Li <thinker@branda.to>
parents:
692
diff
changeset
|
364 XSHM_update(rt); |
8b7964869f7a
Update window with XImage through XSHM
Thinker K.F. Li <thinker@branda.to>
parents:
692
diff
changeset
|
365 #endif |
77 | 366 XFlush(display); |
367 } | |
368 | |
369 /*! \brief Handle connection coming data and timeout of timers. | |
78 | 370 * |
371 * \param display is a Display returned by XOpenDisplay(). | |
372 * \param rdman is a redraw manager. | |
373 * \param tman is a timer manager. | |
374 * | |
375 * The display is managed by specified rdman and tman. rdman draws | |
376 * on the display, and tman trigger actions according timers. | |
77 | 377 */ |
462
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
378 void X_MB_handle_connection(void *be) { |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
379 X_MB_runtime_t *rt = (X_MB_runtime_t *) be; |
83 | 380 Display *display = rt->display; |
381 redraw_man_t *rdman = rt->rdman; | |
382 mb_tman_t *tman = rt->tman; | |
77 | 383 int fd; |
384 mb_timeval_t now, tmo; | |
385 struct timeval tv; | |
462
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
386 fd_set rfds,wfds; |
77 | 387 int nfds; |
462
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
388 int r, r1,i; |
77 | 389 |
142
3efe77007127
Do not redraw all at begining, waiting for explosure.
Thinker K.F. Li <thinker@branda.to>
parents:
131
diff
changeset
|
390 handle_x_event(rt); |
78 | 391 |
77 | 392 fd = XConnectionNumber(display); |
393 nfds = fd + 1; | |
394 while(1) { | |
395 FD_ZERO(&rfds); | |
462
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
396 FD_ZERO(&wfds); |
77 | 397 FD_SET(fd, &rfds); |
462
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
398 for(i=0;i<rt->n_monitor;i++) { |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
399 if (rt->monitors[i].type == MONITOR_READ) |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
400 FD_SET(rt->monitors[i].fd, &rfds); |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
401 else if (rt->monitors[i].type == MONITOR_WRITE) |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
402 FD_SET(rt->monitors[i].fd, &wfds); |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
403 } |
77 | 404 |
405 get_now(&now); | |
406 r = mb_tman_next_timeout(tman, &now, &tmo); | |
407 | |
408 if(r == 0) { | |
409 tv.tv_sec = MB_TIMEVAL_SEC(&tmo); | |
410 tv.tv_usec = MB_TIMEVAL_USEC(&tmo); | |
120 | 411 r1 = select(nfds, &rfds, NULL, NULL, &tv); |
77 | 412 } else |
120 | 413 r1 = select(nfds, &rfds, NULL, NULL, NULL); |
77 | 414 |
120 | 415 if(r1 == -1) { |
77 | 416 perror("select"); |
417 break; | |
418 } | |
419 | |
120 | 420 if(r1 == 0) { |
77 | 421 get_now(&now); |
422 mb_tman_handle_timeout(tman, &now); | |
423 rdman_redraw_changed(rdman); | |
693
8b7964869f7a
Update window with XImage through XSHM
Thinker K.F. Li <thinker@branda.to>
parents:
692
diff
changeset
|
424 #ifdef XSHM |
8b7964869f7a
Update window with XImage through XSHM
Thinker K.F. Li <thinker@branda.to>
parents:
692
diff
changeset
|
425 XSHM_update(rt); |
8b7964869f7a
Update window with XImage through XSHM
Thinker K.F. Li <thinker@branda.to>
parents:
692
diff
changeset
|
426 #endif |
77 | 427 XFlush(display); |
428 } else if(FD_ISSET(fd, &rfds)){ | |
83 | 429 handle_x_event(rt); |
462
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
430 } else { |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
431 for(i=0;i<rt->n_monitor;i++) { |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
432 if (rt->monitors[i].type == MONITOR_READ) |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
433 if (FD_ISSET(rt->monitors[i].fd, &rfds)) |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
434 rt->monitors[i].f(rt->monitors[i].fd,rt->monitors[i].arg); |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
435 else if (rt->monitors[i].type == MONITOR_WRITE) |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
436 if (FD_ISSET(rt->monitors[i].fd, &wfds)) |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
437 rt->monitors[i].f(rt->monitors[i].fd,rt->monitors[i].arg); |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
438 } |
77 | 439 } |
440 } | |
441 } | |
78 | 442 |
443 #define ERR -1 | |
444 #define OK 0 | |
445 | |
446 static int X_init_connection(const char *display_name, | |
447 int w, int h, | |
448 Display **displayp, | |
449 Visual **visualp, | |
450 Window *winp) { | |
451 Display *display; | |
452 Window root, win; | |
453 Visual *visual; | |
454 int screen; | |
455 XSetWindowAttributes wattr; | |
456 int depth; | |
457 int x, y; | |
458 int r; | |
459 | |
460 display = XOpenDisplay(display_name); | |
461 if(display == NULL) | |
462 return ERR; | |
463 | |
464 screen = DefaultScreen(display); | |
465 root = DefaultRootWindow(display); | |
466 visual = DefaultVisual(display, screen); | |
467 depth = DefaultDepth(display, screen); | |
468 wattr.override_redirect = False; | |
469 x = 10; | |
470 y = 10; | |
471 win = XCreateWindow(display, root, | |
472 x, y, | |
473 w, h, | |
474 1, depth, InputOutput, visual, | |
475 CWOverrideRedirect, &wattr); | |
476 r = XMapWindow(display, win); | |
477 if(r == -1) { | |
478 XCloseDisplay(display); | |
479 return ERR; | |
480 } | |
481 | |
84
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
482 XSelectInput(display, win, PointerMotionMask | ExposureMask | |
122
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
483 ButtonPressMask | ButtonReleaseMask | |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
484 KeyPressMask | KeyReleaseMask); |
78 | 485 XFlush(display); |
486 | |
487 *displayp = display; | |
488 *visualp = visual; | |
489 *winp = win; | |
490 | |
491 return OK; | |
492 } | |
493 | |
691
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
494 #ifdef XSHM |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
495 static void |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
496 xshm_destroy(X_MB_runtime_t *xmb_rt) { |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
497 XShmSegmentInfo *shminfo; |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
498 |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
499 shminfo = &xmb_rt->shminfo; |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
500 |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
501 if(xmb_rt->shminfo.shmaddr) { |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
502 XShmDetach(xmb_rt->display, shminfo); |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
503 } |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
504 |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
505 if(xmb_rt->ximage) { |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
506 XDestroyImage(xmb_rt->ximage); |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
507 xmb_rt->ximage = NULL; |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
508 } |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
509 |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
510 if(shminfo->shmaddr) { |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
511 shmdt(shminfo->shmaddr); |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
512 shminfo->shmaddr = NULL; |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
513 } |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
514 |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
515 if(shminfo->shmid) { |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
516 shmctl(shminfo->shmid, IPC_RMID, 0); |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
517 shminfo->shmid = 0; |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
518 } |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
519 } |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
520 |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
521 static void |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
522 xshm_init(X_MB_runtime_t *xmb_rt) { |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
523 Display *display; |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
524 Visual *visual; |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
525 XImage *ximage; |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
526 int screen; |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
527 int depth; |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
528 int support_shm; |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
529 int mem_sz; |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
530 XShmSegmentInfo *shminfo; |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
531 int surf_fmt; |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
532 |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
533 display = xmb_rt->display; |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
534 visual = xmb_rt->visual; |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
535 shminfo = &xmb_rt->shminfo; |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
536 |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
537 support_shm = XShmQueryExtension(display); |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
538 if(!support_shm) |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
539 return; |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
540 |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
541 screen = DefaultScreen(display); |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
542 depth = DefaultDepth(display, screen); |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
543 |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
544 if(depth != 24 && depth != 32) |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
545 return; |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
546 |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
547 xmb_rt->ximage = XShmCreateImage(display, visual, depth, |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
548 ZPixmap, NULL, shminfo, |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
549 xmb_rt->w, xmb_rt->h); |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
550 ximage = xmb_rt->ximage; |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
551 |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
552 mem_sz = ximage->bytes_per_line * ximage->height; |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
553 shminfo->shmid = shmget(IPC_PRIVATE, mem_sz, IPC_CREAT | 0777); |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
554 if(shminfo->shmid == -1) { |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
555 xshm_destroy(xmb_rt); |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
556 return; |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
557 } |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
558 |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
559 shminfo->shmaddr = shmat(shminfo->shmid, 0, 0); |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
560 ximage->data = shminfo->shmaddr; |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
561 |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
562 shminfo->readOnly = 0; |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
563 |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
564 XShmAttach(display, shminfo); |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
565 |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
566 switch(depth) { |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
567 case 24: surf_fmt = CAIRO_FORMAT_RGB24; break; |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
568 case 32: surf_fmt = CAIRO_FORMAT_ARGB32; break; |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
569 } |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
570 |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
571 xmb_rt->backend_surface = |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
572 cairo_image_surface_create_for_data(ximage->data, |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
573 surf_fmt, |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
574 xmb_rt->w, |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
575 xmb_rt->h, |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
576 ximage->bytes_per_line); |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
577 if(xmb_rt->backend_surface == NULL) |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
578 xshm_destroy(xmb_rt); |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
579 } |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
580 #endif /* XSHM */ |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
581 |
78 | 582 /*! \brief Initialize a MadButterfy runtime for Xlib. |
583 * | |
584 * It setups a runtime environment to run MadButterfly with Xlib. | |
585 * Users should specify width and height of the opening window. | |
586 */ | |
122
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
587 static int X_MB_init(const char *display_name, |
78 | 588 int w, int h, X_MB_runtime_t *xmb_rt) { |
265
b42ee279669e
Change function name and add comments.
Thinker K.F. Li <thinker@branda.to>
parents:
260
diff
changeset
|
589 mb_img_ldr_t *img_ldr; |
691
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
590 int r; |
265
b42ee279669e
Change function name and add comments.
Thinker K.F. Li <thinker@branda.to>
parents:
260
diff
changeset
|
591 |
78 | 592 memset(xmb_rt, 0, sizeof(X_MB_runtime_t)); |
593 | |
594 xmb_rt->w = w; | |
595 xmb_rt->h = h; | |
691
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
596 r = X_init_connection(display_name, w, h, &xmb_rt->display, |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
597 &xmb_rt->visual, &xmb_rt->win); |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
598 if(r != OK) |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
599 return ERR; |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
600 |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
601 #ifdef XSHM |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
602 xshm_init(xmb_rt); |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
603 #endif |
78 | 604 |
605 xmb_rt->surface = | |
450
a417fd980228
Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
606 mbe_image_surface_create(MB_IFMT_ARGB32, w, h); |
471
e98ae1407ca2
Remove mbe_set_source_surface() from graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
462
diff
changeset
|
607 |
e98ae1407ca2
Remove mbe_set_source_surface() from graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
462
diff
changeset
|
608 xmb_rt->surface_ptn = |
e98ae1407ca2
Remove mbe_set_source_surface() from graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
462
diff
changeset
|
609 mbe_pattern_create_for_surface(xmb_rt->surface); |
78 | 610 |
693
8b7964869f7a
Update window with XImage through XSHM
Thinker K.F. Li <thinker@branda.to>
parents:
692
diff
changeset
|
611 if(xmb_rt->backend_surface == NULL) /* xshm_init() may create one */ |
691
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
612 xmb_rt->backend_surface = |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
613 mbe_xlib_surface_create(xmb_rt->display, |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
614 xmb_rt->win, |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
615 xmb_rt->visual, |
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
616 w, h); |
78 | 617 |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
350
diff
changeset
|
618 xmb_rt->cr = mbe_create(xmb_rt->surface); |
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
350
diff
changeset
|
619 xmb_rt->backend_cr = mbe_create(xmb_rt->backend_surface); |
78 | 620 |
471
e98ae1407ca2
Remove mbe_set_source_surface() from graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
462
diff
changeset
|
621 mbe_set_source(xmb_rt->backend_cr, xmb_rt->surface_ptn); |
78 | 622 |
623 xmb_rt->rdman = (redraw_man_t *)malloc(sizeof(redraw_man_t)); | |
624 redraw_man_init(xmb_rt->rdman, xmb_rt->cr, xmb_rt->backend_cr); | |
249
ab8284c8dcee
* Add loopback reference from rdman to the backend. This is only required when we need to acquire the tman for the animation. This is not a reasonable arrangement since the animation should be backend transparent. We should not touch the backend directly from the animation. We should relocate the tman to the rdman.
wycc
parents:
224
diff
changeset
|
625 // FIXME: This is a wired loopback reference. This is inly required when we need |
ab8284c8dcee
* Add loopback reference from rdman to the backend. This is only required when we need to acquire the tman for the animation. This is not a reasonable arrangement since the animation should be backend transparent. We should not touch the backend directly from the animation. We should relocate the tman to the rdman.
wycc
parents:
224
diff
changeset
|
626 // to get the xmb_rt->tman for the animation. We should relocate the tman |
ab8284c8dcee
* Add loopback reference from rdman to the backend. This is only required when we need to acquire the tman for the animation. This is not a reasonable arrangement since the animation should be backend transparent. We should not touch the backend directly from the animation. We should relocate the tman to the rdman.
wycc
parents:
224
diff
changeset
|
627 // to the redraw_man_t instead. |
ab8284c8dcee
* Add loopback reference from rdman to the backend. This is only required when we need to acquire the tman for the animation. This is not a reasonable arrangement since the animation should be backend transparent. We should not touch the backend directly from the animation. We should relocate the tman to the rdman.
wycc
parents:
224
diff
changeset
|
628 xmb_rt->rdman->rt = xmb_rt; |
270
cd6af7da32c9
Fix the problem that clean_canvas() can not clean canvas cleanly.
Thinker K.F. Li <thinker@branda.to>
parents:
265
diff
changeset
|
629 xmb_rt->rdman->w = w; |
cd6af7da32c9
Fix the problem that clean_canvas() can not clean canvas cleanly.
Thinker K.F. Li <thinker@branda.to>
parents:
265
diff
changeset
|
630 xmb_rt->rdman->h = h; |
78 | 631 |
632 xmb_rt->tman = mb_tman_new(); | |
633 | |
346
b391722bf20e
sh_image_t::img_data is managed by paint_image_t.
Thinker K.F. Li <thinker@branda.to>
parents:
270
diff
changeset
|
634 img_ldr = simple_mb_img_ldr_new(""); |
265
b42ee279669e
Change function name and add comments.
Thinker K.F. Li <thinker@branda.to>
parents:
260
diff
changeset
|
635 xmb_rt->img_ldr = img_ldr; |
b42ee279669e
Change function name and add comments.
Thinker K.F. Li <thinker@branda.to>
parents:
260
diff
changeset
|
636 rdman_set_img_ldr(xmb_rt->rdman, img_ldr); |
462
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
637 memset(xmb_rt->monitors,0,sizeof(xmb_rt->monitors)); |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
259
diff
changeset
|
638 |
224
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
639 #ifndef ONLY_MOUSE_MOVE_RAW |
83 | 640 xmb_rt->last = NULL; |
224
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
641 #endif |
83 | 642 |
122
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
643 X_kb_init(&xmb_rt->kbinfo, xmb_rt->display, xmb_rt->rdman); |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
644 |
78 | 645 return OK; |
646 } | |
647 | |
122
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
648 static void X_MB_destroy(X_MB_runtime_t *xmb_rt) { |
78 | 649 if(xmb_rt->rdman) { |
650 redraw_man_destroy(xmb_rt->rdman); | |
651 free(xmb_rt->rdman); | |
652 } | |
653 | |
654 if(xmb_rt->tman) | |
655 mb_tman_free(xmb_rt->tman); | |
656 | |
259
e8a784a306d0
Initialize an image loader for X runtime
Thinker K.F. Li <thinker@branda.to>
parents:
249
diff
changeset
|
657 if(xmb_rt->img_ldr) |
e8a784a306d0
Initialize an image loader for X runtime
Thinker K.F. Li <thinker@branda.to>
parents:
249
diff
changeset
|
658 MB_IMG_LDR_FREE(xmb_rt->img_ldr); |
e8a784a306d0
Initialize an image loader for X runtime
Thinker K.F. Li <thinker@branda.to>
parents:
249
diff
changeset
|
659 |
78 | 660 if(xmb_rt->cr) |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
350
diff
changeset
|
661 mbe_destroy(xmb_rt->cr); |
78 | 662 if(xmb_rt->backend_cr) |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
350
diff
changeset
|
663 mbe_destroy(xmb_rt->backend_cr); |
78 | 664 |
665 if(xmb_rt->surface) | |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
350
diff
changeset
|
666 mbe_surface_destroy(xmb_rt->surface); |
471
e98ae1407ca2
Remove mbe_set_source_surface() from graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
462
diff
changeset
|
667 if(xmb_rt->surface_ptn) |
e98ae1407ca2
Remove mbe_set_source_surface() from graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
462
diff
changeset
|
668 mbe_pattern_destroy(xmb_rt->surface_ptn); |
78 | 669 if(xmb_rt->backend_surface) |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
350
diff
changeset
|
670 mbe_surface_destroy(xmb_rt->backend_surface); |
78 | 671 |
672 if(xmb_rt->display) | |
673 XCloseDisplay(xmb_rt->display); | |
122
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
674 |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
675 X_kb_destroy(&xmb_rt->kbinfo); |
78 | 676 } |
677 | |
462
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
678 void *X_MB_new(const char *display_name, int w, int h) { |
122
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
679 X_MB_runtime_t *rt; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
680 int r; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
681 |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
682 rt = O_ALLOC(X_MB_runtime_t); |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
683 if(rt == NULL) |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
684 return NULL; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
685 |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
686 r = X_MB_init(display_name, w, h, rt); |
528
d687d3395264
Clear variables and draw root coord.
Thinker K.F. Li <thinker@branda.to>
parents:
471
diff
changeset
|
687 if(r != OK) { |
d687d3395264
Clear variables and draw root coord.
Thinker K.F. Li <thinker@branda.to>
parents:
471
diff
changeset
|
688 free(rt); |
122
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
689 return NULL; |
528
d687d3395264
Clear variables and draw root coord.
Thinker K.F. Li <thinker@branda.to>
parents:
471
diff
changeset
|
690 } |
122
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
691 |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
692 return rt; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
693 } |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
694 |
462
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
695 void X_MB_free(void *rt) { |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
696 X_MB_destroy((X_MB_runtime_t *) rt); |
122
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
697 free(rt); |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
698 } |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
699 |
462
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
700 subject_t *X_MB_kbevents(void *rt) { |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
701 X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *) rt; |
122
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
702 return xmb_rt->kbinfo.kbevents; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
703 } |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
704 |
462
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
705 redraw_man_t *X_MB_rdman(void *rt) { |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
706 X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *) rt; |
122
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
707 return xmb_rt->rdman; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
708 } |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
709 |
462
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
710 mb_tman_t *X_MB_tman(void *rt) { |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
711 X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *) rt; |
122
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
712 return xmb_rt->tman; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
713 } |
131
6a8588df68af
Tank can change direction and navigate on the mud area
Thinker K.F. Li <thinker@branda.to>
parents:
122
diff
changeset
|
714 |
462
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
715 ob_factory_t *X_MB_ob_factory(void *rt) { |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
716 X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *) rt; |
131
6a8588df68af
Tank can change direction and navigate on the mud area
Thinker K.F. Li <thinker@branda.to>
parents:
122
diff
changeset
|
717 ob_factory_t *factory; |
6a8588df68af
Tank can change direction and navigate on the mud area
Thinker K.F. Li <thinker@branda.to>
parents:
122
diff
changeset
|
718 |
6a8588df68af
Tank can change direction and navigate on the mud area
Thinker K.F. Li <thinker@branda.to>
parents:
122
diff
changeset
|
719 factory = rdman_get_ob_factory(xmb_rt->rdman); |
6a8588df68af
Tank can change direction and navigate on the mud area
Thinker K.F. Li <thinker@branda.to>
parents:
122
diff
changeset
|
720 return factory; |
6a8588df68af
Tank can change direction and navigate on the mud area
Thinker K.F. Li <thinker@branda.to>
parents:
122
diff
changeset
|
721 } |
259
e8a784a306d0
Initialize an image loader for X runtime
Thinker K.F. Li <thinker@branda.to>
parents:
249
diff
changeset
|
722 |
462
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
723 mb_img_ldr_t *X_MB_img_ldr(void *rt) { |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
724 X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *) rt; |
692
201cc86720a3
Fix compiling time warning about cairo xlib
Thinker K.F. Li <thinker@branda.to>
parents:
691
diff
changeset
|
725 mb_img_ldr_t *img_ldr; |
259
e8a784a306d0
Initialize an image loader for X runtime
Thinker K.F. Li <thinker@branda.to>
parents:
249
diff
changeset
|
726 |
e8a784a306d0
Initialize an image loader for X runtime
Thinker K.F. Li <thinker@branda.to>
parents:
249
diff
changeset
|
727 img_ldr = xmb_rt->img_ldr; |
e8a784a306d0
Initialize an image loader for X runtime
Thinker K.F. Li <thinker@branda.to>
parents:
249
diff
changeset
|
728 |
e8a784a306d0
Initialize an image loader for X runtime
Thinker K.F. Li <thinker@branda.to>
parents:
249
diff
changeset
|
729 return img_ldr; |
e8a784a306d0
Initialize an image loader for X runtime
Thinker K.F. Li <thinker@branda.to>
parents:
249
diff
changeset
|
730 } |
462
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
731 |
545
49f8f57f184a
Preparing for nodejs plugin
Thinker K.F. Li <thinker@branda.to>
parents:
529
diff
changeset
|
732 void X_MB_add_event(void *rt, int type, int fd, mb_eventcb_t f,void *arg) |
462
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
733 { |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
734 X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *) rt; |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
735 int i; |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
736 |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
737 for(i=0;i<xmb_rt->n_monitor;i++) { |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
738 if (xmb_rt->monitors[i].type == type && xmb_rt->monitors[i].fd == fd) { |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
739 xmb_rt->monitors[i].f = f; |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
740 xmb_rt->monitors[i].arg = arg; |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
741 return; |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
742 } |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
743 } |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
744 for(i=0;i<xmb_rt->n_monitor;i++) { |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
745 if (xmb_rt->monitors[i].type == 0) { |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
746 xmb_rt->monitors[i].type = type; |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
747 xmb_rt->monitors[i].fd = fd; |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
748 xmb_rt->monitors[i].f = f; |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
749 xmb_rt->monitors[i].arg = arg; |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
750 return; |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
751 } |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
752 } |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
753 if (i == MAX_MONITORS) return; |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
754 xmb_rt->monitors[i].type = type; |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
755 xmb_rt->monitors[i].fd = fd; |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
756 xmb_rt->monitors[i].f = f; |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
757 xmb_rt->monitors[i].arg = arg; |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
758 i++; |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
759 xmb_rt->n_monitor=i; |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
760 } |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
761 |
545
49f8f57f184a
Preparing for nodejs plugin
Thinker K.F. Li <thinker@branda.to>
parents:
529
diff
changeset
|
762 void X_MB_remove_event(void *rt, int type, int fd) |
462
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
763 { |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
764 X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *) rt; |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
765 int i; |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
766 for(i=0;i<xmb_rt->n_monitor;i++) { |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
767 if (xmb_rt->monitors[i].type == type && xmb_rt->monitors[i].fd == fd) { |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
768 xmb_rt->monitors[i].type = 0; |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
769 return; |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
770 } |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
771 } |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
772 } |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
773 mb_backend_t backend = { X_MB_new, |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
774 X_MB_free, |
545
49f8f57f184a
Preparing for nodejs plugin
Thinker K.F. Li <thinker@branda.to>
parents:
529
diff
changeset
|
775 X_MB_add_event, |
49f8f57f184a
Preparing for nodejs plugin
Thinker K.F. Li <thinker@branda.to>
parents:
529
diff
changeset
|
776 X_MB_remove_event, |
462
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
777 X_MB_handle_connection, |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
778 X_MB_kbevents, |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
779 X_MB_rdman, |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
780 X_MB_tman, |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
781 X_MB_ob_factory, |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
782 X_MB_img_ldr |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
451
diff
changeset
|
783 }; |
545
49f8f57f184a
Preparing for nodejs plugin
Thinker K.F. Li <thinker@branda.to>
parents:
529
diff
changeset
|
784 /*! \defgroup x_supp_nodejs_sup Export functions for supporting nodejs plugin. |
49f8f57f184a
Preparing for nodejs plugin
Thinker K.F. Li <thinker@branda.to>
parents:
529
diff
changeset
|
785 * |
49f8f57f184a
Preparing for nodejs plugin
Thinker K.F. Li <thinker@branda.to>
parents:
529
diff
changeset
|
786 * These functions are for internal using. |
49f8f57f184a
Preparing for nodejs plugin
Thinker K.F. Li <thinker@branda.to>
parents:
529
diff
changeset
|
787 * @{ |
49f8f57f184a
Preparing for nodejs plugin
Thinker K.F. Li <thinker@branda.to>
parents:
529
diff
changeset
|
788 */ |
49f8f57f184a
Preparing for nodejs plugin
Thinker K.F. Li <thinker@branda.to>
parents:
529
diff
changeset
|
789 /*! \brief Exported for nodejs plugin to call handle_x_event. |
49f8f57f184a
Preparing for nodejs plugin
Thinker K.F. Li <thinker@branda.to>
parents:
529
diff
changeset
|
790 */ |
550
127499ab2412
Upgrade ndoejs plugin to level of a new runtime.
Thinker K.F. Li <thinker@branda.to>
parents:
545
diff
changeset
|
791 void _X_MB_handle_x_event_for_nodejs(void *rt) { |
127499ab2412
Upgrade ndoejs plugin to level of a new runtime.
Thinker K.F. Li <thinker@branda.to>
parents:
545
diff
changeset
|
792 handle_x_event((X_MB_runtime_t *)rt); |
545
49f8f57f184a
Preparing for nodejs plugin
Thinker K.F. Li <thinker@branda.to>
parents:
529
diff
changeset
|
793 } |
49f8f57f184a
Preparing for nodejs plugin
Thinker K.F. Li <thinker@branda.to>
parents:
529
diff
changeset
|
794 |
49f8f57f184a
Preparing for nodejs plugin
Thinker K.F. Li <thinker@branda.to>
parents:
529
diff
changeset
|
795 /*! \brief Get X connect for nodejs plugin. |
49f8f57f184a
Preparing for nodejs plugin
Thinker K.F. Li <thinker@branda.to>
parents:
529
diff
changeset
|
796 */ |
550
127499ab2412
Upgrade ndoejs plugin to level of a new runtime.
Thinker K.F. Li <thinker@branda.to>
parents:
545
diff
changeset
|
797 int _X_MB_get_x_conn_for_nodejs(void *rt) { |
127499ab2412
Upgrade ndoejs plugin to level of a new runtime.
Thinker K.F. Li <thinker@branda.to>
parents:
545
diff
changeset
|
798 return XConnectionNumber(((X_MB_runtime_t *)rt)->display); |
545
49f8f57f184a
Preparing for nodejs plugin
Thinker K.F. Li <thinker@branda.to>
parents:
529
diff
changeset
|
799 } |
49f8f57f184a
Preparing for nodejs plugin
Thinker K.F. Li <thinker@branda.to>
parents:
529
diff
changeset
|
800 |
49f8f57f184a
Preparing for nodejs plugin
Thinker K.F. Li <thinker@branda.to>
parents:
529
diff
changeset
|
801 /*! \brief Flush buffer for the X connection of a runtime object. |
49f8f57f184a
Preparing for nodejs plugin
Thinker K.F. Li <thinker@branda.to>
parents:
529
diff
changeset
|
802 */ |
556
c9d23f7279a4
The first testcase that nodejs code can show a MadButterfly window.
Thinker K.F. Li <thinker@branda.to>
parents:
550
diff
changeset
|
803 int _X_MB_flush_x_conn_for_nodejs(void *rt) { |
693
8b7964869f7a
Update window with XImage through XSHM
Thinker K.F. Li <thinker@branda.to>
parents:
692
diff
changeset
|
804 X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *)rt; |
8b7964869f7a
Update window with XImage through XSHM
Thinker K.F. Li <thinker@branda.to>
parents:
692
diff
changeset
|
805 #ifdef XSHM |
8b7964869f7a
Update window with XImage through XSHM
Thinker K.F. Li <thinker@branda.to>
parents:
692
diff
changeset
|
806 XSHM_update(xmb_rt); |
8b7964869f7a
Update window with XImage through XSHM
Thinker K.F. Li <thinker@branda.to>
parents:
692
diff
changeset
|
807 #endif |
8b7964869f7a
Update window with XImage through XSHM
Thinker K.F. Li <thinker@branda.to>
parents:
692
diff
changeset
|
808 return XFlush(xmb_rt->display); |
545
49f8f57f184a
Preparing for nodejs plugin
Thinker K.F. Li <thinker@branda.to>
parents:
529
diff
changeset
|
809 } |
49f8f57f184a
Preparing for nodejs plugin
Thinker K.F. Li <thinker@branda.to>
parents:
529
diff
changeset
|
810 |
49f8f57f184a
Preparing for nodejs plugin
Thinker K.F. Li <thinker@branda.to>
parents:
529
diff
changeset
|
811 /* @} */ |