aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/ecore/src/lib/ecore_win32/ecore_win32.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/ecore/src/lib/ecore_win32/ecore_win32.c')
-rw-r--r--libraries/ecore/src/lib/ecore_win32/ecore_win32.c788
1 files changed, 788 insertions, 0 deletions
diff --git a/libraries/ecore/src/lib/ecore_win32/ecore_win32.c b/libraries/ecore/src/lib/ecore_win32/ecore_win32.c
new file mode 100644
index 0000000..19ca3ed
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_win32/ecore_win32.c
@@ -0,0 +1,788 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <stdlib.h>
6
7#define WIN32_LEAN_AND_MEAN
8#include <windows.h>
9#undef WIN32_LEAN_AND_MEAN
10#include <windowsx.h>
11
12#include <Eina.h>
13#include <Ecore.h>
14#include <Ecore_Input.h>
15
16#include "Ecore_Win32.h"
17#include "ecore_win32_private.h"
18
19/*============================================================================*
20 * Local *
21 *============================================================================*/
22
23/**
24 * @cond LOCAL
25 */
26
27/* OLE IID for Drag'n Drop */
28
29# define INITGUID
30# include <basetyps.h>
31DEFINE_OLEGUID(IID_IEnumFORMATETC, 0x00000103L, 0, 0);
32DEFINE_OLEGUID(IID_IDataObject, 0x0000010EL, 0, 0);
33DEFINE_OLEGUID(IID_IDropSource, 0x00000121L, 0, 0);
34DEFINE_OLEGUID(IID_IDropTarget, 0x00000122L, 0, 0);
35DEFINE_OLEGUID(IID_IUnknown, 0x00000000L, 0, 0);
36
37#define IDI_ICON 101
38
39static int _ecore_win32_init_count = 0;
40
41static void
42_ecore_win32_size_check(Ecore_Win32_Window *win, int w, int h, int *dx, int *dy)
43{
44 int minimal_width;
45 int minimal_height;
46
47 minimal_width = GetSystemMetrics(SM_CXMIN);
48 minimal_height = GetSystemMetrics(SM_CYMIN);
49 if ((w) < MAX(minimal_width, (int)win->min_width))
50 *dx = 0;
51 if ((w) > (int)win->max_width)
52 *dx = 0;
53 if ((h) < MAX(minimal_height, (int)win->min_height))
54 *dy = 0;
55 if ((h) > (int)win->max_height)
56 *dy = 0;
57}
58
59LRESULT CALLBACK
60_ecore_win32_window_procedure(HWND window,
61 UINT message,
62 WPARAM window_param,
63 LPARAM data_param)
64{
65 Ecore_Win32_Callback_Data *data;
66 POINTS point;
67 DWORD coord;
68
69 data = (Ecore_Win32_Callback_Data *)malloc(sizeof(Ecore_Win32_Callback_Data));
70 if (!data) return DefWindowProc(window, message, window_param, data_param);
71
72 data->window = window;
73 data->message = message;
74 data->window_param = window_param;
75 data->data_param = data_param;
76 data->time = GetMessageTime();
77 coord = GetMessagePos();
78 point = MAKEPOINTS(coord);
79 data->x = point.x;
80 data->y = point.y;
81
82 switch (data->message)
83 {
84 /* Keyboard input notifications */
85 case WM_KEYDOWN:
86 case WM_SYSKEYDOWN:
87 INF("keydown message");
88 _ecore_win32_event_handle_key_press(data, 1);
89 return 0;
90 case WM_CHAR:
91 case WM_SYSCHAR:
92 INF("char message");
93 _ecore_win32_event_handle_key_press(data, 0);
94 return 0;
95 case WM_KEYUP:
96 case WM_SYSKEYUP:
97 INF("keyup message");
98 _ecore_win32_event_handle_key_release(data);
99 return 0;
100 case WM_SETFOCUS:
101 INF("setfocus message");
102 _ecore_win32_event_handle_focus_in(data);
103 return 0;
104 case WM_KILLFOCUS:
105 INF("kill focus message");
106 _ecore_win32_event_handle_focus_out(data);
107 return 0;
108 /* Mouse input notifications */
109 case WM_LBUTTONDOWN:
110 INF("left button down message");
111 SetCapture(window);
112 _ecore_win32_event_handle_button_press(data, 1);
113 return 0;
114 case WM_MBUTTONDOWN:
115 INF("middle button down message");
116 _ecore_win32_event_handle_button_press(data, 2);
117 return 0;
118 case WM_RBUTTONDOWN:
119 INF("right button down message");
120 _ecore_win32_event_handle_button_press(data, 3);
121 return 0;
122 case WM_LBUTTONUP:
123 {
124 Ecore_Win32_Window *w = NULL;
125
126 INF("left button up message");
127
128 ReleaseCapture();
129 w = (Ecore_Win32_Window *)GetWindowLongPtr(window, GWLP_USERDATA);
130 if (w->drag.dragging)
131 {
132 w->drag.dragging = 0;
133 return 0;
134 }
135
136 _ecore_win32_event_handle_button_release(data, 1);
137 return 0;
138 }
139 case WM_MBUTTONUP:
140 INF("middle button up message");
141 _ecore_win32_event_handle_button_release(data, 2);
142 return 0;
143 case WM_RBUTTONUP:
144 INF("right button up message");
145 _ecore_win32_event_handle_button_release(data, 3);
146 return 0;
147 case WM_MOUSEMOVE:
148 {
149 RECT rect;
150 Ecore_Win32_Window *w = NULL;
151
152 INF("moue move message");
153
154 w = (Ecore_Win32_Window *)GetWindowLongPtr(window, GWLP_USERDATA);
155
156 if (w->drag.dragging)
157 {
158 POINT pt;
159
160 pt.x = GET_X_LPARAM(data_param);
161 pt.y = GET_Y_LPARAM(data_param);
162 if (ClientToScreen(window, &pt))
163 {
164 if (w->drag.type == HTCAPTION)
165 {
166 int dx;
167 int dy;
168
169 dx = pt.x - w->drag.px;
170 dy = pt.y - w->drag.py;
171 ecore_win32_window_move(w, w->drag.x + dx, w->drag.y + dy);
172 w->drag.x += dx;
173 w->drag.y += dy;
174 w->drag.px = pt.x;
175 w->drag.py = pt.y;
176 return 0;
177 }
178 if (w->drag.type == HTLEFT)
179 {
180 int dw;
181
182 dw = pt.x - w->drag.px;
183 ecore_win32_window_move_resize(w, w->drag.x + dw, w->drag.y, w->drag.w - dw, w->drag.h);
184 w->drag.x += dw;
185 w->drag.w -= dw;
186 w->drag.px = pt.x;
187 w->drag.py = pt.y;
188 return 0;
189 }
190 if (w->drag.type == HTRIGHT)
191 {
192 int dw;
193
194 dw = pt.x - w->drag.px;
195 ecore_win32_window_resize(w, w->drag.w + dw, w->drag.h);
196 w->drag.w += dw;
197 w->drag.px = pt.x;
198 w->drag.py = pt.y;
199 return 0;
200 }
201 if (w->drag.type == HTTOP)
202 {
203 int dh;
204
205 dh = pt.y - w->drag.py;
206 ecore_win32_window_move_resize(w, w->drag.x, w->drag.y + dh, w->drag.w, w->drag.h - dh);
207 w->drag.y += dh;
208 w->drag.h -= dh;
209 w->drag.px = pt.x;
210 w->drag.py = pt.y;
211 return 0;
212 }
213 if (w->drag.type == HTBOTTOM)
214 {
215 int dh;
216
217 dh = pt.y - w->drag.py;
218 ecore_win32_window_resize(w, w->drag.w, w->drag.h + dh);
219 w->drag.h += dh;
220 w->drag.px = pt.x;
221 w->drag.py = pt.y;
222 return 0;
223 }
224 if (w->drag.type == HTTOPLEFT)
225 {
226 int dx;
227 int dy;
228 int dh;
229 int dw;
230
231 dw = pt.x - w->drag.px;
232 dh = pt.y - w->drag.py;
233 dx = dw;
234 dy = dh;
235 _ecore_win32_size_check(w,
236 w->drag.w - dw, w->drag.h - dh,
237 &dx, &dy);
238
239 ecore_win32_window_move_resize(w, w->drag.x + dx, w->drag.y + dy, w->drag.w - dw, w->drag.h - dh);
240 w->drag.x += dx;
241 w->drag.y += dy;
242 w->drag.w -= dw;
243 w->drag.h -= dh;
244 w->drag.px = pt.x;
245 w->drag.py = pt.y;
246 return 0;
247 }
248 if (w->drag.type == HTTOPRIGHT)
249 {
250 int dx;
251 int dy;
252 int dh;
253 int dw;
254
255 dw = pt.x - w->drag.px;
256 dh = pt.y - w->drag.py;
257 dx = dw;
258 dy = dh;
259 _ecore_win32_size_check(w,
260 w->drag.w, w->drag.h - dh,
261 &dx, &dy);
262 ecore_win32_window_move_resize(w, w->drag.x, w->drag.y + dy, w->drag.w, w->drag.h - dh);
263 w->drag.y += dy;
264 w->drag.w += dw;
265 w->drag.h -= dh;
266 w->drag.px = pt.x;
267 w->drag.py = pt.y;
268 return 0;
269 }
270 if (w->drag.type == HTBOTTOMLEFT)
271 {
272 int dx;
273 int dy;
274 int dh;
275 int dw;
276
277 dw = pt.x - w->drag.px;
278 dh = pt.y - w->drag.py;
279 dx = dw;
280 dy = dh;
281 _ecore_win32_size_check(w,
282 w->drag.w - dw, w->drag.h + dh,
283 &dx, &dy);
284 ecore_win32_window_move_resize(w, w->drag.x + dx, w->drag.y, w->drag.w - dw, w->drag.h + dh);
285 w->drag.x += dx;
286 w->drag.w -= dw;
287 w->drag.h += dh;
288 w->drag.px = pt.x;
289 w->drag.py = pt.y;
290 return 0;
291 }
292 if (w->drag.type == HTBOTTOMRIGHT)
293 {
294 int dh;
295 int dw;
296
297 dw = pt.x - w->drag.px;
298 dh = pt.y - w->drag.py;
299 ecore_win32_window_resize(w, w->drag.w + dw, w->drag.h + dh);
300 w->drag.w += dw;
301 w->drag.h += dh;
302 w->drag.px = pt.x;
303 w->drag.py = pt.y;
304 return 0;
305 }
306 }
307 }
308
309 if (GetClientRect(window, &rect))
310 {
311 POINT pt;
312
313 INF("mouse in window");
314
315 pt.x = GET_X_LPARAM(data_param);
316 pt.y = GET_Y_LPARAM(data_param);
317 if (!PtInRect(&rect, pt))
318 {
319 if (w->pointer_is_in)
320 {
321 w->pointer_is_in = 0;
322 _ecore_win32_event_handle_leave_notify(data);
323 }
324 }
325 else
326 {
327 if (!w->pointer_is_in)
328 {
329 w->pointer_is_in = 1;
330 _ecore_win32_event_handle_enter_notify(data);
331 }
332 }
333 }
334 else
335 {
336 ERR("GetClientRect() failed");
337 }
338 _ecore_win32_event_handle_motion_notify(data);
339
340 return 0;
341 }
342 case WM_MOUSEWHEEL:
343 INF("mouse wheel message");
344 _ecore_win32_event_handle_button_press(data, 4);
345 return 0;
346 /* Window notifications */
347 case WM_CREATE:
348 INF("create window message");
349 _ecore_win32_event_handle_create_notify(data);
350 return 0;
351 case WM_DESTROY:
352 INF("destroy window message");
353 _ecore_win32_event_handle_destroy_notify(data);
354 return 0;
355 case WM_SHOWWINDOW:
356 INF("show window message");
357 if ((data->data_param == SW_OTHERUNZOOM) ||
358 (data->data_param == SW_OTHERZOOM))
359 return 0;
360
361 if (data->window_param)
362 _ecore_win32_event_handle_map_notify(data);
363 else
364 _ecore_win32_event_handle_unmap_notify(data);
365
366 return 0;
367 case WM_CLOSE:
368 INF("close window message");
369 _ecore_win32_event_handle_delete_request(data);
370 return 0;
371 case WM_GETMINMAXINFO:
372 INF("get min max info window message");
373 return TRUE;
374 case WM_MOVING:
375 INF("moving window message");
376 _ecore_win32_event_handle_configure_notify(data);
377 return TRUE;
378 case WM_MOVE:
379 INF("move window message");
380 return 0;
381 case WM_SIZING:
382 INF("sizing window message");
383 _ecore_win32_event_handle_resize(data);
384 _ecore_win32_event_handle_configure_notify(data);
385 return TRUE;
386 case WM_SIZE:
387 INF("size window message");
388 return 0;
389/* case WM_WINDOWPOSCHANGING: */
390/* { */
391/* RECT rect; */
392/* GetClientRect(window, &rect); */
393/* printf (" *** ecore message : WINDOWPOSCHANGING %ld %ld\n", */
394/* rect.right - rect.left, rect.bottom - rect.top); */
395/* } */
396/* _ecore_win32_event_handle_configure_notify(data); */
397/* return 0; */
398 case WM_WINDOWPOSCHANGED:
399 INF("position changed window message");
400 _ecore_win32_event_handle_configure_notify(data);
401 _ecore_win32_event_handle_expose(data);
402 return 0;
403 case WM_ENTERSIZEMOVE:
404 INF("enter size move window message");
405 return 0;
406 case WM_EXITSIZEMOVE:
407 INF("exit size move window message");
408 return 0;
409 case WM_NCLBUTTONDOWN:
410 INF("non client left button down window message");
411
412 if (((DWORD)window_param == HTCAPTION) ||
413 ((DWORD)window_param == HTBOTTOM) ||
414 ((DWORD)window_param == HTBOTTOMLEFT) ||
415 ((DWORD)window_param == HTBOTTOMRIGHT) ||
416 ((DWORD)window_param == HTLEFT) ||
417 ((DWORD)window_param == HTRIGHT) ||
418 ((DWORD)window_param == HTTOP) ||
419 ((DWORD)window_param == HTTOPLEFT) ||
420 ((DWORD)window_param == HTTOPRIGHT))
421 {
422 Ecore_Win32_Window *w;
423
424 w = (Ecore_Win32_Window *)GetWindowLongPtr(window, GWLP_USERDATA);
425 ecore_win32_window_geometry_get(w,
426 NULL, NULL,
427 &w->drag.w, &w->drag.h);
428 SetCapture(window);
429 w->drag.type = (DWORD)window_param;
430 w->drag.px = GET_X_LPARAM(data_param);
431 w->drag.py = GET_Y_LPARAM(data_param);
432 w->drag.dragging = 1;
433 return 0;
434 }
435 return DefWindowProc(window, message, window_param, data_param);
436 case WM_SYSCOMMAND:
437 INF("sys command window message %d", (int)window_param);
438
439 if ((((DWORD)window_param & 0xfff0) == SC_MOVE) ||
440 (((DWORD)window_param & 0xfff0) == SC_SIZE))
441 {
442 Ecore_Win32_Window *w;
443
444 INF("sys command MOVE or SIZE window message : %dx%d", GET_X_LPARAM(data_param), GET_Y_LPARAM(data_param));
445
446 w = (Ecore_Win32_Window *)GetWindowLongPtr(window, GWLP_USERDATA);
447 w->drag.dragging = 1;
448 return 0;
449 }
450 return DefWindowProc(window, message, window_param, data_param);
451 /* GDI notifications */
452 case WM_ERASEBKGND:
453 return 1;
454 case WM_PAINT:
455 {
456 RECT rect;
457
458 INF("paint message");
459
460 if (GetUpdateRect(window, &rect, FALSE))
461 {
462 PAINTSTRUCT ps;
463 HDC hdc;
464
465 hdc = BeginPaint(window, &ps);
466 data->update = rect;
467 _ecore_win32_event_handle_expose(data);
468 EndPaint(window, &ps);
469 }
470 return 0;
471 }
472 case WM_SETREDRAW:
473 INF("set redraw message");
474 return 0;
475 case WM_SYNCPAINT:
476 INF("sync paint message");
477 return 0;
478 default:
479 return DefWindowProc(window, message, window_param, data_param);
480 }
481}
482
483/**
484 * @endcond
485 */
486
487
488/*============================================================================*
489 * Global *
490 *============================================================================*/
491
492
493HINSTANCE _ecore_win32_instance = NULL;
494double _ecore_win32_double_click_time = 0.25;
495long _ecore_win32_event_last_time = 0;
496Ecore_Win32_Window *_ecore_win32_event_last_window = NULL;
497int _ecore_win32_log_dom_global = -1;
498
499int ECORE_WIN32_EVENT_MOUSE_IN = 0;
500int ECORE_WIN32_EVENT_MOUSE_OUT = 0;
501int ECORE_WIN32_EVENT_WINDOW_FOCUS_IN = 0;
502int ECORE_WIN32_EVENT_WINDOW_FOCUS_OUT = 0;
503int ECORE_WIN32_EVENT_WINDOW_DAMAGE = 0;
504int ECORE_WIN32_EVENT_WINDOW_CREATE = 0;
505int ECORE_WIN32_EVENT_WINDOW_DESTROY = 0;
506int ECORE_WIN32_EVENT_WINDOW_SHOW = 0;
507int ECORE_WIN32_EVENT_WINDOW_HIDE = 0;
508int ECORE_WIN32_EVENT_WINDOW_CONFIGURE = 0;
509int ECORE_WIN32_EVENT_WINDOW_RESIZE = 0;
510int ECORE_WIN32_EVENT_WINDOW_DELETE_REQUEST = 0;
511
512/*============================================================================*
513 * API *
514 *============================================================================*/
515
516/**
517 * @addtogroup Ecore_Win32_Group Ecore_Win32 library
518 *
519 * Ecore_Win32 is a library that wraps Windows graphic functions
520 * and integrate them nicely into the Ecore main loop.
521 *
522 * @section Ecore_Win32_Sec_Init Initialisation / Shutdown
523 *
524 * To fill...
525 *
526 * @section Ecore_Win32_Sec_Icons How to set icons to an application
527 *
528 * It is possible to also sets the icon of the application easily:
529 *
530 * @li Create an icon with your favorite image creator. The Gimp is a
531 * good choice. Create several images of size 16, 32 and 48. You can
532 * also create images of size 24, 64, 128 and 256. Paste all of them
533 * in the image of size 16 as a layer. Save the image of size 16 with
534 * the name my_icon.ico. Put it where the source code of the
535 * application is located.
536 * @li Create my_icon_rc.rc file with your code editor and add in it:
537 * @code
538 * 101 ICON DISCARDABLE "my_icon.ico"
539 * @endcode
540 * @li With Visual Studio, put that file in the 'Resource file' part
541 * of the project.
542 * @li With MinGW, you have to compile it with windres:
543 * @code
544 * windres my_icon_rc.rc my_icon_rc.o
545 * @endcode
546 * and add my_icon_rc.o to the object files of the application.
547 *
548 * @note The value 101 must not be changed, it's the ID used
549 * internally by Ecore_Win32 to get the icons.
550 *
551 * @{
552 */
553
554/**
555 * @brief Initialize the Ecore_Win32 library.
556 *
557 * @return 1 or greater on success, 0 on error.
558 *
559 * This function sets up the Windows graphic system. It returns 0 on
560 * failure, otherwise it returns the number of times it has already been
561 * called.
562 *
563 * When Ecore_Win32 is not used anymore, call ecore_win32_shutdown()
564 * to shut down the Ecore_Win32 library.
565 */
566EAPI int
567ecore_win32_init()
568{
569 WNDCLASSEX wc;
570 HICON icon;
571 HICON icon_sm;
572
573 if (++_ecore_win32_init_count != 1)
574 return _ecore_win32_init_count;
575
576 if (!eina_init())
577 return --_ecore_win32_init_count;
578
579 _ecore_win32_log_dom_global = eina_log_domain_register
580 ("ecore_win32", ECORE_WIN32_DEFAULT_LOG_COLOR);
581 if (_ecore_win32_log_dom_global < 0)
582 {
583 EINA_LOG_ERR("Ecore_Win32: Could not register log domain");
584 goto shutdown_eina;
585 }
586
587 if (!ecore_event_init())
588 {
589 ERR("Ecore_Win32: Could not init ecore_event");
590 goto unregister_log_domain;
591 }
592
593 _ecore_win32_instance = GetModuleHandle(NULL);
594 if (!_ecore_win32_instance)
595 {
596 ERR("GetModuleHandle() failed");
597 goto shutdown_ecore_event;
598 }
599
600 icon = LoadImage(_ecore_win32_instance,
601 MAKEINTRESOURCE(IDI_ICON),
602 IMAGE_ICON,
603 GetSystemMetrics(SM_CXICON),
604 GetSystemMetrics(SM_CYICON),
605 LR_DEFAULTCOLOR);
606 icon_sm = LoadImage(_ecore_win32_instance,
607 MAKEINTRESOURCE(IDI_ICON),
608 IMAGE_ICON,
609 GetSystemMetrics(SM_CXSMICON),
610 GetSystemMetrics(SM_CYSMICON),
611 LR_DEFAULTCOLOR);
612 if (!icon)
613 icon = LoadIcon (NULL, IDI_APPLICATION);
614 if (!icon_sm)
615 icon_sm = LoadIcon (NULL, IDI_APPLICATION);
616
617 memset (&wc, 0, sizeof (WNDCLASSEX));
618 wc.cbSize = sizeof (WNDCLASSEX);
619 wc.style = CS_HREDRAW | CS_VREDRAW;
620 wc.lpfnWndProc = _ecore_win32_window_procedure;
621 wc.cbClsExtra = 0;
622 wc.cbWndExtra = 0;
623 wc.hInstance = _ecore_win32_instance;
624 wc.hIcon = icon;
625 wc.hCursor = LoadCursor (NULL, IDC_ARROW);
626 wc.hbrBackground = (HBRUSH)(1 + COLOR_BTNFACE);
627 wc.lpszMenuName = NULL;
628 wc.lpszClassName = ECORE_WIN32_WINDOW_CLASS;
629 wc.hIconSm = icon_sm;
630
631 if(!RegisterClassEx(&wc))
632 {
633 ERR("RegisterClass() failed");
634 goto free_library;
635 }
636
637 if (!ecore_win32_dnd_init())
638 {
639 ERR("ecore_win32_dnd_init() failed");
640 goto unregister_class;
641 }
642
643 if (!ECORE_WIN32_EVENT_MOUSE_IN)
644 {
645 ECORE_WIN32_EVENT_MOUSE_IN = ecore_event_type_new();
646 ECORE_WIN32_EVENT_MOUSE_OUT = ecore_event_type_new();
647 ECORE_WIN32_EVENT_WINDOW_FOCUS_IN = ecore_event_type_new();
648 ECORE_WIN32_EVENT_WINDOW_FOCUS_OUT = ecore_event_type_new();
649 ECORE_WIN32_EVENT_WINDOW_DAMAGE = ecore_event_type_new();
650 ECORE_WIN32_EVENT_WINDOW_CREATE = ecore_event_type_new();
651 ECORE_WIN32_EVENT_WINDOW_DESTROY = ecore_event_type_new();
652 ECORE_WIN32_EVENT_WINDOW_SHOW = ecore_event_type_new();
653 ECORE_WIN32_EVENT_WINDOW_HIDE = ecore_event_type_new();
654 ECORE_WIN32_EVENT_WINDOW_CONFIGURE = ecore_event_type_new();
655 ECORE_WIN32_EVENT_WINDOW_RESIZE = ecore_event_type_new();
656 ECORE_WIN32_EVENT_WINDOW_DELETE_REQUEST = ecore_event_type_new();
657 }
658
659 return _ecore_win32_init_count;
660
661 unregister_class:
662 UnregisterClass(ECORE_WIN32_WINDOW_CLASS, _ecore_win32_instance);
663 free_library:
664 FreeLibrary(_ecore_win32_instance);
665 shutdown_ecore_event:
666 ecore_event_shutdown();
667 unregister_log_domain:
668 eina_log_domain_unregister(_ecore_win32_log_dom_global);
669 shutdown_eina:
670 eina_shutdown();
671
672 return --_ecore_win32_init_count;
673}
674
675/**
676 * @brief Shut down the Ecore_Win32 library.
677 *
678 * @return 0 when the library is completely shut down, 1 or
679 * greater otherwise.
680 *
681 * This function shuts down the Ecore_Win32 library. It returns 0 when it has
682 * been called the same number of times than ecore_win32_init(). In that case
683 * it shuts down all the Windows graphic system.
684 */
685EAPI int
686ecore_win32_shutdown()
687{
688 if (--_ecore_win32_init_count != 0)
689 return _ecore_win32_init_count;
690
691 ecore_win32_dnd_shutdown();
692
693 if (!UnregisterClass(ECORE_WIN32_WINDOW_CLASS, _ecore_win32_instance))
694 INF("UnregisterClass() failed");
695
696 if (!FreeLibrary(_ecore_win32_instance))
697 INF("FreeLibrary() failed");
698
699 _ecore_win32_instance = NULL;
700
701 ecore_event_shutdown();
702 eina_log_domain_unregister(_ecore_win32_log_dom_global);
703 _ecore_win32_log_dom_global = -1;
704 eina_shutdown();
705
706 return _ecore_win32_init_count;
707}
708
709/**
710 * @brief Retrieve the depth of the screen.
711 *
712 * @return The depth of the screen.
713 *
714 * This function returns the depth of the screen. If an error occurs,
715 * it returns 0.
716 */
717EAPI int
718ecore_win32_screen_depth_get()
719{
720 HDC dc;
721 int depth;
722
723 INF("getting screen depth");
724
725 dc = GetDC(NULL);
726 if (!dc)
727 {
728 ERR("GetDC() failed");
729 return 0;
730 }
731
732 depth = GetDeviceCaps(dc, BITSPIXEL);
733 if (!ReleaseDC(NULL, dc))
734 {
735 ERR("ReleaseDC() failed (device context not released)");
736 }
737
738 return depth;
739}
740
741/**
742 * @brief Sets the timeout for a double and triple clicks to be flagged.
743 *
744 * @param t The time in seconds.
745 *
746 * This function sets the time @p t between clicks before the
747 * double_click flag is set in a button down event. If 3 clicks occur
748 * within double this time, the triple_click flag is also set.
749 */
750EAPI void
751ecore_win32_double_click_time_set(double t)
752{
753 if (t < 0.0) t = 0.0;
754 _ecore_win32_double_click_time = t;
755}
756
757/**
758 * @brief Retrieve the double and triple click flag timeout.
759 *
760 * @return The timeout for double clicks in seconds.
761 *
762 * This function returns the double clicks in seconds. If
763 * ecore_win32_double_click_time_set() has not been called, the
764 * default value is returned. See ecore_win32_double_click_time_set()
765 * for more informations.
766 */
767EAPI double
768ecore_win32_double_click_time_get(void)
769{
770 return _ecore_win32_double_click_time;
771}
772
773/**
774 * @brief Return the last event time.
775 *
776 * @return The last envent time.
777 *
778 * This function returns the last event time.
779 */
780EAPI long
781ecore_win32_current_time_get(void)
782{
783 return _ecore_win32_event_last_time;
784}
785
786/**
787 * @}
788 */