-
Notifications
You must be signed in to change notification settings - Fork 1
/
ecef.h
438 lines (408 loc) · 11.2 KB
/
ecef.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
#define CEF_NEW(TYPE) cef_new(sizeof(TYPE), NULL)
#define CEF_NEW_PTR(TYPE, PTR) cef_new(sizeof(TYPE), (void**)PTR)
//#define CEF_INCLUDE_INTERNAL_CEF_EXPORT_H_
//#define CEF_CALLBACK
//#define CEF_EXPORT __attribute__((weak))
#include "include/capi/cef_base_capi.h"
#include "include/capi/cef_browser_capi.h"
#include "include/capi/cef_client_capi.h"
#include "include/capi/cef_render_handler_capi.h"
#include "include/capi/cef_render_process_handler_capi.h"
#include "include/capi/cef_display_handler_capi.h"
#include <assert.h>
#ifndef TEST_APP
// From ui/events/keycodes/keyboard_codes_posix.h.
typedef enum {
VKEY_BACK = 0x08,
VKEY_TAB = 0x09,
VKEY_BACKTAB = 0x0A,
VKEY_CLEAR = 0x0C,
VKEY_RETURN = 0x0D,
VKEY_SHIFT = 0x10,
VKEY_CONTROL = 0x11,
VKEY_MENU = 0x12,
VKEY_PAUSE = 0x13,
VKEY_CAPITAL = 0x14,
VKEY_KANA = 0x15,
VKEY_HANGUL = 0x15,
VKEY_JUNJA = 0x17,
VKEY_FINAL = 0x18,
VKEY_HANJA = 0x19,
VKEY_KANJI = 0x19,
VKEY_ESCAPE = 0x1B,
VKEY_CONVERT = 0x1C,
VKEY_NONCONVERT = 0x1D,
VKEY_ACCEPT = 0x1E,
VKEY_MODECHANGE = 0x1F,
VKEY_SPACE = 0x20,
VKEY_PRIOR = 0x21,
VKEY_NEXT = 0x22,
VKEY_END = 0x23,
VKEY_HOME = 0x24,
VKEY_LEFT = 0x25,
VKEY_UP = 0x26,
VKEY_RIGHT = 0x27,
VKEY_DOWN = 0x28,
VKEY_SELECT = 0x29,
VKEY_PRINT = 0x2A,
VKEY_EXECUTE = 0x2B,
VKEY_SNAPSHOT = 0x2C,
VKEY_INSERT = 0x2D,
VKEY_DELETE = 0x2E,
VKEY_HELP = 0x2F,
VKEY_0 = 0x30,
VKEY_1 = 0x31,
VKEY_2 = 0x32,
VKEY_3 = 0x33,
VKEY_4 = 0x34,
VKEY_5 = 0x35,
VKEY_6 = 0x36,
VKEY_7 = 0x37,
VKEY_8 = 0x38,
VKEY_9 = 0x39,
VKEY_A = 0x41,
VKEY_B = 0x42,
VKEY_C = 0x43,
VKEY_D = 0x44,
VKEY_E = 0x45,
VKEY_F = 0x46,
VKEY_G = 0x47,
VKEY_H = 0x48,
VKEY_I = 0x49,
VKEY_J = 0x4A,
VKEY_K = 0x4B,
VKEY_L = 0x4C,
VKEY_M = 0x4D,
VKEY_N = 0x4E,
VKEY_O = 0x4F,
VKEY_P = 0x50,
VKEY_Q = 0x51,
VKEY_R = 0x52,
VKEY_S = 0x53,
VKEY_T = 0x54,
VKEY_U = 0x55,
VKEY_V = 0x56,
VKEY_W = 0x57,
VKEY_X = 0x58,
VKEY_Y = 0x59,
VKEY_Z = 0x5A,
VKEY_LWIN = 0x5B,
VKEY_COMMAND = VKEY_LWIN, // Provide the Mac name for convenience.
VKEY_RWIN = 0x5C,
VKEY_APPS = 0x5D,
VKEY_SLEEP = 0x5F,
VKEY_NUMPAD0 = 0x60,
VKEY_NUMPAD1 = 0x61,
VKEY_NUMPAD2 = 0x62,
VKEY_NUMPAD3 = 0x63,
VKEY_NUMPAD4 = 0x64,
VKEY_NUMPAD5 = 0x65,
VKEY_NUMPAD6 = 0x66,
VKEY_NUMPAD7 = 0x67,
VKEY_NUMPAD8 = 0x68,
VKEY_NUMPAD9 = 0x69,
VKEY_MULTIPLY = 0x6A,
VKEY_ADD = 0x6B,
VKEY_SEPARATOR = 0x6C,
VKEY_SUBTRACT = 0x6D,
VKEY_DECIMAL = 0x6E,
VKEY_DIVIDE = 0x6F,
VKEY_F1 = 0x70,
VKEY_F2 = 0x71,
VKEY_F3 = 0x72,
VKEY_F4 = 0x73,
VKEY_F5 = 0x74,
VKEY_F6 = 0x75,
VKEY_F7 = 0x76,
VKEY_F8 = 0x77,
VKEY_F9 = 0x78,
VKEY_F10 = 0x79,
VKEY_F11 = 0x7A,
VKEY_F12 = 0x7B,
VKEY_F13 = 0x7C,
VKEY_F14 = 0x7D,
VKEY_F15 = 0x7E,
VKEY_F16 = 0x7F,
VKEY_F17 = 0x80,
VKEY_F18 = 0x81,
VKEY_F19 = 0x82,
VKEY_F20 = 0x83,
VKEY_F21 = 0x84,
VKEY_F22 = 0x85,
VKEY_F23 = 0x86,
VKEY_F24 = 0x87,
VKEY_NUMLOCK = 0x90,
VKEY_SCROLL = 0x91,
VKEY_LSHIFT = 0xA0,
VKEY_RSHIFT = 0xA1,
VKEY_LCONTROL = 0xA2,
VKEY_RCONTROL = 0xA3,
VKEY_LMENU = 0xA4,
VKEY_RMENU = 0xA5,
VKEY_BROWSER_BACK = 0xA6,
VKEY_BROWSER_FORWARD = 0xA7,
VKEY_BROWSER_REFRESH = 0xA8,
VKEY_BROWSER_STOP = 0xA9,
VKEY_BROWSER_SEARCH = 0xAA,
VKEY_BROWSER_FAVORITES = 0xAB,
VKEY_BROWSER_HOME = 0xAC,
VKEY_VOLUME_MUTE = 0xAD,
VKEY_VOLUME_DOWN = 0xAE,
VKEY_VOLUME_UP = 0xAF,
VKEY_MEDIA_NEXT_TRACK = 0xB0,
VKEY_MEDIA_PREV_TRACK = 0xB1,
VKEY_MEDIA_STOP = 0xB2,
VKEY_MEDIA_PLAY_PAUSE = 0xB3,
VKEY_MEDIA_LAUNCH_MAIL = 0xB4,
VKEY_MEDIA_LAUNCH_MEDIA_SELECT = 0xB5,
VKEY_MEDIA_LAUNCH_APP1 = 0xB6,
VKEY_MEDIA_LAUNCH_APP2 = 0xB7,
VKEY_OEM_1 = 0xBA,
VKEY_OEM_PLUS = 0xBB,
VKEY_OEM_COMMA = 0xBC,
VKEY_OEM_MINUS = 0xBD,
VKEY_OEM_PERIOD = 0xBE,
VKEY_OEM_2 = 0xBF,
VKEY_OEM_3 = 0xC0,
VKEY_OEM_4 = 0xDB,
VKEY_OEM_5 = 0xDC,
VKEY_OEM_6 = 0xDD,
VKEY_OEM_7 = 0xDE,
VKEY_OEM_8 = 0xDF,
VKEY_OEM_102 = 0xE2,
VKEY_OEM_103 = 0xE3, // GTV KEYCODE_MEDIA_REWIND
VKEY_OEM_104 = 0xE4, // GTV KEYCODE_MEDIA_FAST_FORWARD
VKEY_PROCESSKEY = 0xE5,
VKEY_PACKET = 0xE7,
VKEY_DBE_SBCSCHAR = 0xF3,
VKEY_DBE_DBCSCHAR = 0xF4,
VKEY_ATTN = 0xF6,
VKEY_CRSEL = 0xF7,
VKEY_EXSEL = 0xF8,
VKEY_EREOF = 0xF9,
VKEY_PLAY = 0xFA,
VKEY_ZOOM = 0xFB,
VKEY_NONAME = 0xFC,
VKEY_PA1 = 0xFD,
VKEY_OEM_CLEAR = 0xFE,
VKEY_UNKNOWN = 0,
// POSIX specific VKEYs. Note that as of Windows SDK 7.1, 0x97-9F, 0xD8-DA,
// and 0xE8 are unassigned.
VKEY_WLAN = 0x97,
VKEY_POWER = 0x98,
VKEY_BRIGHTNESS_DOWN = 0xD8,
VKEY_BRIGHTNESS_UP = 0xD9,
VKEY_KBD_BRIGHTNESS_DOWN = 0xDA,
VKEY_KBD_BRIGHTNESS_UP = 0xE8,
// Windows does not have a specific key code for AltGr. We use the unused 0xE1
// (VK_OEM_AX) code to represent AltGr, matching the behaviour of Firefox on
// Linux.
VKEY_ALTGR = 0xE1,
// Windows does not have a specific key code for Compose. We use the unused
// 0xE6 (VK_ICO_CLEAR) code to represent Compose.
VKEY_COMPOSE = 0xE6,
} KeyboardCode ;
#include <Elementary.h>
#include <Evas.h>
#define WEIGHT evas_object_size_hint_weight_set
#define ALIGN evas_object_size_hint_align_set
#define EXPAND(X) WEIGHT((X), EVAS_HINT_EXPAND, EVAS_HINT_EXPAND)
#define FILL(X) ALIGN((X), EVAS_HINT_FILL, EVAS_HINT_FILL)
#endif
typedef struct Ref
{
unsigned int count;
void **ptr;
} Ref;
static inline void *
getref(cef_base_t *self)
{
return (char*)self + self->size;
}
static inline void
cef_addref(void *self)
{
Ref *ref = getref(self);
++ref->count;
//fprintf(stderr, "REF(%p) %d\n", self, ref->count);
}
static inline int
cef_delref(void *self)
{
Ref *ref = getref(self);
//fprintf(stderr, "UNREF(%p) %d\n", self, ref->count - 1);
if (!(--ref->count))
{
if (ref->ptr)
*ref->ptr = NULL;
free(self);
return 1;
}
return 0;
}
static inline int
cef_has_one_ref(void *self)
{
Ref *ref = getref(self);
return ref->count == 1;
}
static inline void
cef_init(cef_base_t *base)
{
base->add_ref = (void*)cef_addref;
base->release = (void*)cef_delref;
base->has_one_ref = (void*)cef_has_one_ref;
base->add_ref(base);
}
static inline void *
cef_new(size_t size, void **ptr)
{
cef_base_t *base = calloc(1, size + sizeof(Ref));
Ref *ref;
base->size = size;
cef_init(base);
ref = getref(base);
ref->ptr = ptr;
if (ptr)
*ptr = base;
return base;
}
#ifndef TEST_APP
extern Eina_Bool servo;
extern Eina_Bool gl_avail;
extern Eina_Bool windowed;
extern Eina_List *clients;
typedef struct Browser
{
EINA_INLIST;
cef_browser_t *browser;
Evas_Object *img;
Eina_Stringshare *title;
Eina_Stringshare *url;
Eina_Stringshare *favicon;
Elm_Object_Item *it;
Evas_Object *it_favicon;
Evas_Object *it_clone; //pagelist clone
GLuint program;
GLuint vao;
GLuint vbo;
GLuint vbo2;
GLuint texture_id;
void *buffer;
Evas_GL *gl;
Evas_GL_Config *glcfg;
GLuint fbo;
GLuint tex;
int pw, ph;
Eina_List *clones;
int w, h;
Eina_Bool can_back : 1;
Eina_Bool can_forward : 1;
Eina_Bool loading : 1;
Eina_Bool swapping : 1;
Eina_Bool dialer : 1; //is a dialer browser
Eina_Bool deleted : 1; //is a dialer browser
} Browser;
typedef void (*Browser_Clone_Update_Cb)(Browser *b, Evas_Object *img);
typedef void (*Browser_Created_Cb)(void *data, Browser *b);
typedef struct ECef_Client
{
cef_client_t client;
Evas_Object *win;
Evas_Object *layout;
Evas_Object *pagelist;
Evas_Object *urlbar;
Evas_Object *back, *forward, *reload, *favicon;
Evas_Object *dialer;
Browser *current_page;
Eina_Hash *browsers;
Eina_Inlist *focus_stack;
Eina_List *pending_pages;
Eina_List *create_cbs;
Eina_List *create_datas;
Browser_Clone_Update_Cb clone_update_cb;
cef_render_handler_t *render_handler;
cef_display_handler_t *display_handler;
cef_load_handler_t *load_handler;
cef_window_info_t *window_info;
cef_browser_settings_t *browser_settings;
Eina_Stringshare *status;
Eina_Stringshare *tooltip;
Ecore_Timer *dialer_resize_timer;
Eina_Bool urlbar_changed : 1;
Eina_Bool need_resize : 1;
Eina_Bool urlbar_visible : 1;
Eina_Bool pagelist_visible : 1;
Eina_Bool tooltip_visible : 1;
Eina_Bool dialing : 1;
} ECef_Client;
cef_render_handler_t *client_render_handler_get(cef_client_t *client);
cef_display_handler_t *client_display_handler_get(cef_client_t *client);
cef_load_handler_t *client_load_handler_get(cef_client_t *client);
static inline cef_browser_host_t *
browser_get_host(cef_browser_t *browser)
{
return browser->get_host(browser);
}
static inline ECef_Client *
browser_get_client(cef_browser_t *browser)
{
return (void*)browser_get_host(browser)->get_client(browser_get_host(browser));
}
static inline int
modifiers_get(Evas_Modifier *m) {
int modifiers = 0;
if (evas_key_modifier_is_set(m, "Shift"))
modifiers |= EVENTFLAG_SHIFT_DOWN;
if (evas_key_modifier_is_set(m, "Caps_Lock"))
modifiers |= EVENTFLAG_CAPS_LOCK_ON;
if (evas_key_modifier_is_set(m, "Control"))
modifiers |= EVENTFLAG_CONTROL_DOWN;
if (evas_key_modifier_is_set(m, "Alt"))
modifiers |= EVENTFLAG_ALT_DOWN;
return modifiers;
}
static inline Eina_Bool
is_glview(void)
{
return gl_avail && !windowed;
}
Evas_Object *button_add(Evas_Object *parent, const char *icon, const char *text, const char *style, Evas_Smart_Cb cb, void *data);
void on_after_browser_created(cef_life_span_handler_t *self EINA_UNUSED, cef_browser_t *browser);
void browser_new(ECef_Client *ec, const char *url, Eina_Bool pending, Browser_Created_Cb cb, void *cbdata);
void browser_page_item_add(ECef_Client *ec, Browser *b);
Browser *browser_get(ECef_Client *ec, cef_browser_t *browser);
char *browser_page_string_get(Browser *b);
void browser_window_title_update(ECef_Client *ec);
void browser_set(ECef_Client *ec, Browser *b);
void browser_swap(ECef_Client *ec, Browser *b, Evas_Object *clone);
void browser_favicon_set(ECef_Client *ec, Browser *b, const char *favicon);
void browser_back(cef_browser_t *browser, ...);
void browser_forward(cef_browser_t *browser, ...);
void browser_reload(cef_browser_t *browser, ...);
void browser_urlbar_show(ECef_Client *ec, Eina_Bool changed);
void browser_urlbar_hide(ECef_Client *ec);
void browser_urlbar_set(ECef_Client *ec, const char *url);
void browser_pagelist_show(ECef_Client *ec);
void browser_pagelist_hide(ECef_Client *ec);
Evas_Object *browser_page_content_get(Browser *b, Evas_Object *obj, const char *part);
Evas_Object *browser_tooltip_cb(Browser *b, Evas_Object *obj, Evas_Object *tooltip, Elm_Object_Item *it);
void render_image_new(ECef_Client *ec, Browser *b, cef_browser_host_t *host, int w, int h);
Evas_Object *render_image_clone(Browser *b, Evas_Object *parent);
void dialer_populate(ECef_Client *ec);
void dialer_use(ECef_Client *ec);
void dialer_unuse(ECef_Client *ec);
void dialer_activate_num(ECef_Client *ec, unsigned int n);
void cache_init(void);
Eina_Bool cache_favicon_set(Evas_Object *img, const char *favicon);
void cache_favicon_add(Evas_Object *img, const char *favicon);
# define E_LIST_HANDLER_APPEND(list, type, callback, data) \
do \
{ \
Ecore_Event_Handler *_eh; \
_eh = ecore_event_handler_add(type, (Ecore_Event_Handler_Cb)callback, data); \
assert(_eh); \
list = eina_list_append(list, _eh); \
} \
while (0)
#endif