summaryrefslogtreecommitdiff
path: root/src/bin/engine_software_16_x11.c
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2007-04-30 07:03:20 +0000
committerCarsten Haitzler <raster@rasterman.com>2007-04-30 07:03:20 +0000
commit3b97a2f9c47dbdb7d3cac00386cb535fedd2b329 (patch)
tree9b37a207780d20cff2cb2cf0c6233f9cb117f489 /src/bin/engine_software_16_x11.c
parentaf2460a361f73d3e4c9f7b960be8ad1628e716e2 (diff)
missed these. oops. added.
SVN revision: 29779
Diffstat (limited to 'src/bin/engine_software_16_x11.c')
-rw-r--r--src/bin/engine_software_16_x11.c203
1 files changed, 203 insertions, 0 deletions
diff --git a/src/bin/engine_software_16_x11.c b/src/bin/engine_software_16_x11.c
new file mode 100644
index 0000000..df9de3a
--- /dev/null
+++ b/src/bin/engine_software_16_x11.c
@@ -0,0 +1,203 @@
1#include "main.h"
2#ifndef HAVE_SOFTWARE_16_X11
3int
4engine_software_16_x11_args(int argc, char **argv)
5{
6 fprintf(stderr, "ERROR: No Software 16bit X11 Engine built\n");
7 return 0;
8}
9
10void
11engine_software_16_x11_loop(void)
12{
13}
14#else
15#include <X11/Xlib.h>
16#include <X11/Xutil.h>
17#include <Evas_Engine_Software_16_X11.h>
18
19static Display *disp = NULL;
20static Window win = 0;
21
22int
23engine_software_16_x11_args(int argc, char **argv)
24{
25 XSetWindowAttributes attr;
26 XClassHint chint;
27 XSizeHints szhints;
28 Evas_Engine_Info_Software_16_X11 *einfo;
29 int i;
30 int ok = 0;
31
32 for (i = 1; i < argc; i++)
33 {
34 if ((!strcmp(argv[i], "-e")) && (i < (argc - 1)))
35 {
36 i++;
37 if (!strcmp(argv[i], "x11-16")) ok = 1;
38 }
39 }
40 if (!ok) return 0;
41
42 disp = XOpenDisplay(NULL);
43 if (!disp) return 0;
44
45 evas_output_method_set(evas, evas_render_method_lookup("software_16_x11"));
46 einfo = (Evas_Engine_Info_Software_16_X11 *)evas_engine_info_get(evas);
47 if (!einfo)
48 {
49 printf("Evas does not support the Software 16bit X11 Engine\n");
50 return 0;
51 }
52
53 einfo->info.display = disp;
54 attr.backing_store = NotUseful;
55 attr.colormap = DefaultColormap(disp, DefaultScreen(disp));
56 attr.border_pixel = 0;
57 attr.background_pixmap = None;
58 attr.event_mask =
59 ExposureMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask |
60 StructureNotifyMask | EnterWindowMask | LeaveWindowMask |
61 KeyPressMask | KeyReleaseMask;
62 attr.bit_gravity = ForgetGravity;
63 win = XCreateWindow(disp, DefaultRootWindow(disp),
64 0, 0, win_w, win_h, 0,
65 DefaultDepth(disp, DefaultScreen(disp)), InputOutput,
66 DefaultVisual(disp, DefaultScreen(disp)),
67 CWBackingStore | CWColormap |
68 CWBackPixmap | CWBorderPixel |
69 CWBitGravity | CWEventMask,
70 &attr);
71 einfo->info.drawable = win;
72 evas_engine_info_set(evas, (Evas_Engine_Info *) einfo);
73
74 XStoreName(disp, win, "Expedite - Evas Test Suite");
75 chint.res_name = "expedite";
76 chint.res_class = "Expedite";
77 XSetClassHint(disp, win, &chint);
78 szhints.flags = PMinSize | PMaxSize | PSize | USSize;
79 szhints.min_width = szhints.max_width = win_w;
80 szhints.min_height = szhints.max_height = win_h;
81 XSetWMNormalHints(disp, win, &szhints);
82 XMapWindow(disp, win);
83 XSync(disp, False);
84 return 1;
85}
86
87void
88engine_software_16_x11_loop(void)
89{
90 XEvent ev;
91 KeySym ks;
92 char *kstr;
93
94 again:
95 if (!XCheckMaskEvent(disp,
96 ExposureMask |
97 StructureNotifyMask |
98 KeyPressMask |
99 KeyReleaseMask |
100 ButtonPressMask |
101 ButtonReleaseMask |
102 PointerMotionMask |
103 EnterWindowMask |
104 LeaveWindowMask, &ev))
105 return;
106 switch (ev.type)
107 {
108 case ButtonPress:
109 evas_event_feed_mouse_move(evas, ev.xbutton.x, ev.xbutton.y, 0, NULL);
110 evas_event_feed_mouse_down(evas, ev.xbutton.button, EVAS_BUTTON_NONE, 0, NULL);
111 break;
112 case ButtonRelease:
113 evas_event_feed_mouse_move(evas, ev.xbutton.x, ev.xbutton.y, 0, NULL);
114 evas_event_feed_mouse_up(evas, ev.xbutton.button, EVAS_BUTTON_NONE, 0, NULL);
115 break;
116 case MotionNotify:
117 evas_event_feed_mouse_move(evas, ev.xmotion.x, ev.xmotion.y, 0, NULL);
118 break;
119 case Expose:
120 evas_damage_rectangle_add(evas,
121 ev.xexpose.x,
122 ev.xexpose.y,
123 ev.xexpose.width,
124 ev.xexpose.height);
125 break;
126 case ConfigureNotify:
127 evas_output_size_set(evas,
128 ev.xconfigure.width,
129 ev.xconfigure.height);
130 break;
131 case EnterNotify:
132 evas_event_feed_mouse_in(evas, 0, NULL);
133 break;
134 case LeaveNotify:
135 evas_event_feed_mouse_out(evas, 0, NULL);
136 break;
137 case KeyPress:
138 ks = XKeycodeToKeysym(ev.xkey.display, ev.xkey.keycode, 0);
139 kstr = XKeysymToString(ks);
140 if (kstr)
141 {
142 if ((!strcmp(kstr, "Shift_L")) ||
143 (!strcmp(kstr, "Shift_R")))
144 evas_key_modifier_on(evas, "Shift");
145 if ((!strcmp(kstr, "Control_L")) ||
146 (!strcmp(kstr, "Control_R")))
147 evas_key_modifier_on(evas, "Control");
148 if ((!strcmp(kstr, "Alt_L")) ||
149 (!strcmp(kstr, "Alt_R")))
150 evas_key_modifier_on(evas, "Alt");
151 if ((!strcmp(kstr, "Super_L")) ||
152 (!strcmp(kstr, "Super_R")))
153 evas_key_modifier_on(evas, "Super");
154 if (!strcmp(kstr, "Caps_Lock"))
155 {
156 if (evas_key_lock_is_set(evas_key_lock_get(evas), "Caps_Lock"))
157 evas_key_lock_off(evas, "Caps_Lock");
158 else
159 evas_key_lock_on(evas, "Caps_Lock");
160 }
161 if (!strcmp(kstr, "Num_Lock"))
162 {
163 if (evas_key_lock_is_set(evas_key_lock_get(evas), "Num_Lock"))
164 evas_key_lock_off(evas, "Num_Lock");
165 else
166 evas_key_lock_on(evas, "Num_Lock");
167 }
168 if (!strcmp(kstr, "Scroll_Lock"))
169 {
170 if (evas_key_lock_is_set(evas_key_lock_get(evas), "Scroll_Lock"))
171 evas_key_lock_off(evas, "Scroll_Lock");
172 else
173 evas_key_lock_on(evas, "Scroll_Lock");
174 }
175 if (kstr) evas_event_feed_key_down(evas, kstr, kstr, NULL, NULL, 0, NULL);
176 }
177 break;
178 case KeyRelease:
179 ks = XKeycodeToKeysym(ev.xkey.display, ev.xkey.keycode, 0);
180 kstr = XKeysymToString(ks);
181 if (kstr)
182 {
183 if ((!strcmp(kstr, "Shift_L")) ||
184 (!strcmp(kstr, "Shift_R")))
185 evas_key_modifier_off(evas, "Shift");
186 if ((!strcmp(kstr, "Control_L")) ||
187 (!strcmp(kstr, "Control_R")))
188 evas_key_modifier_off(evas, "Control");
189 if ((!strcmp(kstr, "Alt_L")) ||
190 (!strcmp(kstr, "Alt_R")))
191 evas_key_modifier_off(evas, "Alt");
192 if ((!strcmp(kstr, "Super_L")) ||
193 (!strcmp(kstr, "Super_R")))
194 evas_key_modifier_off(evas, "Super");
195 evas_event_feed_key_up(evas, kstr, kstr, NULL, NULL, 0, NULL);
196 }
197 break;
198 default:
199 break;
200 }
201 goto again;
202}
203#endif