annotate nodejs/X_supp_njs.c @ 787:0899dcac441c

Set bounding box attributes for JS Parse inkscape:bbox-x/y/width/height to - bbox_x - bbox_y - bbox_width - bbox_height
author Thinker K.F. Li <thinker@codemud.net>
date Tue, 31 Aug 2010 01:26:22 +0800
parents cedfe4966fd6
children 586e50f82c1f
rev   line source
546
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1 /*! \brief Implement X11 backend for nodejs plugin.
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2 *
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
3 * Since nodejs use libev to handle event loops, part of X11 backend
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
4 * code can not be used directly. The part of code should be rewrote.
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
5 * The part is about
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
6 */
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
7 #include <stdio.h>
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
8 #include <X11/Xlib.h>
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
9 #include <X11/Xutil.h>
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
10 #include <ev.h>
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
11 #include "mb_X_supp.h"
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
12 #include "mb_tools.h"
560
ce7a35abcb0d Function to instantiate coord for Javascript
Thinker K.F. Li <thinker@branda.to>
parents: 556
diff changeset
13 #include "X_supp_njs.h"
546
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
14
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
15 #ifndef ASSERT
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
16 #define ASSERT(x)
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
17 #endif
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
18
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
19 static void timer_cb(EV_P_ ev_timer *tmwatcher, int revent);
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
20
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
21 /*! \brief Register next timeout with libev.
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
22 */
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
23 static void
552
dd8d32b4c899 rename ev_data to rt
Thinker K.F. Li <thinker@branda.to>
parents: 551
diff changeset
24 set_next_timeout(njs_runtime_t *rt) {
546
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
25 mb_tman_t *tman;
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
26 mb_timeval_t now, tmo;
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
27 ev_tstamp tout;
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
28 int r;
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
29
552
dd8d32b4c899 rename ev_data to rt
Thinker K.F. Li <thinker@branda.to>
parents: 551
diff changeset
30 tman = X_MB_tman(rt->xrt);
546
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
31 get_now(&now);
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
32 r = mb_tman_next_timeout(tman, &now, &tmo);
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
33 if(r == 0) {
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
34 MB_TIMEVAL_DIFF(&tmo, &now);
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
35 tout = (ev_tstamp)MB_TIMEVAL_SEC(&tmo) +
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
36 (ev_tstamp)MB_TIMEVAL_USEC(&tmo) / 1000000;
552
dd8d32b4c899 rename ev_data to rt
Thinker K.F. Li <thinker@branda.to>
parents: 551
diff changeset
37 ev_timer_init(&rt->tmwatcher, timer_cb, tout, 0);
dd8d32b4c899 rename ev_data to rt
Thinker K.F. Li <thinker@branda.to>
parents: 551
diff changeset
38 ev_timer_start(&rt->tmwatcher);
dd8d32b4c899 rename ev_data to rt
Thinker K.F. Li <thinker@branda.to>
parents: 551
diff changeset
39 rt->enable_timer = 1;
546
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
40 } else
552
dd8d32b4c899 rename ev_data to rt
Thinker K.F. Li <thinker@branda.to>
parents: 551
diff changeset
41 rt->enable_timer = 0;
546
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
42 }
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
43
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
44 static void
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
45 x_conn_cb(EV_P_ ev_io *iowatcher, int revent) {
552
dd8d32b4c899 rename ev_data to rt
Thinker K.F. Li <thinker@branda.to>
parents: 551
diff changeset
46 njs_runtime_t *rt = MEM2OBJ(iowatcher, njs_runtime_t, iowatcher);
546
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
47 redraw_man_t *rdman;
550
127499ab2412 Upgrade ndoejs plugin to level of a new runtime.
Thinker K.F. Li <thinker@branda.to>
parents: 546
diff changeset
48 extern void _X_MB_handle_x_event_for_nodejs(void *rt);
546
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
49
552
dd8d32b4c899 rename ev_data to rt
Thinker K.F. Li <thinker@branda.to>
parents: 551
diff changeset
50 rdman = X_MB_rdman(rt->xrt);
dd8d32b4c899 rename ev_data to rt
Thinker K.F. Li <thinker@branda.to>
parents: 551
diff changeset
51 _X_MB_handle_x_event_for_nodejs(rt->xrt);
546
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
52 rdman_redraw_changed(rdman);
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
53
552
dd8d32b4c899 rename ev_data to rt
Thinker K.F. Li <thinker@branda.to>
parents: 551
diff changeset
54 if(rt->enable_timer == 0) /* no installed timeout */
dd8d32b4c899 rename ev_data to rt
Thinker K.F. Li <thinker@branda.to>
parents: 551
diff changeset
55 set_next_timeout(rt);
546
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
56 }
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
57
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
58 static void
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
59 timer_cb(EV_P_ ev_timer *tmwatcher, int revent) {
552
dd8d32b4c899 rename ev_data to rt
Thinker K.F. Li <thinker@branda.to>
parents: 551
diff changeset
60 njs_runtime_t *rt = MEM2OBJ(tmwatcher, njs_runtime_t, tmwatcher);
546
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
61 mb_tman_t *tman;
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
62 redraw_man_t *rdman;
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
63 mb_timeval_t now;
556
c9d23f7279a4 The first testcase that nodejs code can show a MadButterfly window.
Thinker K.F. Li <thinker@branda.to>
parents: 554
diff changeset
64 extern int _X_MB_flush_x_conn_for_nodejs(void *rt);
546
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
65
552
dd8d32b4c899 rename ev_data to rt
Thinker K.F. Li <thinker@branda.to>
parents: 551
diff changeset
66 tman = X_MB_tman(rt->xrt);
546
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
67 get_now(&now);
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
68 mb_tman_handle_timeout(tman, &now);
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
69
552
dd8d32b4c899 rename ev_data to rt
Thinker K.F. Li <thinker@branda.to>
parents: 551
diff changeset
70 rdman = X_MB_rdman(rt->xrt);
546
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
71 rdman_redraw_changed(rdman);
556
c9d23f7279a4 The first testcase that nodejs code can show a MadButterfly window.
Thinker K.F. Li <thinker@branda.to>
parents: 554
diff changeset
72 _X_MB_flush_x_conn_for_nodejs(rt->xrt);
546
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
73
552
dd8d32b4c899 rename ev_data to rt
Thinker K.F. Li <thinker@branda.to>
parents: 551
diff changeset
74 set_next_timeout(rt);
546
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
75 }
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
76
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
77 /*! \brief Handle connection coming data and timeout of timers.
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
78 *
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
79 * \param rt is a runtime object for X.
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
80 */
550
127499ab2412 Upgrade ndoejs plugin to level of a new runtime.
Thinker K.F. Li <thinker@branda.to>
parents: 546
diff changeset
81 void
556
c9d23f7279a4 The first testcase that nodejs code can show a MadButterfly window.
Thinker K.F. Li <thinker@branda.to>
parents: 554
diff changeset
82 X_njs_MB_init_handle_connection(njs_runtime_t *rt) {
552
dd8d32b4c899 rename ev_data to rt
Thinker K.F. Li <thinker@branda.to>
parents: 551
diff changeset
83 void *xrt = rt->xrt;
546
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
84 int fd;
550
127499ab2412 Upgrade ndoejs plugin to level of a new runtime.
Thinker K.F. Li <thinker@branda.to>
parents: 546
diff changeset
85 extern int _X_MB_get_x_conn_for_nodejs(void *rt);
546
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
86
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
87 /*
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
88 * Setup watcher for X connection.
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
89 */
551
9e69c4a0f565 rename njs_ev_data_t to njs_runtime_t
Thinker K.F. Li <thinker@branda.to>
parents: 550
diff changeset
90 fd = _X_MB_get_x_conn_for_nodejs(xrt);
552
dd8d32b4c899 rename ev_data to rt
Thinker K.F. Li <thinker@branda.to>
parents: 551
diff changeset
91 ev_io_init(&rt->iowatcher, x_conn_cb, fd, EV_READ);
dd8d32b4c899 rename ev_data to rt
Thinker K.F. Li <thinker@branda.to>
parents: 551
diff changeset
92 ev_io_start(&rt->iowatcher);
554
4caf6090825f Fix leaking on freeing a njs runtime object
Thinker K.F. Li <thinker@branda.to>
parents: 553
diff changeset
93 rt->enable_io = 1;
546
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
94
552
dd8d32b4c899 rename ev_data to rt
Thinker K.F. Li <thinker@branda.to>
parents: 551
diff changeset
95 set_next_timeout(rt);
546
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
96 }
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
97
551
9e69c4a0f565 rename njs_ev_data_t to njs_runtime_t
Thinker K.F. Li <thinker@branda.to>
parents: 550
diff changeset
98 /*! \brief Free njs_runtime_t.
550
127499ab2412 Upgrade ndoejs plugin to level of a new runtime.
Thinker K.F. Li <thinker@branda.to>
parents: 546
diff changeset
99 */
127499ab2412 Upgrade ndoejs plugin to level of a new runtime.
Thinker K.F. Li <thinker@branda.to>
parents: 546
diff changeset
100 void
552
dd8d32b4c899 rename ev_data to rt
Thinker K.F. Li <thinker@branda.to>
parents: 551
diff changeset
101 X_njs_MB_free(njs_runtime_t *rt) {
546
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
102 /*
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
103 * stop IO and timer watcher
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
104 */
554
4caf6090825f Fix leaking on freeing a njs runtime object
Thinker K.F. Li <thinker@branda.to>
parents: 553
diff changeset
105 if(rt->enable_io)
4caf6090825f Fix leaking on freeing a njs runtime object
Thinker K.F. Li <thinker@branda.to>
parents: 553
diff changeset
106 ev_io_stop(&rt->iowatcher);
552
dd8d32b4c899 rename ev_data to rt
Thinker K.F. Li <thinker@branda.to>
parents: 551
diff changeset
107 if(rt->enable_timer)
dd8d32b4c899 rename ev_data to rt
Thinker K.F. Li <thinker@branda.to>
parents: 551
diff changeset
108 ev_timer_stop(&rt->tmwatcher);
554
4caf6090825f Fix leaking on freeing a njs runtime object
Thinker K.F. Li <thinker@branda.to>
parents: 553
diff changeset
109
4caf6090825f Fix leaking on freeing a njs runtime object
Thinker K.F. Li <thinker@branda.to>
parents: 553
diff changeset
110 X_MB_free(rt->xrt);
4caf6090825f Fix leaking on freeing a njs runtime object
Thinker K.F. Li <thinker@branda.to>
parents: 553
diff changeset
111 free(rt);
546
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
112 }
550
127499ab2412 Upgrade ndoejs plugin to level of a new runtime.
Thinker K.F. Li <thinker@branda.to>
parents: 546
diff changeset
113
571
13b15b7a463b Redraw all and changed in Javascript
Thinker K.F. Li <thinker@branda.to>
parents: 560
diff changeset
114 int
13b15b7a463b Redraw all and changed in Javascript
Thinker K.F. Li <thinker@branda.to>
parents: 560
diff changeset
115 X_njs_MB_flush(njs_runtime_t *rt) {
13b15b7a463b Redraw all and changed in Javascript
Thinker K.F. Li <thinker@branda.to>
parents: 560
diff changeset
116 void *xrt = rt->xrt;
13b15b7a463b Redraw all and changed in Javascript
Thinker K.F. Li <thinker@branda.to>
parents: 560
diff changeset
117 int r;
13b15b7a463b Redraw all and changed in Javascript
Thinker K.F. Li <thinker@branda.to>
parents: 560
diff changeset
118 extern int _X_MB_flush_x_conn_for_nodejs(void *rt);
13b15b7a463b Redraw all and changed in Javascript
Thinker K.F. Li <thinker@branda.to>
parents: 560
diff changeset
119
13b15b7a463b Redraw all and changed in Javascript
Thinker K.F. Li <thinker@branda.to>
parents: 560
diff changeset
120 _X_MB_flush_x_conn_for_nodejs(xrt);
13b15b7a463b Redraw all and changed in Javascript
Thinker K.F. Li <thinker@branda.to>
parents: 560
diff changeset
121
13b15b7a463b Redraw all and changed in Javascript
Thinker K.F. Li <thinker@branda.to>
parents: 560
diff changeset
122 return r;
13b15b7a463b Redraw all and changed in Javascript
Thinker K.F. Li <thinker@branda.to>
parents: 560
diff changeset
123 }
13b15b7a463b Redraw all and changed in Javascript
Thinker K.F. Li <thinker@branda.to>
parents: 560
diff changeset
124
551
9e69c4a0f565 rename njs_ev_data_t to njs_runtime_t
Thinker K.F. Li <thinker@branda.to>
parents: 550
diff changeset
125 njs_runtime_t *
550
127499ab2412 Upgrade ndoejs plugin to level of a new runtime.
Thinker K.F. Li <thinker@branda.to>
parents: 546
diff changeset
126 X_njs_MB_new(char *display_name, int w, int h) {
552
dd8d32b4c899 rename ev_data to rt
Thinker K.F. Li <thinker@branda.to>
parents: 551
diff changeset
127 njs_runtime_t *rt;
551
9e69c4a0f565 rename njs_ev_data_t to njs_runtime_t
Thinker K.F. Li <thinker@branda.to>
parents: 550
diff changeset
128 void *xrt;
550
127499ab2412 Upgrade ndoejs plugin to level of a new runtime.
Thinker K.F. Li <thinker@branda.to>
parents: 546
diff changeset
129
552
dd8d32b4c899 rename ev_data to rt
Thinker K.F. Li <thinker@branda.to>
parents: 551
diff changeset
130 rt = (njs_runtime_t *)malloc(sizeof(njs_runtime_t));
dd8d32b4c899 rename ev_data to rt
Thinker K.F. Li <thinker@branda.to>
parents: 551
diff changeset
131 ASSERT(rt != NULL);
550
127499ab2412 Upgrade ndoejs plugin to level of a new runtime.
Thinker K.F. Li <thinker@branda.to>
parents: 546
diff changeset
132
551
9e69c4a0f565 rename njs_ev_data_t to njs_runtime_t
Thinker K.F. Li <thinker@branda.to>
parents: 550
diff changeset
133 xrt = X_MB_new(display_name, w, h);
550
127499ab2412 Upgrade ndoejs plugin to level of a new runtime.
Thinker K.F. Li <thinker@branda.to>
parents: 546
diff changeset
134
552
dd8d32b4c899 rename ev_data to rt
Thinker K.F. Li <thinker@branda.to>
parents: 551
diff changeset
135 rt->xrt = xrt;
554
4caf6090825f Fix leaking on freeing a njs runtime object
Thinker K.F. Li <thinker@branda.to>
parents: 553
diff changeset
136 rt->enable_io = 0;
552
dd8d32b4c899 rename ev_data to rt
Thinker K.F. Li <thinker@branda.to>
parents: 551
diff changeset
137 rt->enable_timer = 0; /* no timer, now */
550
127499ab2412 Upgrade ndoejs plugin to level of a new runtime.
Thinker K.F. Li <thinker@branda.to>
parents: 546
diff changeset
138
552
dd8d32b4c899 rename ev_data to rt
Thinker K.F. Li <thinker@branda.to>
parents: 551
diff changeset
139 return rt;
550
127499ab2412 Upgrade ndoejs plugin to level of a new runtime.
Thinker K.F. Li <thinker@branda.to>
parents: 546
diff changeset
140 }
127499ab2412 Upgrade ndoejs plugin to level of a new runtime.
Thinker K.F. Li <thinker@branda.to>
parents: 546
diff changeset
141
553
0a77b88500bf rename _X_njs_MB_get_runtime to _X_njs_MB_get_X_runtime
Thinker K.F. Li <thinker@branda.to>
parents: 552
diff changeset
142 /*! \brief Get X runtime that is backend of this njs runtime.
0a77b88500bf rename _X_njs_MB_get_runtime to _X_njs_MB_get_X_runtime
Thinker K.F. Li <thinker@branda.to>
parents: 552
diff changeset
143 */
550
127499ab2412 Upgrade ndoejs plugin to level of a new runtime.
Thinker K.F. Li <thinker@branda.to>
parents: 546
diff changeset
144 void *
553
0a77b88500bf rename _X_njs_MB_get_runtime to _X_njs_MB_get_X_runtime
Thinker K.F. Li <thinker@branda.to>
parents: 552
diff changeset
145 _X_njs_MB_get_X_runtime(njs_runtime_t *rt) {
552
dd8d32b4c899 rename ev_data to rt
Thinker K.F. Li <thinker@branda.to>
parents: 551
diff changeset
146 return rt->xrt;
550
127499ab2412 Upgrade ndoejs plugin to level of a new runtime.
Thinker K.F. Li <thinker@branda.to>
parents: 546
diff changeset
147 }