Mercurial > MadButterfly
annotate src/dfb_supp.c @ 904:f838e5207ec4
Remove XSHM support from DirectFB backend.
author | Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com> |
---|---|
date | Sun, 03 Oct 2010 17:00:31 +0800 |
parents | 4c7f0ec97ad9 |
children | e3a5e05f00c1 |
rev | line source |
---|---|
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
757
diff
changeset
|
1 // -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- |
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
757
diff
changeset
|
2 // vim: sw=4:ts=8:sts=4 |
77 | 3 #include <stdio.h> |
78 | 4 #include <stdlib.h> |
5 #include <string.h> | |
904
f838e5207ec4
Remove XSHM support from DirectFB backend.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
903
diff
changeset
|
6 #include <cairo-directfb.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" |
694
7e64e0f70cb6
Switch XSHM with autoconf
Thinker K.F. Li <thinker@branda.to>
parents:
693
diff
changeset
|
11 #include "config.h" |
691
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
12 |
122
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
13 #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
|
14 #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
|
15 |
224
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
16 #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
|
17 |
122
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
18 /*! \ingroup xkb |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
19 * @{ |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
20 */ |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
21 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
|
22 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
|
23 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
|
24 KeySym *syms; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
25 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
|
26 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
|
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 /* @} */ |
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
|
30 #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
|
31 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
|
32 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
|
33 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
|
34 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
|
35 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
|
36 } monitor_t; |
869
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
37 |
122
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
38 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
|
39 Display *display; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
40 Window win; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
41 Visual *visual; |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
350
diff
changeset
|
42 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
|
43 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
|
44 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
|
45 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
|
46 mb_tman_t *tman; |
259
e8a784a306d0
Initialize an image loader for X runtime
Thinker K.F. Li <thinker@branda.to>
parents:
249
diff
changeset
|
47 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
|
48 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
|
49 |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
50 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
|
51 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
|
52 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
|
53 |
224
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
54 #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
|
55 /* States */ |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
56 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
|
57 #endif |
691
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
58 |
869
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
59 /* |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
60 * Following variables are used by handle_single_x_event() |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
61 */ |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
62 int last_evt_type; /* Type of last event */ |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
63 int eflag; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
64 int ex1, ey1, ex2, ey2; /* Aggregate expose events */ |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
65 int mflag; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
66 int mx, my; /* Position of last motion event */ |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
67 int mbut_state; /* Button state of last motion event */ |
122
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
68 }; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
69 |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
70 /*! \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
|
71 * |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
72 * 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
|
73 * 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
|
74 * 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
|
75 * @{ |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
76 */ |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
77 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
|
78 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
|
79 int sym; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
80 |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
81 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
|
82 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
|
83 return sym; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
84 } |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
85 |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
86 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
|
87 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
|
88 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
|
89 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
|
90 int r; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
91 |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
92 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
|
93 &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
|
94 &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
|
95 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
|
96 return ERR; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
97 |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
98 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
|
99 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
|
100 n_syms, |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
101 &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
|
102 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
|
103 return ERR; |
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 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
|
106 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
|
107 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
|
108 return ERR; |
192
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
109 /*! \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
|
110 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
|
111 |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
112 return OK; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
113 } |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
114 |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
115 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
|
116 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
|
117 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
|
118 } |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
119 |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
120 /*! \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
|
121 */ |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
122 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
|
123 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
|
124 int sym; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
125 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
|
126 |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
127 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
|
128 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
|
129 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
|
130 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
|
131 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
|
132 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
|
133 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
|
134 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
|
135 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
|
136 |
192
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
137 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
|
138 } |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
139 |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
140 /* @} */ |
77 | 141 |
78 | 142 static unsigned int get_button_state(unsigned int state) { |
143 unsigned int but = 0; | |
144 | |
145 if(state & Button1Mask) | |
146 but |= MOUSE_BUT1; | |
147 if(state & Button2Mask) | |
148 but |= MOUSE_BUT2; | |
149 if(state & Button3Mask) | |
150 but |= MOUSE_BUT3; | |
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
757
diff
changeset
|
151 |
78 | 152 return but; |
153 } | |
154 | |
155 static unsigned int get_button(unsigned int button) { | |
156 switch(button) { | |
157 case Button1: | |
158 return MOUSE_BUT1; | |
159 case Button2: | |
160 return MOUSE_BUT2; | |
161 case Button3: | |
162 return MOUSE_BUT3; | |
163 } | |
164 return 0; | |
165 } | |
166 | |
167 /*! \brief Notify observers of the shape at specified | |
168 * position for mouse event. | |
169 * | |
170 * Observers of parent shapes may be called if the subject is not | |
171 * with SUBF_STOP_PROPAGATE flag. The subject of mouse event | |
172 * for a shape is returned by sh_get_mouse_event_subject(). | |
173 */ | |
224
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
174 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
|
175 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
|
176 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
|
177 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
|
178 unsigned int button) { |
78 | 179 mouse_event_t mouse_event; |
180 subject_t *subject; | |
181 | |
182 mouse_event.event.type = etype; | |
183 mouse_event.x = x; | |
184 mouse_event.y = y; | |
185 mouse_event.but_state = state; | |
186 mouse_event.button = button; | |
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
757
diff
changeset
|
187 |
224
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
188 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
|
189 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
|
190 else |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
191 subject = coord_get_mouse_event((coord_t *)obj); |
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
757
diff
changeset
|
192 |
192
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
193 subject_notify(subject, (event_t *)&mouse_event); |
78 | 194 } |
195 | |
869
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
196 /*! \brief Handle motion event. |
77 | 197 */ |
869
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
198 static void |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
199 handle_motion_event(X_MB_runtime_t *rt) { |
83 | 200 redraw_man_t *rdman = rt->rdman; |
869
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
201 int x, y; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
202 int state; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
203 shape_t *shape; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
204 coord_t *root; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
205 int in_stroke; |
904
f838e5207ec4
Remove XSHM support from DirectFB backend.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
903
diff
changeset
|
206 |
869
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
207 x = rt->mx; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
208 y = rt->my; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
209 state = rt->mbut_state; |
904
f838e5207ec4
Remove XSHM support from DirectFB backend.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
903
diff
changeset
|
210 |
869
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
211 shape = find_shape_at_pos(rdman, x, y, |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
212 &in_stroke); |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
213 #ifdef ONLY_MOUSE_MOVE_RAW |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
214 if(shape != NULL) { |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
215 notify_coord_or_shape(rdman, (mb_obj_t *)shape, |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
216 x, y, EVT_MOUSE_MOVE_RAW, state, 0); |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
217 } else { |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
218 root = rdman_get_root(rdman); |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
219 notify_coord_or_shape(rdman, (mb_obj_t *)root, |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
220 x, y, EVT_MOUSE_MOVE_RAW, state, 0); |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
221 } |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
222 #else |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
223 if(shape != NULL) { |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
224 if(rt->last != shape) { |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
225 if(rt->last) |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
226 notify_coord_or_shape(rdman, rt->last, x, y, |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
227 EVT_MOUSE_OUT, state, 0); |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
228 notify_coord_or_shape(rdman, shape, x, y, |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
229 EVT_MOUSE_OVER, state, 0); |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
230 rt->last = shape; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
231 } else |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
232 notify_coord_or_shape(rdman, shape, x, y, |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
233 EVT_MOUSE_MOVE, state, 0); |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
234 } else { |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
235 if(rt->last) { |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
236 notify_coord_or_shape(rdman, rt->last, x, y, |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
237 EVT_MOUSE_OUT, state, 0); |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
238 rt->last = NULL; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
239 } |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
240 } |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
241 #endif |
904
f838e5207ec4
Remove XSHM support from DirectFB backend.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
903
diff
changeset
|
242 |
869
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
243 rt->mflag = 0; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
244 } |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
245 |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
246 /*! \brief Redraw exposed area. |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
247 */ |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
248 static void |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
249 handle_expose_event(X_MB_runtime_t *rt) { |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
250 redraw_man_t *rdman = rt->rdman; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
251 int ex1, ey1, ex2, ey2; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
252 |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
253 ex1 = rt->ex1; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
254 ey1 = rt->ey1; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
255 ex2 = rt->ex2; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
256 ey2 = rt->ey2; |
904
f838e5207ec4
Remove XSHM support from DirectFB backend.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
903
diff
changeset
|
257 |
869
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
258 rdman_redraw_area(rdman, ex1, ey1, (ex2 - ex1), (ey2 - ey1)); |
904
f838e5207ec4
Remove XSHM support from DirectFB backend.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
903
diff
changeset
|
259 |
869
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
260 rt->eflag = 0; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
261 } |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
262 |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
263 /*! \brief Handle single X event and maintain internal states. |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
264 * |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
265 * It keeps internal state in rt to improve performance. |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
266 */ |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
267 static void |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
268 handle_single_x_event(X_MB_runtime_t *rt, XEvent *evt) { |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
269 redraw_man_t *rdman = rt->rdman; |
77 | 270 XMotionEvent *mevt; |
78 | 271 XButtonEvent *bevt; |
81 | 272 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
|
273 XKeyEvent *xkey; |
869
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
274 int x, y, w, h; |
81 | 275 |
84
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
276 shape_t *shape; |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
277 |
78 | 278 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
|
279 int in_stroke; |
869
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
280 |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
281 if(evt->type != MotionNotify && rt->mflag) |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
282 handle_motion_event(rt); |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
283 |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
284 switch(evt->type) { |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
285 case ButtonPress: |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
286 bevt = (XButtonEvent *)evt; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
287 x = bevt->x; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
288 y = bevt->y; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
289 state = get_button_state(bevt->state); |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
290 button = get_button(bevt->button); |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
291 |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
292 shape = find_shape_at_pos(rdman, x, y, |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
293 &in_stroke); |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
294 if(shape) |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
295 notify_coord_or_shape(rdman, (mb_obj_t *)shape, |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
296 x, y, EVT_MOUSE_BUT_PRESS, |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
297 state, button); |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
298 break; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
299 |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
300 case ButtonRelease: |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
301 bevt = (XButtonEvent *)evt; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
302 x = bevt->x; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
303 y = bevt->y; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
304 state = get_button_state(bevt->state); |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
305 button = get_button(bevt->button); |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
306 |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
307 shape = find_shape_at_pos(rdman, x, y, |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
308 &in_stroke); |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
309 if(shape) |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
310 notify_coord_or_shape(rdman, (mb_obj_t *)shape, |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
311 x, y, EVT_MOUSE_BUT_RELEASE, |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
312 state, button); |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
313 break; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
314 |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
315 case MotionNotify: |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
316 mevt = (XMotionEvent *)evt; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
317 rt->mx = mevt->x; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
318 rt->my = mevt->y; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
319 rt->mbut_state = get_button_state(mevt->state); |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
320 rt->mflag = 1; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
321 break; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
322 |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
323 case KeyPress: |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
324 case KeyRelease: |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
325 xkey = &evt->xkey; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
326 X_kb_handle_event(&rt->kbinfo, xkey); |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
327 break; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
328 |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
329 case Expose: |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
330 eevt = &evt->xexpose; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
331 x = eevt->x; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
332 y = eevt->y; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
333 w = eevt->width; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
334 h = eevt->height; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
335 |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
336 if(rt->eflag) { |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
337 if(x < rt->ex1) |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
338 rt->ex1 = x; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
339 if(y < rt->ey1) |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
340 rt->ey1 = y; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
341 if((x + w) > rt->ex2) |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
342 rt->ex2 = x + w; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
343 if((y + h) > rt->ey2) |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
344 rt->ey2 = y + h; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
345 } else { |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
346 rt->ex1 = x; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
347 rt->ey1 = y; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
348 rt->ex2 = x + w; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
349 rt->ey2 = y + h; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
350 rt->eflag = 1; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
351 } |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
352 break; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
353 } |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
354 } |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
355 |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
356 /*! \brief Call when no more event in an event iteration. |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
357 * |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
358 * No more event means event queue is emplty. This function will |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
359 * perform some actions according current internal state. |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
360 */ |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
361 static void |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
362 no_more_event(X_MB_runtime_t *rt) { |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
363 if(rt->mflag) |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
364 handle_motion_event(rt); |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
365 if(rt->eflag) |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
366 handle_expose_event(rt); |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
367 } |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
368 |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
369 /*! \brief Dispatch all X events in the queue. |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
370 */ |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
371 static void handle_x_event(X_MB_runtime_t *rt) { |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
372 Display *display = rt->display; |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
373 XEvent evt; |
77 | 374 int r; |
375 | |
529 | 376 /* XXX: For some unknown reason, it causes a segmentation fault to |
377 * called XEventsQueued() after receiving first Expose event | |
378 * and before redraw for the event. | |
379 */ | |
77 | 380 while(XEventsQueued(display, QueuedAfterReading) > 0) { |
381 r = XNextEvent(display, &evt); | |
382 if(r == -1) | |
383 break; | |
384 | |
869
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
385 handle_single_x_event(rt, &evt); |
77 | 386 } |
869
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
387 no_more_event(rt); |
904
f838e5207ec4
Remove XSHM support from DirectFB backend.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
903
diff
changeset
|
388 |
77 | 389 XFlush(display); |
390 } | |
391 | |
392 /*! \brief Handle connection coming data and timeout of timers. | |
78 | 393 * |
394 * \param display is a Display returned by XOpenDisplay(). | |
395 * \param rdman is a redraw manager. | |
396 * \param tman is a timer manager. | |
397 * | |
398 * The display is managed by specified rdman and tman. rdman draws | |
399 * on the display, and tman trigger actions according timers. | |
77 | 400 */ |
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
|
401 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
|
402 X_MB_runtime_t *rt = (X_MB_runtime_t *) be; |
83 | 403 Display *display = rt->display; |
404 redraw_man_t *rdman = rt->rdman; | |
405 mb_tman_t *tman = rt->tman; | |
77 | 406 int fd; |
407 mb_timeval_t now, tmo; | |
408 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
|
409 fd_set rfds,wfds; |
77 | 410 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
|
411 int r, r1,i; |
77 | 412 |
142
3efe77007127
Do not redraw all at begining, waiting for explosure.
Thinker K.F. Li <thinker@branda.to>
parents:
131
diff
changeset
|
413 handle_x_event(rt); |
78 | 414 |
77 | 415 fd = XConnectionNumber(display); |
416 nfds = fd + 1; | |
417 while(1) { | |
418 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
|
419 FD_ZERO(&wfds); |
77 | 420 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
|
421 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
|
422 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
|
423 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
|
424 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
|
425 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
|
426 } |
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
757
diff
changeset
|
427 |
77 | 428 get_now(&now); |
429 r = mb_tman_next_timeout(tman, &now, &tmo); | |
430 | |
431 if(r == 0) { | |
432 tv.tv_sec = MB_TIMEVAL_SEC(&tmo); | |
433 tv.tv_usec = MB_TIMEVAL_USEC(&tmo); | |
120 | 434 r1 = select(nfds, &rfds, NULL, NULL, &tv); |
77 | 435 } else |
120 | 436 r1 = select(nfds, &rfds, NULL, NULL, NULL); |
77 | 437 |
120 | 438 if(r1 == -1) { |
77 | 439 perror("select"); |
440 break; | |
441 } | |
442 | |
120 | 443 if(r1 == 0) { |
77 | 444 get_now(&now); |
445 mb_tman_handle_timeout(tman, &now); | |
446 rdman_redraw_changed(rdman); | |
447 XFlush(display); | |
448 } else if(FD_ISSET(fd, &rfds)){ | |
83 | 449 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
|
450 } 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
|
451 for(i=0;i<rt->n_monitor;i++) { |
756
cceac4ba259e
Support drawing at root window for X Window
Thinker K.F. Li <thinker@codemud.net>
parents:
755
diff
changeset
|
452 if (rt->monitors[i].type == MONITOR_READ) { |
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
|
453 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
|
454 rt->monitors[i].f(rt->monitors[i].fd,rt->monitors[i].arg); |
756
cceac4ba259e
Support drawing at root window for X Window
Thinker K.F. Li <thinker@codemud.net>
parents:
755
diff
changeset
|
455 } else if (rt->monitors[i].type == MONITOR_WRITE) { |
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
|
456 if (FD_ISSET(rt->monitors[i].fd, &wfds)) |
756
cceac4ba259e
Support drawing at root window for X Window
Thinker K.F. Li <thinker@codemud.net>
parents:
755
diff
changeset
|
457 rt->monitors[i].f(rt->monitors[i].fd,rt->monitors[i].arg); |
cceac4ba259e
Support drawing at root window for X Window
Thinker K.F. Li <thinker@codemud.net>
parents:
755
diff
changeset
|
458 } |
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
|
459 } |
77 | 460 } |
461 } | |
462 } | |
78 | 463 |
464 #define ERR -1 | |
465 #define OK 0 | |
466 | |
467 static int X_init_connection(const char *display_name, | |
468 int w, int h, | |
469 Display **displayp, | |
470 Visual **visualp, | |
471 Window *winp) { | |
472 Display *display; | |
473 Window root, win; | |
474 Visual *visual; | |
475 int screen; | |
476 XSetWindowAttributes wattr; | |
477 int depth; | |
478 int x, y; | |
756
cceac4ba259e
Support drawing at root window for X Window
Thinker K.F. Li <thinker@codemud.net>
parents:
755
diff
changeset
|
479 int draw_root = 0; |
cceac4ba259e
Support drawing at root window for X Window
Thinker K.F. Li <thinker@codemud.net>
parents:
755
diff
changeset
|
480 const char *disp_name; |
cceac4ba259e
Support drawing at root window for X Window
Thinker K.F. Li <thinker@codemud.net>
parents:
755
diff
changeset
|
481 char disp_buf[32]; |
cceac4ba259e
Support drawing at root window for X Window
Thinker K.F. Li <thinker@codemud.net>
parents:
755
diff
changeset
|
482 int cp; |
78 | 483 int r; |
484 | |
756
cceac4ba259e
Support drawing at root window for X Window
Thinker K.F. Li <thinker@codemud.net>
parents:
755
diff
changeset
|
485 /* |
cceac4ba259e
Support drawing at root window for X Window
Thinker K.F. Li <thinker@codemud.net>
parents:
755
diff
changeset
|
486 * Support drawing on the root window. |
cceac4ba259e
Support drawing at root window for X Window
Thinker K.F. Li <thinker@codemud.net>
parents:
755
diff
changeset
|
487 */ |
cceac4ba259e
Support drawing at root window for X Window
Thinker K.F. Li <thinker@codemud.net>
parents:
755
diff
changeset
|
488 disp_name = display_name; |
cceac4ba259e
Support drawing at root window for X Window
Thinker K.F. Li <thinker@codemud.net>
parents:
755
diff
changeset
|
489 if(strstr(display_name, ":root") != NULL) { |
cceac4ba259e
Support drawing at root window for X Window
Thinker K.F. Li <thinker@codemud.net>
parents:
755
diff
changeset
|
490 draw_root = 1; |
cceac4ba259e
Support drawing at root window for X Window
Thinker K.F. Li <thinker@codemud.net>
parents:
755
diff
changeset
|
491 cp = strlen(display_name) - 5; |
cceac4ba259e
Support drawing at root window for X Window
Thinker K.F. Li <thinker@codemud.net>
parents:
755
diff
changeset
|
492 if(cp >= 32) |
cceac4ba259e
Support drawing at root window for X Window
Thinker K.F. Li <thinker@codemud.net>
parents:
755
diff
changeset
|
493 cp = 31; |
cceac4ba259e
Support drawing at root window for X Window
Thinker K.F. Li <thinker@codemud.net>
parents:
755
diff
changeset
|
494 memcpy(disp_buf, display_name, cp); |
cceac4ba259e
Support drawing at root window for X Window
Thinker K.F. Li <thinker@codemud.net>
parents:
755
diff
changeset
|
495 disp_buf[cp] = 0; |
cceac4ba259e
Support drawing at root window for X Window
Thinker K.F. Li <thinker@codemud.net>
parents:
755
diff
changeset
|
496 disp_name = disp_buf; |
cceac4ba259e
Support drawing at root window for X Window
Thinker K.F. Li <thinker@codemud.net>
parents:
755
diff
changeset
|
497 } |
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
757
diff
changeset
|
498 |
756
cceac4ba259e
Support drawing at root window for X Window
Thinker K.F. Li <thinker@codemud.net>
parents:
755
diff
changeset
|
499 display = XOpenDisplay(disp_name); |
78 | 500 if(display == NULL) |
501 return ERR; | |
502 | |
503 screen = DefaultScreen(display); | |
504 root = DefaultRootWindow(display); | |
505 visual = DefaultVisual(display, screen); | |
506 depth = DefaultDepth(display, screen); | |
507 wattr.override_redirect = False; | |
508 x = 10; | |
509 y = 10; | |
756
cceac4ba259e
Support drawing at root window for X Window
Thinker K.F. Li <thinker@codemud.net>
parents:
755
diff
changeset
|
510 if(draw_root) |
cceac4ba259e
Support drawing at root window for X Window
Thinker K.F. Li <thinker@codemud.net>
parents:
755
diff
changeset
|
511 win = RootWindowOfScreen(ScreenOfDisplay(display, screen)); |
cceac4ba259e
Support drawing at root window for X Window
Thinker K.F. Li <thinker@codemud.net>
parents:
755
diff
changeset
|
512 else { |
cceac4ba259e
Support drawing at root window for X Window
Thinker K.F. Li <thinker@codemud.net>
parents:
755
diff
changeset
|
513 win = XCreateWindow(display, root, |
cceac4ba259e
Support drawing at root window for X Window
Thinker K.F. Li <thinker@codemud.net>
parents:
755
diff
changeset
|
514 x, y, |
cceac4ba259e
Support drawing at root window for X Window
Thinker K.F. Li <thinker@codemud.net>
parents:
755
diff
changeset
|
515 w, h, |
cceac4ba259e
Support drawing at root window for X Window
Thinker K.F. Li <thinker@codemud.net>
parents:
755
diff
changeset
|
516 1, depth, InputOutput, visual, |
cceac4ba259e
Support drawing at root window for X Window
Thinker K.F. Li <thinker@codemud.net>
parents:
755
diff
changeset
|
517 CWOverrideRedirect, &wattr); |
cceac4ba259e
Support drawing at root window for X Window
Thinker K.F. Li <thinker@codemud.net>
parents:
755
diff
changeset
|
518 r = XMapWindow(display, win); |
cceac4ba259e
Support drawing at root window for X Window
Thinker K.F. Li <thinker@codemud.net>
parents:
755
diff
changeset
|
519 if(r == -1) { |
cceac4ba259e
Support drawing at root window for X Window
Thinker K.F. Li <thinker@codemud.net>
parents:
755
diff
changeset
|
520 XCloseDisplay(display); |
cceac4ba259e
Support drawing at root window for X Window
Thinker K.F. Li <thinker@codemud.net>
parents:
755
diff
changeset
|
521 return ERR; |
cceac4ba259e
Support drawing at root window for X Window
Thinker K.F. Li <thinker@codemud.net>
parents:
755
diff
changeset
|
522 } |
78 | 523 } |
524 | |
84
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
525 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
|
526 ButtonPressMask | ButtonReleaseMask | |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
527 KeyPressMask | KeyReleaseMask); |
78 | 528 XFlush(display); |
529 | |
530 *displayp = display; | |
531 *visualp = visual; | |
532 *winp = win; | |
533 | |
534 return OK; | |
535 } | |
536 | |
537 /*! \brief Initialize a MadButterfy runtime for Xlib. | |
538 * | |
757
f43224bf3524
Remove unused variables and refactor to X_MB_init_with_win
Thinker K.F. Li <thinker@codemud.net>
parents:
756
diff
changeset
|
539 * This one is very like X_MB_init(), except it accepts a |
f43224bf3524
Remove unused variables and refactor to X_MB_init_with_win
Thinker K.F. Li <thinker@codemud.net>
parents:
756
diff
changeset
|
540 * X_MB_runtime_t object initialized with a display connected to a X |
f43224bf3524
Remove unused variables and refactor to X_MB_init_with_win
Thinker K.F. Li <thinker@codemud.net>
parents:
756
diff
changeset
|
541 * server and an opened window. |
f43224bf3524
Remove unused variables and refactor to X_MB_init_with_win
Thinker K.F. Li <thinker@codemud.net>
parents:
756
diff
changeset
|
542 * |
f43224bf3524
Remove unused variables and refactor to X_MB_init_with_win
Thinker K.F. Li <thinker@codemud.net>
parents:
756
diff
changeset
|
543 * Following field of the X_MB_runtime_t object should be initialized. |
f43224bf3524
Remove unused variables and refactor to X_MB_init_with_win
Thinker K.F. Li <thinker@codemud.net>
parents:
756
diff
changeset
|
544 * - w, h |
f43224bf3524
Remove unused variables and refactor to X_MB_init_with_win
Thinker K.F. Li <thinker@codemud.net>
parents:
756
diff
changeset
|
545 * - win |
f43224bf3524
Remove unused variables and refactor to X_MB_init_with_win
Thinker K.F. Li <thinker@codemud.net>
parents:
756
diff
changeset
|
546 * - display |
f43224bf3524
Remove unused variables and refactor to X_MB_init_with_win
Thinker K.F. Li <thinker@codemud.net>
parents:
756
diff
changeset
|
547 * - visual |
78 | 548 */ |
757
f43224bf3524
Remove unused variables and refactor to X_MB_init_with_win
Thinker K.F. Li <thinker@codemud.net>
parents:
756
diff
changeset
|
549 static int |
870
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
550 X_MB_init_with_win_internal(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
|
551 mb_img_ldr_t *img_ldr; |
757
f43224bf3524
Remove unused variables and refactor to X_MB_init_with_win
Thinker K.F. Li <thinker@codemud.net>
parents:
756
diff
changeset
|
552 int w, h; |
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
757
diff
changeset
|
553 |
757
f43224bf3524
Remove unused variables and refactor to X_MB_init_with_win
Thinker K.F. Li <thinker@codemud.net>
parents:
756
diff
changeset
|
554 w = xmb_rt->w; |
f43224bf3524
Remove unused variables and refactor to X_MB_init_with_win
Thinker K.F. Li <thinker@codemud.net>
parents:
756
diff
changeset
|
555 h = xmb_rt->h; |
691
05a453e07d01
X_supp.c uses XSHM to avoid overhead of transmission
Thinker K.F. Li <thinker@branda.to>
parents:
556
diff
changeset
|
556 |
78 | 557 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
|
558 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
|
559 |
e98ae1407ca2
Remove mbe_set_source_surface() from graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
462
diff
changeset
|
560 xmb_rt->surface_ptn = |
e98ae1407ca2
Remove mbe_set_source_surface() from graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
462
diff
changeset
|
561 mbe_pattern_create_for_surface(xmb_rt->surface); |
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
757
diff
changeset
|
562 |
693
8b7964869f7a
Update window with XImage through XSHM
Thinker K.F. Li <thinker@branda.to>
parents:
692
diff
changeset
|
563 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
|
564 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
|
565 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
|
566 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
|
567 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
|
568 w, h); |
78 | 569 |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
350
diff
changeset
|
570 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
|
571 xmb_rt->backend_cr = mbe_create(xmb_rt->backend_surface); |
78 | 572 |
471
e98ae1407ca2
Remove mbe_set_source_surface() from graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
462
diff
changeset
|
573 mbe_set_source(xmb_rt->backend_cr, xmb_rt->surface_ptn); |
78 | 574 |
575 xmb_rt->rdman = (redraw_man_t *)malloc(sizeof(redraw_man_t)); | |
576 redraw_man_init(xmb_rt->rdman, xmb_rt->cr, xmb_rt->backend_cr); | |
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
757
diff
changeset
|
577 // FIXME: This is a wired loopback reference. This is inly required when we need |
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
|
578 // 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
|
579 // 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
|
580 xmb_rt->rdman->rt = xmb_rt; |
78 | 581 |
582 xmb_rt->tman = mb_tman_new(); | |
583 | |
346
b391722bf20e
sh_image_t::img_data is managed by paint_image_t.
Thinker K.F. Li <thinker@branda.to>
parents:
270
diff
changeset
|
584 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
|
585 xmb_rt->img_ldr = img_ldr; |
b42ee279669e
Change function name and add comments.
Thinker K.F. Li <thinker@branda.to>
parents:
260
diff
changeset
|
586 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
|
587 memset(xmb_rt->monitors,0,sizeof(xmb_rt->monitors)); |
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
757
diff
changeset
|
588 |
224
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
589 #ifndef ONLY_MOUSE_MOVE_RAW |
83 | 590 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
|
591 #endif |
83 | 592 |
122
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
593 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
|
594 |
78 | 595 return OK; |
596 } | |
597 | |
757
f43224bf3524
Remove unused variables and refactor to X_MB_init_with_win
Thinker K.F. Li <thinker@codemud.net>
parents:
756
diff
changeset
|
598 /*! \brief Initialize a MadButterfy runtime for Xlib. |
f43224bf3524
Remove unused variables and refactor to X_MB_init_with_win
Thinker K.F. Li <thinker@codemud.net>
parents:
756
diff
changeset
|
599 * |
f43224bf3524
Remove unused variables and refactor to X_MB_init_with_win
Thinker K.F. Li <thinker@codemud.net>
parents:
756
diff
changeset
|
600 * It setups a runtime environment to run MadButterfly with Xlib. |
f43224bf3524
Remove unused variables and refactor to X_MB_init_with_win
Thinker K.F. Li <thinker@codemud.net>
parents:
756
diff
changeset
|
601 * Users should specify width and height of the opening window. |
f43224bf3524
Remove unused variables and refactor to X_MB_init_with_win
Thinker K.F. Li <thinker@codemud.net>
parents:
756
diff
changeset
|
602 */ |
870
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
603 static int X_MB_init(X_MB_runtime_t *xmb_rt, const char *display_name, |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
604 int w, int h) { |
757
f43224bf3524
Remove unused variables and refactor to X_MB_init_with_win
Thinker K.F. Li <thinker@codemud.net>
parents:
756
diff
changeset
|
605 int r; |
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
757
diff
changeset
|
606 |
757
f43224bf3524
Remove unused variables and refactor to X_MB_init_with_win
Thinker K.F. Li <thinker@codemud.net>
parents:
756
diff
changeset
|
607 memset(xmb_rt, 0, sizeof(X_MB_runtime_t)); |
f43224bf3524
Remove unused variables and refactor to X_MB_init_with_win
Thinker K.F. Li <thinker@codemud.net>
parents:
756
diff
changeset
|
608 |
f43224bf3524
Remove unused variables and refactor to X_MB_init_with_win
Thinker K.F. Li <thinker@codemud.net>
parents:
756
diff
changeset
|
609 xmb_rt->w = w; |
f43224bf3524
Remove unused variables and refactor to X_MB_init_with_win
Thinker K.F. Li <thinker@codemud.net>
parents:
756
diff
changeset
|
610 xmb_rt->h = h; |
f43224bf3524
Remove unused variables and refactor to X_MB_init_with_win
Thinker K.F. Li <thinker@codemud.net>
parents:
756
diff
changeset
|
611 r = X_init_connection(display_name, w, h, &xmb_rt->display, |
f43224bf3524
Remove unused variables and refactor to X_MB_init_with_win
Thinker K.F. Li <thinker@codemud.net>
parents:
756
diff
changeset
|
612 &xmb_rt->visual, &xmb_rt->win); |
f43224bf3524
Remove unused variables and refactor to X_MB_init_with_win
Thinker K.F. Li <thinker@codemud.net>
parents:
756
diff
changeset
|
613 if(r != OK) |
f43224bf3524
Remove unused variables and refactor to X_MB_init_with_win
Thinker K.F. Li <thinker@codemud.net>
parents:
756
diff
changeset
|
614 return ERR; |
f43224bf3524
Remove unused variables and refactor to X_MB_init_with_win
Thinker K.F. Li <thinker@codemud.net>
parents:
756
diff
changeset
|
615 |
870
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
616 r = X_MB_init_with_win_internal(xmb_rt); |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
617 |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
618 return r; |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
619 } |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
620 |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
621 /*! \brief Initialize a MadButterfly runtime for a window of X. |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
622 * |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
623 * Runtimes initialized with this function should be destroyed with |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
624 * X_MB_destroy_keep_win(). |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
625 */ |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
626 static int |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
627 X_MB_init_with_win(X_MB_runtime_t *xmb_rt, |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
628 Display *display, Window win) { |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
629 XWindowAttributes attrs; |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
630 int r; |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
631 |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
632 r = XGetWindowAttributes(display, win, &attrs); |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
633 if(r == 0) |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
634 return ERR; |
904
f838e5207ec4
Remove XSHM support from DirectFB backend.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
903
diff
changeset
|
635 |
870
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
636 memset(xmb_rt, 0, sizeof(X_MB_runtime_t)); |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
637 |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
638 xmb_rt->display = display; |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
639 xmb_rt->win = win; |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
640 xmb_rt->visual = attrs.visual; |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
641 xmb_rt->w = attrs.width; |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
642 xmb_rt->h = attrs.height; |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
643 |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
644 r = X_MB_init_with_win_internal(xmb_rt); |
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
757
diff
changeset
|
645 |
757
f43224bf3524
Remove unused variables and refactor to X_MB_init_with_win
Thinker K.F. Li <thinker@codemud.net>
parents:
756
diff
changeset
|
646 return r; |
f43224bf3524
Remove unused variables and refactor to X_MB_init_with_win
Thinker K.F. Li <thinker@codemud.net>
parents:
756
diff
changeset
|
647 } |
f43224bf3524
Remove unused variables and refactor to X_MB_init_with_win
Thinker K.F. Li <thinker@codemud.net>
parents:
756
diff
changeset
|
648 |
122
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
649 static void X_MB_destroy(X_MB_runtime_t *xmb_rt) { |
78 | 650 if(xmb_rt->rdman) { |
651 redraw_man_destroy(xmb_rt->rdman); | |
652 free(xmb_rt->rdman); | |
653 } | |
654 | |
655 if(xmb_rt->tman) | |
656 mb_tman_free(xmb_rt->tman); | |
657 | |
259
e8a784a306d0
Initialize an image loader for X runtime
Thinker K.F. Li <thinker@branda.to>
parents:
249
diff
changeset
|
658 if(xmb_rt->img_ldr) |
e8a784a306d0
Initialize an image loader for X runtime
Thinker K.F. Li <thinker@branda.to>
parents:
249
diff
changeset
|
659 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
|
660 |
78 | 661 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
|
662 mbe_destroy(xmb_rt->cr); |
78 | 663 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
|
664 mbe_destroy(xmb_rt->backend_cr); |
78 | 665 |
666 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
|
667 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
|
668 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
|
669 mbe_pattern_destroy(xmb_rt->surface_ptn); |
78 | 670 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
|
671 mbe_surface_destroy(xmb_rt->backend_surface); |
78 | 672 |
673 if(xmb_rt->display) | |
674 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
|
675 |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
676 X_kb_destroy(&xmb_rt->kbinfo); |
78 | 677 } |
678 | |
870
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
679 /*! \brief Destroy a MadButterfly runtime initialized with |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
680 * X_MB_init_with_win(). |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
681 * |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
682 * Destroying a runtime with this function prevent the window and |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
683 * display associated with the runtime being closed. |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
684 */ |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
685 static void |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
686 X_MB_destroy_keep_win(X_MB_runtime_t *xmb_rt) { |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
687 Display *display; |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
688 Window win; |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
689 |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
690 display = xmb_rt->display; |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
691 xmb_rt->display = NULL; |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
692 win = xmb_rt->win; |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
693 xmb_rt->win = 0; |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
694 |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
695 X_MB_destroy(xmb_rt); |
904
f838e5207ec4
Remove XSHM support from DirectFB backend.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
903
diff
changeset
|
696 |
870
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
697 xmb_rt->display = display; |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
698 xmb_rt->win = win; |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
699 } |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
700 |
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
|
701 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
|
702 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
|
703 int r; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
704 |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
705 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
|
706 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
|
707 return NULL; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
708 |
870
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
709 r = X_MB_init(rt, display_name, w, h); |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
710 if(r != OK) { |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
711 free(rt); |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
712 return NULL; |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
713 } |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
714 |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
715 return rt; |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
716 } |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
717 |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
718 /*! \brief Create a new runtime for existed window for X. |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
719 * |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
720 * The object returned by this function must be free with |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
721 * X_MB_free_keep_win() to prevent the window from closed. |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
722 */ |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
723 void *X_MB_new_with_win(Display *display, Window win) { |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
724 X_MB_runtime_t *rt; |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
725 int r; |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
726 |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
727 rt = O_ALLOC(X_MB_runtime_t); |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
728 if(rt == NULL) |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
729 return NULL; |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
730 |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
731 r = X_MB_init_with_win(rt, display, win); |
528
d687d3395264
Clear variables and draw root coord.
Thinker K.F. Li <thinker@branda.to>
parents:
471
diff
changeset
|
732 if(r != OK) { |
d687d3395264
Clear variables and draw root coord.
Thinker K.F. Li <thinker@branda.to>
parents:
471
diff
changeset
|
733 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
|
734 return NULL; |
528
d687d3395264
Clear variables and draw root coord.
Thinker K.F. Li <thinker@branda.to>
parents:
471
diff
changeset
|
735 } |
122
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
736 |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
737 return rt; |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
738 } |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
739 |
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
|
740 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
|
741 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
|
742 free(rt); |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
743 } |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
744 |
870
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
745 /*! \brief Free runtime created with X_MB_new_with_win(). |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
746 */ |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
747 void |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
748 X_MB_free_keep_win(void *rt) { |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
749 X_MB_destroy_keep_win((X_MB_runtime_t *) rt); |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
750 free(rt); |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
751 } |
512204bcafba
Export the function to create a runtime for an existed window for X.
Thinker K.F. Li <thinker@codemud.net>
parents:
869
diff
changeset
|
752 |
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
|
753 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
|
754 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
|
755 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
|
756 } |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
757 |
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
|
758 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
|
759 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
|
760 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
|
761 } |
17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
Thinker K.F. Li <thinker@branda.to>
parents:
120
diff
changeset
|
762 |
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 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
|
764 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
|
765 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
|
766 } |
131
6a8588df68af
Tank can change direction and navigate on the mud area
Thinker K.F. Li <thinker@branda.to>
parents:
122
diff
changeset
|
767 |
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
|
768 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
|
769 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
|
770 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
|
771 |
6a8588df68af
Tank can change direction and navigate on the mud area
Thinker K.F. Li <thinker@branda.to>
parents:
122
diff
changeset
|
772 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
|
773 return factory; |
6a8588df68af
Tank can change direction and navigate on the mud area
Thinker K.F. Li <thinker@branda.to>
parents:
122
diff
changeset
|
774 } |
259
e8a784a306d0
Initialize an image loader for X runtime
Thinker K.F. Li <thinker@branda.to>
parents:
249
diff
changeset
|
775 |
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
|
776 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
|
777 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
|
778 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
|
779 |
e8a784a306d0
Initialize an image loader for X runtime
Thinker K.F. Li <thinker@branda.to>
parents:
249
diff
changeset
|
780 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
|
781 |
e8a784a306d0
Initialize an image loader for X runtime
Thinker K.F. Li <thinker@branda.to>
parents:
249
diff
changeset
|
782 return img_ldr; |
e8a784a306d0
Initialize an image loader for X runtime
Thinker K.F. Li <thinker@branda.to>
parents:
249
diff
changeset
|
783 } |
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
|
784 |
545
49f8f57f184a
Preparing for nodejs plugin
Thinker K.F. Li <thinker@branda.to>
parents:
529
diff
changeset
|
785 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
|
786 { |
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
|
787 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
|
788 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
|
789 |
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
|
790 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
|
791 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
|
792 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
|
793 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
|
794 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
|
795 } |
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
|
796 } |
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
|
797 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
|
798 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
|
799 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
|
800 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
|
801 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
|
802 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
|
803 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
|
804 } |
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
|
805 } |
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
|
806 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
|
807 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
|
808 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
|
809 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
|
810 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
|
811 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
|
812 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
|
813 } |
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
|
814 |
545
49f8f57f184a
Preparing for nodejs plugin
Thinker K.F. Li <thinker@branda.to>
parents:
529
diff
changeset
|
815 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
|
816 { |
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
|
817 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
|
818 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
|
819 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
|
820 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
|
821 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
|
822 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
|
823 } |
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
|
824 } |
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
|
825 } |
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
|
826 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
|
827 X_MB_free, |
545
49f8f57f184a
Preparing for nodejs plugin
Thinker K.F. Li <thinker@branda.to>
parents:
529
diff
changeset
|
828 X_MB_add_event, |
49f8f57f184a
Preparing for nodejs plugin
Thinker K.F. Li <thinker@branda.to>
parents:
529
diff
changeset
|
829 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
|
830 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
|
831 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
|
832 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
|
833 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
|
834 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
|
835 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
|
836 }; |
545
49f8f57f184a
Preparing for nodejs plugin
Thinker K.F. Li <thinker@branda.to>
parents:
529
diff
changeset
|
837 /*! \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
|
838 * |
49f8f57f184a
Preparing for nodejs plugin
Thinker K.F. Li <thinker@branda.to>
parents:
529
diff
changeset
|
839 * These functions are for internal using. |
49f8f57f184a
Preparing for nodejs plugin
Thinker K.F. Li <thinker@branda.to>
parents:
529
diff
changeset
|
840 * @{ |
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
757
diff
changeset
|
841 */ |
545
49f8f57f184a
Preparing for nodejs plugin
Thinker K.F. Li <thinker@branda.to>
parents:
529
diff
changeset
|
842 /*! \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
|
843 */ |
550
127499ab2412
Upgrade ndoejs plugin to level of a new runtime.
Thinker K.F. Li <thinker@branda.to>
parents:
545
diff
changeset
|
844 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
|
845 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
|
846 } |
49f8f57f184a
Preparing for nodejs plugin
Thinker K.F. Li <thinker@branda.to>
parents:
529
diff
changeset
|
847 |
49f8f57f184a
Preparing for nodejs plugin
Thinker K.F. Li <thinker@branda.to>
parents:
529
diff
changeset
|
848 /*! \brief Get X connect for nodejs plugin. |
49f8f57f184a
Preparing for nodejs plugin
Thinker K.F. Li <thinker@branda.to>
parents:
529
diff
changeset
|
849 */ |
550
127499ab2412
Upgrade ndoejs plugin to level of a new runtime.
Thinker K.F. Li <thinker@branda.to>
parents:
545
diff
changeset
|
850 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
|
851 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
|
852 } |
49f8f57f184a
Preparing for nodejs plugin
Thinker K.F. Li <thinker@branda.to>
parents:
529
diff
changeset
|
853 |
49f8f57f184a
Preparing for nodejs plugin
Thinker K.F. Li <thinker@branda.to>
parents:
529
diff
changeset
|
854 /*! \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
|
855 */ |
556
c9d23f7279a4
The first testcase that nodejs code can show a MadButterfly window.
Thinker K.F. Li <thinker@branda.to>
parents:
550
diff
changeset
|
856 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
|
857 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
|
858 return XFlush(xmb_rt->display); |
545
49f8f57f184a
Preparing for nodejs plugin
Thinker K.F. Li <thinker@branda.to>
parents:
529
diff
changeset
|
859 } |
49f8f57f184a
Preparing for nodejs plugin
Thinker K.F. Li <thinker@branda.to>
parents:
529
diff
changeset
|
860 |
869
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
861 /*! \brief Handle single X event. |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
862 */ |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
863 void |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
864 _X_MB_handle_single_event(void *rt, void *evt) { |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
865 X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *)rt; |
904
f838e5207ec4
Remove XSHM support from DirectFB backend.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
903
diff
changeset
|
866 |
869
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
867 handle_single_x_event(xmb_rt, (XEvent *)evt); |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
868 } |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
869 |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
870 /*! \brief Called at end of an iteration of X event loop. |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
871 */ |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
872 void |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
873 _X_MB_no_more_event(void *rt) { |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
874 X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *)rt; |
904
f838e5207ec4
Remove XSHM support from DirectFB backend.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
903
diff
changeset
|
875 |
869
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
876 no_more_event(xmb_rt); |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
877 } |
c18058fb48ee
Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
878 |
545
49f8f57f184a
Preparing for nodejs plugin
Thinker K.F. Li <thinker@branda.to>
parents:
529
diff
changeset
|
879 /* @} */ |