From 78a2040f2ee794253cef7042510ab42f79cfef9a Mon Sep 17 00:00:00 2001 From: caro Date: Thu, 23 Sep 2010 18:47:40 +0000 Subject: [PATCH] document completely the Ecore_Win32 and Ecore_WinCE git-svn-id: http://svn.enlightenment.org/svn/e/trunk/ecore@52648 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/ecore_win32/Ecore_Win32.h | 381 +++++--- src/lib/ecore_win32/ecore_win32.c | 474 +++++----- src/lib/ecore_win32/ecore_win32_cursor.c | 203 +++- src/lib/ecore_win32/ecore_win32_dnd.c | 123 ++- src/lib/ecore_win32/ecore_win32_window.c | 657 ++++++++++--- src/lib/ecore_wince/Ecore_WinCE.h | 184 +++- src/lib/ecore_wince/ecore_wince.c | 402 ++++---- src/lib/ecore_wince/ecore_wince_event.c | 1520 +++++++++++++++--------------- src/lib/ecore_wince/ecore_wince_window.c | 317 +++++-- 9 files changed, 2689 insertions(+), 1572 deletions(-) diff --git a/src/lib/ecore_win32/Ecore_Win32.h b/src/lib/ecore_win32/Ecore_Win32.h index 090dff5..159c1a0 100644 --- a/src/lib/ecore_win32/Ecore_Win32.h +++ b/src/lib/ecore_win32/Ecore_Win32.h @@ -37,206 +37,310 @@ extern "C" { typedef struct _Ecore_Win32_Window Ecore_Win32_Window; typedef void Ecore_Win32_Cursor; -/* Window state */ - +/** + * @defgroup Ecore_Win32_Group Ecore_Win32 library + * + * @{ + */ + +/** + * @typedef Ecore_Win32_Window_State + * State of a window. + */ typedef enum { - /* The window is iconified. */ - ECORE_WIN32_WINDOW_STATE_ICONIFIED, - /* The window is a modal dialog box. */ - ECORE_WIN32_WINDOW_STATE_MODAL, - /* The window manager should keep the window's position fixed - * even if the virtual desktop scrolls. */ - ECORE_WIN32_WINDOW_STATE_STICKY, - /* The window has the maximum vertical size. */ - ECORE_WIN32_WINDOW_STATE_MAXIMIZED_VERT, - /* The window has the maximum horizontal size. */ - ECORE_WIN32_WINDOW_STATE_MAXIMIZED_HORZ, - /* The window has the maximum horizontal and vertical size. */ - ECORE_WIN32_WINDOW_STATE_MAXIMIZED, - /* The window is shaded. */ - ECORE_WIN32_WINDOW_STATE_SHADED, - /* The window is invisible (i.e. minimized/iconified) */ - ECORE_WIN32_WINDOW_STATE_HIDDEN, - /* The window should fill the entire screen and have no - * window border/decorations */ - ECORE_WIN32_WINDOW_STATE_FULLSCREEN, - /* The following are not documented because they are not - * intended for use in applications. */ - ECORE_WIN32_WINDOW_STATE_ABOVE, - ECORE_WIN32_WINDOW_STATE_BELOW, - /* FIXME: Documentation */ - ECORE_WIN32_WINDOW_STATE_DEMANDS_ATTENTION, - /* Unknown state */ - ECORE_WIN32_WINDOW_STATE_UNKNOWN + ECORE_WIN32_WINDOW_STATE_ICONIFIED, /**< iconified window */ + ECORE_WIN32_WINDOW_STATE_MODAL, /**< modal dialog box */ + ECORE_WIN32_WINDOW_STATE_STICKY, /**< sticky window */ + ECORE_WIN32_WINDOW_STATE_MAXIMIZED_VERT, /**< maximum vertical sized window */ + ECORE_WIN32_WINDOW_STATE_MAXIMIZED_HORZ, /**< maximum horizontal sized window */ + ECORE_WIN32_WINDOW_STATE_MAXIMIZED, /**< maximum sized window */ + ECORE_WIN32_WINDOW_STATE_SHADED, /**< shaded window */ + ECORE_WIN32_WINDOW_STATE_HIDDEN, /**< hidden (minimized or iconified) window */ + ECORE_WIN32_WINDOW_STATE_FULLSCREEN, /**< fullscreen window */ + ECORE_WIN32_WINDOW_STATE_ABOVE, /**< above window */ + ECORE_WIN32_WINDOW_STATE_BELOW, /**< below window */ + ECORE_WIN32_WINDOW_STATE_DEMANDS_ATTENTION, /**< To document */ + ECORE_WIN32_WINDOW_STATE_UNKNOWN /**< Unknown state */ } Ecore_Win32_Window_State; -/* Window type */ - +/** + * @typedef Ecore_Win32_Window_Type + * Type of a window. + */ typedef enum { - /* Desktop feature*/ - ECORE_WIN32_WINDOW_TYPE_DESKTOP, - /* Dock window (should be on top of other windows */ - ECORE_WIN32_WINDOW_TYPE_DOCK, - /* Toolbar window */ - ECORE_WIN32_WINDOW_TYPE_TOOLBAR, - /* Menu window */ - ECORE_WIN32_WINDOW_TYPE_MENU, - /* Small persistent utility window, such as a palette or toolbox */ - ECORE_WIN32_WINDOW_TYPE_UTILITY, - /* Splash screen window displayed as an application is starting up */ - ECORE_WIN32_WINDOW_TYPE_SPLASH, - /* Dialog window */ - ECORE_WIN32_WINDOW_TYPE_DIALOG, - /* Normal top-level window */ - ECORE_WIN32_WINDOW_TYPE_NORMAL, - /* Unknown type */ - ECORE_WIN32_WINDOW_TYPE_UNKNOWN + ECORE_WIN32_WINDOW_TYPE_DESKTOP, /**< Desktop feature */ + ECORE_WIN32_WINDOW_TYPE_DOCK, /**< Dock window (should be on top of other windows) */ + ECORE_WIN32_WINDOW_TYPE_TOOLBAR, /**< Toolbar window */ + ECORE_WIN32_WINDOW_TYPE_MENU, /**< Menu window */ + ECORE_WIN32_WINDOW_TYPE_UTILITY, /**< Small persistent utility window, such as a palette or toolbox */ + ECORE_WIN32_WINDOW_TYPE_SPLASH, /**< Splash screen window displayed as an application is starting up */ + ECORE_WIN32_WINDOW_TYPE_DIALOG, /**< Dialog window */ + ECORE_WIN32_WINDOW_TYPE_NORMAL, /**< Normal top-level window */ + ECORE_WIN32_WINDOW_TYPE_UNKNOWN /**< Unknown type */ } Ecore_Win32_Window_Type; -/*cursor shapes */ - +/** + * @typedef Ecore_Win32_Cursor_Shape + * Shape of a cursor. + */ typedef enum { - ECORE_WIN32_CURSOR_SHAPE_APP_STARTING, /* Standard arrow and small hourglass */ - ECORE_WIN32_CURSOR_SHAPE_ARROW, /* Standard arrow */ - ECORE_WIN32_CURSOR_SHAPE_CROSS, /* Crosshair */ - ECORE_WIN32_CURSOR_SHAPE_HAND, /* Hand */ - ECORE_WIN32_CURSOR_SHAPE_HELP, /* Arrow and question mark */ - ECORE_WIN32_CURSOR_SHAPE_I_BEAM, /* I-beam */ - ECORE_WIN32_CURSOR_SHAPE_NO, /* Slashed circle */ - ECORE_WIN32_CURSOR_SHAPE_SIZE_ALL, /* Four-pointed arrow pointing north, south, east, and west */ - ECORE_WIN32_CURSOR_SHAPE_SIZE_NESW, /* Double-pointed arrow pointing northeast and southwest */ - ECORE_WIN32_CURSOR_SHAPE_SIZE_NS, /* Double-pointed arrow pointing north and south */ - ECORE_WIN32_CURSOR_SHAPE_SIZE_NWSE, /* Double-pointed arrow pointing northwest and southeast */ - ECORE_WIN32_CURSOR_SHAPE_SIZE_WE, /* Double-pointed arrow pointing west and east */ - ECORE_WIN32_CURSOR_SHAPE_UP_ARROW, /* Vertical arrow */ - ECORE_WIN32_CURSOR_SHAPE_WAIT /* Hourglass */ + ECORE_WIN32_CURSOR_SHAPE_APP_STARTING, /**< Standard arrow and small hourglass */ + ECORE_WIN32_CURSOR_SHAPE_ARROW, /**< Standard arrow */ + ECORE_WIN32_CURSOR_SHAPE_CROSS, /**< Crosshair */ + ECORE_WIN32_CURSOR_SHAPE_HAND, /**< Hand */ + ECORE_WIN32_CURSOR_SHAPE_HELP, /**< Arrow and question mark */ + ECORE_WIN32_CURSOR_SHAPE_I_BEAM, /**< I-beam */ + ECORE_WIN32_CURSOR_SHAPE_NO, /**< Slashed circle */ + ECORE_WIN32_CURSOR_SHAPE_SIZE_ALL, /**< Four-pointed arrow pointing north, south, east, and west */ + ECORE_WIN32_CURSOR_SHAPE_SIZE_NESW, /**< Double-pointed arrow pointing northeast and southwest */ + ECORE_WIN32_CURSOR_SHAPE_SIZE_NS, /**< Double-pointed arrow pointing north and south */ + ECORE_WIN32_CURSOR_SHAPE_SIZE_NWSE, /**< Double-pointed arrow pointing northwest and southeast */ + ECORE_WIN32_CURSOR_SHAPE_SIZE_WE, /**< Double-pointed arrow pointing west and east */ + ECORE_WIN32_CURSOR_SHAPE_UP_ARROW, /**< Vertical arrow */ + ECORE_WIN32_CURSOR_SHAPE_WAIT /**< Hourglass */ } Ecore_Win32_Cursor_Shape; -/* Events */ +/** + * @typedef Ecore_Win32_DnD_State + * State of a DnD operation. + */ +typedef enum +{ + ECORE_WIN32_DND_EVENT_DRAG_ENTER = 1, /**< Drag enter */ + ECORE_WIN32_DND_EVENT_DRAG_OVER = 2, /**< Drag over */ + ECORE_WIN32_DND_EVENT_DRAG_LEAVE = 3, /**< Drag leave */ + ECORE_WIN32_DND_EVENT_DROP = 4 /**< Drop */ +} Ecore_Win32_DnD_State; + +/** + * @typedef Ecore_Win32_Event_Mouse_In + * Event sent when the mouse enters the window. + */ typedef struct _Ecore_Win32_Event_Mouse_In Ecore_Win32_Event_Mouse_In; + +/** + * @typedef Ecore_Win32_Event_Mouse_Out + * Event sent when the mouse leaves the window. + */ typedef struct _Ecore_Win32_Event_Mouse_Out Ecore_Win32_Event_Mouse_Out; + +/** + * @typedef Ecore_Win32_Event_Window_Focus_In + * Event sent when the window gets the focus. + */ typedef struct _Ecore_Win32_Event_Window_Focus_In Ecore_Win32_Event_Window_Focus_In; + +/** + * @typedef Ecore_Win32_Event_Window_Focus_Out + * Event sent when the window looses the focus. + */ typedef struct _Ecore_Win32_Event_Window_Focus_Out Ecore_Win32_Event_Window_Focus_Out; + +/** + * @typedef Ecore_Win32_Event_Window_Damage + * Event sent when the window is damaged. + */ typedef struct _Ecore_Win32_Event_Window_Damage Ecore_Win32_Event_Window_Damage; + +/** + * @typedef Ecore_Win32_Event_Window_Create + * Event sent when the window is created. + */ typedef struct _Ecore_Win32_Event_Window_Create Ecore_Win32_Event_Window_Create; + +/** + * @typedef Ecore_Win32_Event_Window_Destroy + * Event sent when the window is destroyed. + */ typedef struct _Ecore_Win32_Event_Window_Destroy Ecore_Win32_Event_Window_Destroy; + +/** + * @typedef Ecore_Win32_Event_Window_Hide + * Event sent when the window is hidden. + */ typedef struct _Ecore_Win32_Event_Window_Hide Ecore_Win32_Event_Window_Hide; + +/** + * @typedef Ecore_Win32_Event_Window_Show + * Event sent when the window is shown. + */ typedef struct _Ecore_Win32_Event_Window_Show Ecore_Win32_Event_Window_Show; + +/** + * @typedef Ecore_Win32_Event_Window_Configure + * Event sent when the window is configured. + */ typedef struct _Ecore_Win32_Event_Window_Configure Ecore_Win32_Event_Window_Configure; + +/** + * @typedef Ecore_Win32_Event_Window_Resize + * Event sent when the window is resized. + */ typedef struct _Ecore_Win32_Event_Window_Resize Ecore_Win32_Event_Window_Resize; + +/** + * @typedef Ecore_Win32_Event_Window_Delete_Request + * Event sent when the window is deleted. + */ typedef struct _Ecore_Win32_Event_Window_Delete_Request Ecore_Win32_Event_Window_Delete_Request; +/** + * @struct _Ecore_Win32_Event_Mouse_In + * Event sent when the mouse enters the window. + */ struct _Ecore_Win32_Event_Mouse_In { - Ecore_Win32_Window *window; - int x; - int y; - long time; + Ecore_Win32_Window *window; /**< The window that received the event */ + int x; /**< The x coordinate where the mouse leaved */ + int y; /**< The y coordinate where the mouse entered */ + long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_Win32_Event_Mouse_Out + * Event sent when the mouse leaves the window. + */ struct _Ecore_Win32_Event_Mouse_Out { - Ecore_Win32_Window *window; - int x; - int y; - long time; + Ecore_Win32_Window *window; /**< The window that received the event */ + int x; /**< The x coordinate where the mouse leaved */ + int y; /**< The y coordinate where the mouse leaved */ + long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_Win32_Event_Window_Focus_In + * Event sent when the window gets the focus. + */ struct _Ecore_Win32_Event_Window_Focus_In { - Ecore_Win32_Window *window; - long long time; + Ecore_Win32_Window *window; /**< The window that received the event */ + long long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_Win32_Event_Window_Focus_Out + * Event sent when the window looses the focus. + */ struct _Ecore_Win32_Event_Window_Focus_Out { - Ecore_Win32_Window *window; - long time; + Ecore_Win32_Window *window; /**< The window that received the event */ + long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_Win32_Event_Window_Damage + * Event sent when the window is damaged. + */ struct _Ecore_Win32_Event_Window_Damage { - Ecore_Win32_Window *window; - int x; - int y; - int width; - int height; - long time; + Ecore_Win32_Window *window; /**< The window that received the event */ + int x; /**< The x coordinate of the top left corner of the damaged region */ + int y; /**< The y coordinate of the top left corner of the damaged region */ + int width; /**< The width of the damaged region */ + int height; /**< The time the event occured */ + long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_Win32_Event_Window_Create + * Event sent when the window is created. + */ struct _Ecore_Win32_Event_Window_Create { - Ecore_Win32_Window *window; - long time; + Ecore_Win32_Window *window; /**< The window that received the event */ + long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_Win32_Event_Window_Destroy + * Event sent when the window is destroyed. + */ struct _Ecore_Win32_Event_Window_Destroy { - Ecore_Win32_Window *window; - long time; + Ecore_Win32_Window *window; /**< The window that received the event */ + long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_Win32_Event_Window_Hide + * Event sent when the window is hidden. + */ struct _Ecore_Win32_Event_Window_Hide { - Ecore_Win32_Window *window; - long time; + Ecore_Win32_Window *window; /**< The window that received the event */ + long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_Win32_Event_Window_Show + * Event sent when the window is shown. + */ struct _Ecore_Win32_Event_Window_Show { - Ecore_Win32_Window *window; - long time; + Ecore_Win32_Window *window; /**< The window that received the event */ + long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_Win32_Event_Window_Configure + * Event sent when the window is configured. + */ struct _Ecore_Win32_Event_Window_Configure { - Ecore_Win32_Window *window; + Ecore_Win32_Window *window; /**< The window that received the event */ Ecore_Win32_Window *abovewin; - int x; - int y; - int width; - int height; - long time; + int x; /**< The new x coordinate of the top left corner */ + int y; /**< The new y coordinate of the top left corner */ + int width; /**< The new width */ + int height; /**< The new height */ + long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_Win32_Event_Window_Resize + * Event sent when the window is resized. + */ struct _Ecore_Win32_Event_Window_Resize { - Ecore_Win32_Window *window; - int width; - int height; - long time; + Ecore_Win32_Window *window; /**< The window that received the event */ + int width; /**< The new width */ + int height; /**< The new height */ + long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_Win32_Event_Window_Delete_Request + * Event sent when the window is deleted. + */ struct _Ecore_Win32_Event_Window_Delete_Request { - Ecore_Win32_Window *window; - long time; + Ecore_Win32_Window *window; /**< The window that received the event */ + long time; /**< The time the event occured */ }; -#define ECORE_WIN32_DND_EVENT_DRAG_ENTER 1 -#define ECORE_WIN32_DND_EVENT_DRAG_OVER 2 -#define ECORE_WIN32_DND_EVENT_DRAG_LEAVE 3 -#define ECORE_WIN32_DND_EVENT_DROP 4 - - +/** + * @typedef Ecore_Win32_Dnd_DropTarget_Callback + * Callback type for Drop operations. See ecore_win32_dnd_register_drop_target(). + */ typedef int (*Ecore_Win32_Dnd_DropTarget_Callback)(void *window, int event, int pt_x, int pt_y, void *data, int size); -EAPI extern int ECORE_WIN32_EVENT_MOUSE_IN; -EAPI extern int ECORE_WIN32_EVENT_MOUSE_OUT; -EAPI extern int ECORE_WIN32_EVENT_WINDOW_FOCUS_IN; -EAPI extern int ECORE_WIN32_EVENT_WINDOW_FOCUS_OUT; -EAPI extern int ECORE_WIN32_EVENT_WINDOW_DAMAGE; -EAPI extern int ECORE_WIN32_EVENT_WINDOW_CREATE; -EAPI extern int ECORE_WIN32_EVENT_WINDOW_DESTROY; -EAPI extern int ECORE_WIN32_EVENT_WINDOW_HIDE; -EAPI extern int ECORE_WIN32_EVENT_WINDOW_SHOW; -EAPI extern int ECORE_WIN32_EVENT_WINDOW_CONFIGURE; -EAPI extern int ECORE_WIN32_EVENT_WINDOW_RESIZE; -EAPI extern int ECORE_WIN32_EVENT_WINDOW_DELETE_REQUEST; +EAPI extern int ECORE_WIN32_EVENT_MOUSE_IN; /**< Ecore_Event for the #Ecore_Win32_Event_Mouse_In event */ +EAPI extern int ECORE_WIN32_EVENT_MOUSE_OUT; /**< Ecore_Event for the #Ecore_Win32_Event_Mouse_Out event */ +EAPI extern int ECORE_WIN32_EVENT_WINDOW_FOCUS_IN; /**< Ecore_Event for the #Ecore_Win32_Event_Window_Focus_In event */ +EAPI extern int ECORE_WIN32_EVENT_WINDOW_FOCUS_OUT; /**< Ecore_Event for the #Ecore_Win32_Event_Window_Focus_Out event */ +EAPI extern int ECORE_WIN32_EVENT_WINDOW_DAMAGE; /**< Ecore_Event for the #Ecore_Win32_Event_Damage event */ +EAPI extern int ECORE_WIN32_EVENT_WINDOW_CREATE; /**< Ecore_Event for the #Ecore_Win32_Event_Create event */ +EAPI extern int ECORE_WIN32_EVENT_WINDOW_DESTROY; /**< Ecore_Event for the #Ecore_Win32_Event_Destroy event */ +EAPI extern int ECORE_WIN32_EVENT_WINDOW_HIDE; /**< Ecore_Event for the #Ecore_Win32_Event_Hide event */ +EAPI extern int ECORE_WIN32_EVENT_WINDOW_SHOW; /**< Ecore_Event for the #Ecore_Win32_Event_Show event */ +EAPI extern int ECORE_WIN32_EVENT_WINDOW_CONFIGURE; /**< Ecore_Event for the #Ecore_Win32_Event_Configure event *> +EAPI extern int ECORE_WIN32_EVENT_WINDOW_RESIZE; /**< Ecore_Event for the #Ecore_Win32_Event_Resize event *> +EAPI extern int ECORE_WIN32_EVENT_WINDOW_DELETE_REQUEST; /**< Ecore_Event for the #Ecore_Win32_Event_Window_Delete_Request event */ /* Core */ @@ -244,8 +348,9 @@ EAPI extern int ECORE_WIN32_EVENT_WINDOW_DELETE_REQUEST; EAPI int ecore_win32_init(); EAPI int ecore_win32_shutdown(); EAPI int ecore_win32_screen_depth_get(); +EAPI void ecore_win32_double_click_time_set(double t); +EAPI double ecore_win32_double_click_time_get(void); EAPI long ecore_win32_current_time_get(void); -EAPI void ecore_win32_message_loop_begin (void); /* Window */ @@ -334,13 +439,13 @@ EAPI void ecore_win32_window_title_set(Ecore_Win32_Window *window, EAPI void ecore_win32_window_focus_set(Ecore_Win32_Window *window); EAPI void ecore_win32_window_iconified_set(Ecore_Win32_Window *window, - int on); + Eina_Bool on); EAPI void ecore_win32_window_borderless_set(Ecore_Win32_Window *window, - int on); + Eina_Bool on); EAPI void ecore_win32_window_fullscreen_set(Ecore_Win32_Window *window, - int on); + Eina_Bool on); EAPI void ecore_win32_window_shape_set(Ecore_Win32_Window *window, unsigned short width, @@ -372,20 +477,24 @@ EAPI Ecore_Win32_Cursor *ecore_win32_cursor_new(const void *pixels_and, EAPI void ecore_win32_cursor_free(Ecore_Win32_Cursor *cursor); -EAPI Ecore_Win32_Cursor *ecore_win32_cursor_shape_get(Ecore_Win32_Cursor_Shape shape); +EAPI Ecore_Win32_Cursor *ecore_win32_cursor_shaped_new(Ecore_Win32_Cursor_Shape shape); -EAPI int ecore_win32_cursor_size_get(void); +EAPI void ecore_win32_cursor_size_get(int *width, int *height); /* Drag and drop */ -EAPI int ecore_win32_dnd_init(); -EAPI int ecore_win32_dnd_shutdown(); -EAPI int ecore_win32_dnd_begin(const char *data, - int size); -EAPI int ecore_win32_dnd_register_drop_target(Ecore_Win32_Window *window, - Ecore_Win32_Dnd_DropTarget_Callback callback); -EAPI void ecore_win32_dnd_unregister_drop_target(Ecore_Win32_Window *window); +EAPI int ecore_win32_dnd_init(); +EAPI int ecore_win32_dnd_shutdown(); +EAPI Eina_Bool ecore_win32_dnd_begin(const char *data, + int size); +EAPI Eina_Bool ecore_win32_dnd_register_drop_target(Ecore_Win32_Window *window, + Ecore_Win32_Dnd_DropTarget_Callback callback); +EAPI void ecore_win32_dnd_unregister_drop_target(Ecore_Win32_Window *window); + +/** + * @} + */ #ifdef __cplusplus diff --git a/src/lib/ecore_win32/ecore_win32.c b/src/lib/ecore_win32/ecore_win32.c index 7217209..f10407b 100644 --- a/src/lib/ecore_win32/ecore_win32.c +++ b/src/lib/ecore_win32/ecore_win32.c @@ -17,6 +17,13 @@ #include "Ecore_Win32.h" #include "ecore_win32_private.h" +/*============================================================================* + * Local * + *============================================================================*/ + +/** + * @cond LOCAL + */ /* OLE IID for Drag'n Drop */ @@ -28,219 +35,8 @@ DEFINE_OLEGUID(IID_IDropSource, 0x00000121L, 0, 0); DEFINE_OLEGUID(IID_IDropTarget, 0x00000122L, 0, 0); DEFINE_OLEGUID(IID_IUnknown, 0x00000000L, 0, 0); - -/***** Global declarations *****/ - -HINSTANCE _ecore_win32_instance = NULL; -double _ecore_win32_double_click_time = 0.25; -long _ecore_win32_event_last_time = 0; -Ecore_Win32_Window *_ecore_win32_event_last_window = NULL; -int _ecore_win32_log_dom_global = -1; - -int ECORE_WIN32_EVENT_MOUSE_IN = 0; -int ECORE_WIN32_EVENT_MOUSE_OUT = 0; -int ECORE_WIN32_EVENT_WINDOW_FOCUS_IN = 0; -int ECORE_WIN32_EVENT_WINDOW_FOCUS_OUT = 0; -int ECORE_WIN32_EVENT_WINDOW_DAMAGE = 0; -int ECORE_WIN32_EVENT_WINDOW_CREATE = 0; -int ECORE_WIN32_EVENT_WINDOW_DESTROY = 0; -int ECORE_WIN32_EVENT_WINDOW_SHOW = 0; -int ECORE_WIN32_EVENT_WINDOW_HIDE = 0; -int ECORE_WIN32_EVENT_WINDOW_CONFIGURE = 0; -int ECORE_WIN32_EVENT_WINDOW_RESIZE = 0; -int ECORE_WIN32_EVENT_WINDOW_DELETE_REQUEST = 0; - - -/***** Private declarations *****/ - static int _ecore_win32_init_count = 0; -LRESULT CALLBACK _ecore_win32_window_procedure(HWND window, - UINT message, - WPARAM window_param, - LPARAM data_param); - - -/***** API *****/ - - -int -ecore_win32_init() -{ - WNDCLASS wc; - - if (++_ecore_win32_init_count != 1) - return _ecore_win32_init_count; - - if (!eina_init()) - return --_ecore_win32_init_count; - - _ecore_win32_log_dom_global = eina_log_domain_register("ecore_win32", ECORE_WIN32_DEFAULT_LOG_COLOR); - if (_ecore_win32_log_dom_global < 0) - { - EINA_LOG_ERR("Ecore_Win32: Could not register log domain"); - goto shutdown_eina; - } - - if (!ecore_event_init()) - { - ERR("Ecore_Win32: Could not init ecore_event"); - goto unregister_log_domain; - } - - _ecore_win32_instance = GetModuleHandle(NULL); - if (!_ecore_win32_instance) - { - ERR("GetModuleHandle() failed"); - goto shutdown_ecore_event; - } - - memset (&wc, 0, sizeof (WNDCLASS)); - wc.style = CS_HREDRAW | CS_VREDRAW; - wc.lpfnWndProc = _ecore_win32_window_procedure; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = _ecore_win32_instance; - wc.hIcon = LoadIcon (NULL, IDI_APPLICATION); - wc.hCursor = LoadCursor (NULL, IDC_ARROW); - wc.hbrBackground = (HBRUSH)(1 + COLOR_BTNFACE); - wc.lpszMenuName = NULL; - wc.lpszClassName = ECORE_WIN32_WINDOW_CLASS; - - if(!RegisterClass(&wc)) - { - ERR("RegisterClass() failed"); - goto free_library; - } - - if (!ecore_win32_dnd_init()) - { - ERR("ecore_win32_dnd_init() failed"); - goto unregister_class; - } - - if (!ECORE_WIN32_EVENT_MOUSE_IN) - { - ECORE_WIN32_EVENT_MOUSE_IN = ecore_event_type_new(); - ECORE_WIN32_EVENT_MOUSE_OUT = ecore_event_type_new(); - ECORE_WIN32_EVENT_WINDOW_FOCUS_IN = ecore_event_type_new(); - ECORE_WIN32_EVENT_WINDOW_FOCUS_OUT = ecore_event_type_new(); - ECORE_WIN32_EVENT_WINDOW_DAMAGE = ecore_event_type_new(); - ECORE_WIN32_EVENT_WINDOW_CREATE = ecore_event_type_new(); - ECORE_WIN32_EVENT_WINDOW_DESTROY = ecore_event_type_new(); - ECORE_WIN32_EVENT_WINDOW_SHOW = ecore_event_type_new(); - ECORE_WIN32_EVENT_WINDOW_HIDE = ecore_event_type_new(); - ECORE_WIN32_EVENT_WINDOW_CONFIGURE = ecore_event_type_new(); - ECORE_WIN32_EVENT_WINDOW_RESIZE = ecore_event_type_new(); - ECORE_WIN32_EVENT_WINDOW_DELETE_REQUEST = ecore_event_type_new(); - } - - return _ecore_win32_init_count; - - unregister_class: - UnregisterClass(ECORE_WIN32_WINDOW_CLASS, _ecore_win32_instance); - free_library: - FreeLibrary(_ecore_win32_instance); - shutdown_ecore_event: - ecore_event_shutdown(); - unregister_log_domain: - eina_log_domain_unregister(_ecore_win32_log_dom_global); - shutdown_eina: - eina_shutdown(); - - return --_ecore_win32_init_count; -} - -int -ecore_win32_shutdown() -{ - if (--_ecore_win32_init_count != 0) - return _ecore_win32_init_count; - - ecore_win32_dnd_shutdown(); - - if (!UnregisterClass(ECORE_WIN32_WINDOW_CLASS, _ecore_win32_instance)) - INF("UnregisterClass() failed"); - - if (!FreeLibrary(_ecore_win32_instance)) - INF("FreeLibrary() failed"); - - _ecore_win32_instance = NULL; - - ecore_event_shutdown(); - eina_log_domain_unregister(_ecore_win32_log_dom_global); - _ecore_win32_log_dom_global = -1; - eina_shutdown(); - - return _ecore_win32_init_count; -} - -int -ecore_win32_screen_depth_get() -{ - HDC dc; - int depth; - - INF("getting screen depth"); - - dc = GetDC(NULL); - if (!dc) - { - ERR("GetDC() failed"); - return 0; - } - - depth = GetDeviceCaps(dc, BITSPIXEL); - if (!ReleaseDC(NULL, dc)) - { - ERR("ReleaseDC() failed (device context not released)"); - } - - return depth; -} - -/** - * Sets the timeout for a double and triple clicks to be flagged. - * - * This sets the time between clicks before the double_click flag is - * set in a button down event. If 3 clicks occur within double this - * time, the triple_click flag is also set. - * - * @param t The time in seconds - */ -void -ecore_win32_double_click_time_set(double t) -{ - if (t < 0.0) t = 0.0; - _ecore_win32_double_click_time = t; -} - -/** - * Retrieves the double and triple click flag timeout. - * - * See @ref ecore_win32_double_click_time_set for more information. - * - * @return The timeout for double clicks in seconds. - */ -double -ecore_win32_double_click_time_get(void) -{ - return _ecore_win32_double_click_time; -} - -/** - * Return the last event time - */ -long -ecore_win32_current_time_get(void) -{ - return _ecore_win32_event_last_time; -} - - -/***** Private functions definitions *****/ - - LRESULT CALLBACK _ecore_win32_window_procedure(HWND window, UINT message, @@ -424,3 +220,259 @@ _ecore_win32_window_procedure(HWND window, return DefWindowProc(window, message, window_param, data_param); } } + +/** + * @endcond + */ + + +/*============================================================================* + * Global * + *============================================================================*/ + + +HINSTANCE _ecore_win32_instance = NULL; +double _ecore_win32_double_click_time = 0.25; +long _ecore_win32_event_last_time = 0; +Ecore_Win32_Window *_ecore_win32_event_last_window = NULL; +int _ecore_win32_log_dom_global = -1; + +int ECORE_WIN32_EVENT_MOUSE_IN = 0; +int ECORE_WIN32_EVENT_MOUSE_OUT = 0; +int ECORE_WIN32_EVENT_WINDOW_FOCUS_IN = 0; +int ECORE_WIN32_EVENT_WINDOW_FOCUS_OUT = 0; +int ECORE_WIN32_EVENT_WINDOW_DAMAGE = 0; +int ECORE_WIN32_EVENT_WINDOW_CREATE = 0; +int ECORE_WIN32_EVENT_WINDOW_DESTROY = 0; +int ECORE_WIN32_EVENT_WINDOW_SHOW = 0; +int ECORE_WIN32_EVENT_WINDOW_HIDE = 0; +int ECORE_WIN32_EVENT_WINDOW_CONFIGURE = 0; +int ECORE_WIN32_EVENT_WINDOW_RESIZE = 0; +int ECORE_WIN32_EVENT_WINDOW_DELETE_REQUEST = 0; + +/*============================================================================* + * API * + *============================================================================*/ + +/** + * @addtogroup Ecore_Win32_Group Ecore_Win32 library + * + * Ecore_Win32 is a library that wraps Windows graphic functions + * and integrate them nicely into the Ecore main loop. + * + * @{ + */ + +/** + * @brief Initialize the Ecore_Win32 library. + * + * @return 1 or greater on success, 0 on error. + * + * This function sets up the Windows graphic system. It returns 0 on + * failure, otherwise it returns the number of times it has already been + * called. + * + * When Ecore_Win32 is not used anymore, call ecore_win32_shutdown() + * to shut down the Ecore_Win32 library. + */ +EAPI int +ecore_win32_init() +{ + WNDCLASS wc; + + if (++_ecore_win32_init_count != 1) + return _ecore_win32_init_count; + + if (!eina_init()) + return --_ecore_win32_init_count; + + _ecore_win32_log_dom_global = eina_log_domain_register("ecore_win32", ECORE_WIN32_DEFAULT_LOG_COLOR); + if (_ecore_win32_log_dom_global < 0) + { + EINA_LOG_ERR("Ecore_Win32: Could not register log domain"); + goto shutdown_eina; + } + + if (!ecore_event_init()) + { + ERR("Ecore_Win32: Could not init ecore_event"); + goto unregister_log_domain; + } + + _ecore_win32_instance = GetModuleHandle(NULL); + if (!_ecore_win32_instance) + { + ERR("GetModuleHandle() failed"); + goto shutdown_ecore_event; + } + + memset (&wc, 0, sizeof (WNDCLASS)); + wc.style = CS_HREDRAW | CS_VREDRAW; + wc.lpfnWndProc = _ecore_win32_window_procedure; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = _ecore_win32_instance; + wc.hIcon = LoadIcon (NULL, IDI_APPLICATION); + wc.hCursor = LoadCursor (NULL, IDC_ARROW); + wc.hbrBackground = (HBRUSH)(1 + COLOR_BTNFACE); + wc.lpszMenuName = NULL; + wc.lpszClassName = ECORE_WIN32_WINDOW_CLASS; + + if(!RegisterClass(&wc)) + { + ERR("RegisterClass() failed"); + goto free_library; + } + + if (!ecore_win32_dnd_init()) + { + ERR("ecore_win32_dnd_init() failed"); + goto unregister_class; + } + + if (!ECORE_WIN32_EVENT_MOUSE_IN) + { + ECORE_WIN32_EVENT_MOUSE_IN = ecore_event_type_new(); + ECORE_WIN32_EVENT_MOUSE_OUT = ecore_event_type_new(); + ECORE_WIN32_EVENT_WINDOW_FOCUS_IN = ecore_event_type_new(); + ECORE_WIN32_EVENT_WINDOW_FOCUS_OUT = ecore_event_type_new(); + ECORE_WIN32_EVENT_WINDOW_DAMAGE = ecore_event_type_new(); + ECORE_WIN32_EVENT_WINDOW_CREATE = ecore_event_type_new(); + ECORE_WIN32_EVENT_WINDOW_DESTROY = ecore_event_type_new(); + ECORE_WIN32_EVENT_WINDOW_SHOW = ecore_event_type_new(); + ECORE_WIN32_EVENT_WINDOW_HIDE = ecore_event_type_new(); + ECORE_WIN32_EVENT_WINDOW_CONFIGURE = ecore_event_type_new(); + ECORE_WIN32_EVENT_WINDOW_RESIZE = ecore_event_type_new(); + ECORE_WIN32_EVENT_WINDOW_DELETE_REQUEST = ecore_event_type_new(); + } + + return _ecore_win32_init_count; + + unregister_class: + UnregisterClass(ECORE_WIN32_WINDOW_CLASS, _ecore_win32_instance); + free_library: + FreeLibrary(_ecore_win32_instance); + shutdown_ecore_event: + ecore_event_shutdown(); + unregister_log_domain: + eina_log_domain_unregister(_ecore_win32_log_dom_global); + shutdown_eina: + eina_shutdown(); + + return --_ecore_win32_init_count; +} + +/** + * @brief Shut down the Ecore_Win32 library. + * + * @return 0 when the library is completely shut down, 1 or + * greater otherwise. + * + * This function shuts down the Ecore_Win32 library. It returns 0 when it has + * been called the same number of times than ecore_win32_init(). In that case + * it shut down all the Windows graphic system. + */ +EAPI int +ecore_win32_shutdown() +{ + if (--_ecore_win32_init_count != 0) + return _ecore_win32_init_count; + + ecore_win32_dnd_shutdown(); + + if (!UnregisterClass(ECORE_WIN32_WINDOW_CLASS, _ecore_win32_instance)) + INF("UnregisterClass() failed"); + + if (!FreeLibrary(_ecore_win32_instance)) + INF("FreeLibrary() failed"); + + _ecore_win32_instance = NULL; + + ecore_event_shutdown(); + eina_log_domain_unregister(_ecore_win32_log_dom_global); + _ecore_win32_log_dom_global = -1; + eina_shutdown(); + + return _ecore_win32_init_count; +} + +/** + * @brief Retrieve the depth of the screen. + * + * @return The depth of the screen. + * + * This function returns the depth of the screen. If an error occurs, + * it returns 0. + */ +EAPI int +ecore_win32_screen_depth_get() +{ + HDC dc; + int depth; + + INF("getting screen depth"); + + dc = GetDC(NULL); + if (!dc) + { + ERR("GetDC() failed"); + return 0; + } + + depth = GetDeviceCaps(dc, BITSPIXEL); + if (!ReleaseDC(NULL, dc)) + { + ERR("ReleaseDC() failed (device context not released)"); + } + + return depth; +} + +/** + * @brief Sets the timeout for a double and triple clicks to be flagged. + * + * @param t The time in seconds. + * + * This function sets the time @p t between clicks before the + * double_click flag is set in a button down event. If 3 clicks occur + * within double this time, the triple_click flag is also set. + */ +EAPI void +ecore_win32_double_click_time_set(double t) +{ + if (t < 0.0) t = 0.0; + _ecore_win32_double_click_time = t; +} + +/** + * @brief Retrieve the double and triple click flag timeout. + * + * @return The timeout for double clicks in seconds. + * + * This function returns the double clicks in seconds. If + * ecore_win32_double_click_time_set() has not been called, the + * default value is returned. See ecore_win32_double_click_time_set() + * for more informations. + */ +EAPI double +ecore_win32_double_click_time_get(void) +{ + return _ecore_win32_double_click_time; +} + +/** + * @brief Return the last event time. + * + * @return The last envent time. + * + * This function returns the last event time. + */ +EAPI long +ecore_win32_current_time_get(void) +{ + return _ecore_win32_event_last_time; +} + +/** + * @} + */ diff --git a/src/lib/ecore_win32/ecore_win32_cursor.c b/src/lib/ecore_win32/ecore_win32_cursor.c index 08d2a30..c072519 100644 --- a/src/lib/ecore_win32/ecore_win32_cursor.c +++ b/src/lib/ecore_win32/ecore_win32_cursor.c @@ -11,10 +11,156 @@ #include "Ecore_Win32.h" #include "ecore_win32_private.h" +/*============================================================================* + * Local * + *============================================================================*/ -/***** API *****/ -Ecore_Win32_Cursor * +/*============================================================================* + * Global * + *============================================================================*/ + + +/*============================================================================* + * API * + *============================================================================*/ + +/** + * @addtogroup Ecore_Win32_Group Ecore_Win32 library + * + * @{ + */ + +/** + * @brief Create a new cursor. + * + * @param pixels_and The array of bytes containing the bit values for + * the AND mask of the cursor. + * @param pixels_xor The array of bytes containing the bit values for + * the XOR mask of the cursor. + * @param width The width of the cursor. + * @param height The height of the cursor. + * @param hot_x The horizontal position of the cursor's hot spot. + * @param hot_y The vertical position of the cursor's hot spot. + * @return A newly user-defined cursor. + * + * This function creates a new cursor of size @p width and @p + * height. They must be valid size. To determine the valid size of a + * cursor, useecore_win32_cursor_size_get(). @p pixels_and is an array + * of bytes (unsigned char) containing the bits of the cursor that + * will be visible. @p pixels_xor is similar but will allow the cursor + * to have a shape. Here is the truth table for the masks: + * + * + * + * + * + * + * + *
AND maskXOR maskDisplay
0 0 Black
0 1 White
1 0 Screen
1 1 Reverse screen
+ * + * @p hot_x and @p hot_y are the position of the hot spot of the + * cursor. If @p pixels_and or @p pixels_xor are @c NULL, the function + * returns NULL. If @p width or @p height does not match the valid + * size of a cursor, the function returns @c NULL. On success, the + * function creates a user-defined cursor, otherwise it returns + * @c NULL. + * + * Once the cursor is not used anymore, use ecore_win32_cursor_free() + * to free the ressources. + * + * Example of use: + * + * @code + * unsigned char pixels_and[] ={ + * 0xFF, 0xFC, 0x3F, 0xFF, // line 1 + * 0xFF, 0xC0, 0x1F, 0xFF, // line 2 + * 0xFF, 0x00, 0x3F, 0xFF, // line 3 + * 0xFE, 0x00, 0xFF, 0xFF, // line 4 + * + * 0xF7, 0x01, 0xFF, 0xFF, // line 5 + * 0xF0, 0x03, 0xFF, 0xFF, // line 6 + * 0xF0, 0x03, 0xFF, 0xFF, // line 7 + * 0xE0, 0x07, 0xFF, 0xFF, // line 8 + * + * 0xC0, 0x07, 0xFF, 0xFF, // line 9 + * 0xC0, 0x0F, 0xFF, 0xFF, // line 10 + * 0x80, 0x0F, 0xFF, 0xFF, // line 11 + * 0x80, 0x0F, 0xFF, 0xFF, // line 12 + * + * 0x80, 0x07, 0xFF, 0xFF, // line 13 + * 0x00, 0x07, 0xFF, 0xFF, // line 14 + * 0x00, 0x03, 0xFF, 0xFF, // line 15 + * 0x00, 0x00, 0xFF, 0xFF, // line 16 + * + * 0x00, 0x00, 0x7F, 0xFF, // line 17 + * 0x00, 0x00, 0x1F, 0xFF, // line 18 + * 0x00, 0x00, 0x0F, 0xFF, // line 19 + * 0x80, 0x00, 0x0F, 0xFF, // line 20 + * + * 0x80, 0x00, 0x07, 0xFF, // line 21 + * 0x80, 0x00, 0x07, 0xFF, // line 22 + * 0xC0, 0x00, 0x07, 0xFF, // line 23 + * 0xC0, 0x00, 0x0F, 0xFF, // line 24 + * + * 0xE0, 0x00, 0x0F, 0xFF, // line 25 + * 0xF0, 0x00, 0x1F, 0xFF, // line 26 + * 0xF0, 0x00, 0x1F, 0xFF, // line 27 + * 0xF8, 0x00, 0x3F, 0xFF, // line 28 + * + * 0xFE, 0x00, 0x7F, 0xFF, // line 29 + * 0xFF, 0x00, 0xFF, 0xFF, // line 30 + * 0xFF, 0xC3, 0xFF, 0xFF, // line 31 + * 0xFF, 0xFF, 0xFF, 0xFF // line 32 + * }; + * + * unsigned char pixels_xor[] = + * { + * 0x00, 0x00, 0x00, 0x00, // line 1 + * 0x00, 0x03, 0xC0, 0x00, // line 2 + * 0x00, 0x3F, 0x00, 0x00, // line 3 + * 0x00, 0xFE, 0x00, 0x00, // line 4 + * + * 0x0E, 0xFC, 0x00, 0x00, // line 5 + * 0x07, 0xF8, 0x00, 0x00, // line 6 + * 0x07, 0xF8, 0x00, 0x00, // line 7 + * 0x0F, 0xF0, 0x00, 0x00, // line 8 + * + * 0x1F, 0xF0, 0x00, 0x00, // line 9 + * 0x1F, 0xE0, 0x00, 0x00, // line 10 + * 0x3F, 0xE0, 0x00, 0x00, // line 11 + * 0x3F, 0xE0, 0x00, 0x00, // line 12 + * + * 0x3F, 0xF0, 0x00, 0x00, // line 13 + * 0x7F, 0xF0, 0x00, 0x00, // line 14 + * 0x7F, 0xF8, 0x00, 0x00, // line 15 + * 0x7F, 0xFC, 0x00, 0x00, // line 16 + * + * 0x7F, 0xFF, 0x00, 0x00, // line 17 + * 0x7F, 0xFF, 0x80, 0x00, // line 18 + * 0x7F, 0xFF, 0xE0, 0x00, // line 19 + * 0x3F, 0xFF, 0xE0, 0x00, // line 20 + * + * 0x3F, 0xC7, 0xF0, 0x00, // line 21 + * 0x3F, 0x83, 0xF0, 0x00, // line 22 + * 0x1F, 0x83, 0xF0, 0x00, // line 23 + * 0x1F, 0x83, 0xE0, 0x00, // line 24 + * + * 0x0F, 0xC7, 0xE0, 0x00, // line 25 + * 0x07, 0xFF, 0xC0, 0x00, // line 26 + * 0x07, 0xFF, 0xC0, 0x00, // line 27 + * 0x01, 0xFF, 0x80, 0x00, // line 28 + * + * 0x00, 0xFF, 0x00, 0x00, // line 29 + * 0x00, 0x3C, 0x00, 0x00, // line 30 + * 0x00, 0x00, 0x00, 0x00, // line 31 + * 0x00, 0x00, 0x00, 0x00 // line 32 + * }; + * + * Ecore_Win32_Cursor cursor = ecore_win32_cursor_new(pixels_and, pixels_xor, 32, 32, 19, 2); + * @endcode + */ +EAPI Ecore_Win32_Cursor * ecore_win32_cursor_new(const void *pixels_and, const void *pixels_xor, int width, @@ -28,6 +174,9 @@ ecore_win32_cursor_new(const void *pixels_and, INF("creating cursor"); + if (!pixels_and || !pixels_xor) + return NULL; + cursor_width = GetSystemMetrics(SM_CXCURSOR); cursor_height = GetSystemMetrics(SM_CYCURSOR); @@ -45,7 +194,15 @@ ecore_win32_cursor_new(const void *pixels_and, return cursor; } -void +/** + * @brief Free the given cursor. + * + * @param cursor The cursor to free. + * + * This function free @p cursor. @p cursor must have been obtained + * with ecore_win32_cursor_new(). + */ +EAPI void ecore_win32_cursor_free(Ecore_Win32_Cursor *cursor) { INF("destroying cursor"); @@ -53,8 +210,18 @@ ecore_win32_cursor_free(Ecore_Win32_Cursor *cursor) DestroyCursor(cursor); } -Ecore_Win32_Cursor * -ecore_win32_cursor_shape_get(Ecore_Win32_Cursor_Shape shape) +/** + * @brief Create a cursor from a Windows ressource. + * + * @param shape The pre-defined shape of the cursor. + * @return The new cursor. + * + * This funtion returns a pre-defined cursor with a specified + * @p shape. This cursor does not need to be freed, as it is loaded + * from an existing resource. + */ +EAPI Ecore_Win32_Cursor * +ecore_win32_cursor_shaped_new(Ecore_Win32_Cursor_Shape shape) { Ecore_Win32_Cursor *cursor = NULL; const char *cursor_name; @@ -115,15 +282,25 @@ ecore_win32_cursor_shape_get(Ecore_Win32_Cursor_Shape shape) return cursor; } -int -ecore_win32_cursor_size_get(void) +/** + * @brief Retrieve the size of a valid cursor. + * + * @param width The width of a valid cursor. + * @param height The height of a valid cursor. + * + * This function returns the size of a cursor that must be passed to + * ecore_win32_cursor_new(). @p width and @p height are buffers that + * will be filled with the correct size. They can be @c NULL. + */ +EAPI void +ecore_win32_cursor_size_get(int *width, int *height) { - int width; - int height; - INF("geting size cursor"); - width = GetSystemMetrics(SM_CXCURSOR); - height = GetSystemMetrics(SM_CYCURSOR); - return (width > height) ? width : height; + if (*width) *width = GetSystemMetrics(SM_CXCURSOR); + if (*height) *height = GetSystemMetrics(SM_CYCURSOR); } + +/** + * @} + */ diff --git a/src/lib/ecore_win32/ecore_win32_dnd.c b/src/lib/ecore_win32/ecore_win32_dnd.c index 415f812..a8eaf9c 100755 --- a/src/lib/ecore_win32/ecore_win32_dnd.c +++ b/src/lib/ecore_win32/ecore_win32_dnd.c @@ -7,6 +7,14 @@ #include "Ecore_Win32.h" #include "ecore_win32_private.h" +/*============================================================================* + * Local * + *============================================================================*/ + +/** + * @cond LOCAL + */ + static int _ecore_win32_dnd_init_count = 0; @@ -18,8 +26,42 @@ static HANDLE DataToHandle(const char *data, int size) return ptr; } - -int +/** + * @endcond + */ + + +/*============================================================================* + * Global * + *============================================================================*/ + + +/*============================================================================* + * API * + *============================================================================*/ + +/** + * @addtogroup Ecore_Win32_Group Ecore_Win32 library + * + * Ecore_Win32 is a library that wraps Windows CE graphic functions + * and integrate them nicely into the Ecore main loop. + * + * @{ + */ + +/** + * @brief Initialize the Ecore_Win32 Drag and Drop module. + * + * @return 1 or greater on success, 0 on error. + * + * This function initialize the Drag and Drop module. It returns 0 on + * failure, otherwise it returns the number of times it has already + * been called. + * + * When the Drag and Drop module is not used anymore, call + * ecore_win32_dnd_shutdown() to shut down the module. + */ +EAPI int ecore_win32_dnd_init() { if (_ecore_win32_dnd_init_count > 0) @@ -36,7 +78,18 @@ ecore_win32_dnd_init() return _ecore_win32_dnd_init_count; } -int ecore_win32_dnd_shutdown() +/** + * @brief Shut down the Ecore_Win32 Drag and Drop module. + * + * @return 0 when the module is completely shut down, 1 or + * greater otherwise. + * + * This function shuts down the Drag and Drop module. It returns 0 when it has + * been called the same number of times than ecore_win32_dnd_init(). In that case + * it shut down the module. + */ +EAPI int +ecore_win32_dnd_shutdown() { _ecore_win32_dnd_init_count--; if (_ecore_win32_dnd_init_count > 0) return _ecore_win32_dnd_init_count; @@ -48,17 +101,31 @@ int ecore_win32_dnd_shutdown() return _ecore_win32_dnd_init_count; } -int ecore_win32_dnd_begin(const char *data, - int size) +/** + * @brief Begin a DnD operation. + * + * @param data The name pf the Drag operation. + * @param size The size of the name. + * @return EINA_TRUE on success, EINA_FALSE otherwise. + * + * This function start a Drag operation with the name @p data. If + * @p data is @c NULL, EINA_FALSE is returned. if @p size is less than + * 0, it is set to the length (as strlen()) of @p data. On success the + * function returns EINA_TRUE, otherwise it returns EINA_FALSE. + */ +EAPI Eina_Bool +ecore_win32_dnd_begin(const char *data, + int size) { IDataObject *pDataObject = NULL; IDropSource *pDropSource = NULL; FORMATETC fmtetc = { CF_TEXT, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; STGMEDIUM stgmed = { TYMED_HGLOBAL, { 0 }, 0 }; - int res = 0; + Eina_Bool res = EINA_FALSE; if (!data) - return 0; + return EINA_FALSE; + if (size < 0) size = strlen(data) + 1; @@ -92,7 +159,7 @@ int ecore_win32_dnd_begin(const char *data, //else // printf("DND error\n"); - res = 1; + res = EINA_TRUE; } _ecore_win32_dnd_data_object_free(pDataObject); @@ -100,24 +167,48 @@ int ecore_win32_dnd_begin(const char *data, // cleanup ReleaseStgMedium(&stgmed); - return (int)res; + + return res; } -int ecore_win32_dnd_register_drop_target(Ecore_Win32_Window *window, - Ecore_Win32_Dnd_DropTarget_Callback callback) +/** + * @brief Register a Drop operation. + * + * @param window The destination of the Drop operation. + * @param callback The callback called when the Drop operation + * finishes. + * @return EINA_TRUE on success, EINA_FALSE otherwise. + * + * This function register a Drop operation on @p window. Once the Drop + * operation finishes, @p callback is called. If @p window is @c NULL, + * the function returns EINA_FALSE. On success, it returns EINA_TRUE, + * otherwise it returns EINA_FALSE. + */ +EAPI Eina_Bool +ecore_win32_dnd_register_drop_target(Ecore_Win32_Window *window, + Ecore_Win32_Dnd_DropTarget_Callback callback) { struct _Ecore_Win32_Window *wnd = (struct _Ecore_Win32_Window *)window; if (!window) - return 0; + return EINA_FALSE; wnd->dnd_drop_target = _ecore_win32_dnd_register_drop_window(wnd->window, callback, (void *)wnd); - return (int)(!!wnd->dnd_drop_target); + return wnd->dnd_drop_target ? EINA_TRUE : EINA_FALSE; } -void ecore_win32_dnd_unregister_drop_target(Ecore_Win32_Window *window) +/** + * @brief Unregister a Drop operation. + * + * @param window The destination of the Drop operation. + * + * This function unregister a Drop operation on @p window. If + * @p window is @c NULL, the function does nothing. + */ +EAPI void +ecore_win32_dnd_unregister_drop_target(Ecore_Win32_Window *window) { struct _Ecore_Win32_Window *wnd = (struct _Ecore_Win32_Window *)window; @@ -127,3 +218,7 @@ void ecore_win32_dnd_unregister_drop_target(Ecore_Win32_Window *window) if (wnd->dnd_drop_target) _ecore_win32_dnd_unregister_drop_window(wnd->window, wnd->dnd_drop_target); } + +/** + * @} + */ diff --git a/src/lib/ecore_win32/ecore_win32_window.c b/src/lib/ecore_win32/ecore_win32_window.c index fd3c079..7ca6748 100644 --- a/src/lib/ecore_win32/ecore_win32_window.c +++ b/src/lib/ecore_win32/ecore_win32_window.c @@ -14,8 +14,13 @@ #include "Ecore_Win32.h" #include "ecore_win32_private.h" +/*============================================================================* + * Local * + *============================================================================*/ -/***** Private declarations *****/ +/** + * @cond LOCAL + */ typedef enum _Ecore_Win32_Window_Z_Order Ecore_Win32_Window_Z_Order; @@ -27,17 +32,151 @@ enum _Ecore_Win32_Window_Z_Order ECORE_WIN32_WINDOW_Z_ORDER_TOPMOST }; -static Ecore_Win32_Window *ecore_win32_window_internal_new(Ecore_Win32_Window *parent, - int x, - int y, - int width, - int height, - DWORD style); +static Ecore_Win32_Window * +ecore_win32_window_internal_new(Ecore_Win32_Window *parent, + int x, + int y, + int width, + int height, + DWORD style) +{ + RECT rect; + struct _Ecore_Win32_Window *w; + int minimal_width; + int minimal_height; + + w = (struct _Ecore_Win32_Window *)calloc(1, sizeof(struct _Ecore_Win32_Window)); + if (!w) + { + ERR("malloc() failed"); + return NULL; + } + + rect.left = 0; + rect.top = 0; + rect.right = width; + rect.bottom = height; + if (!AdjustWindowRect(&rect, style, FALSE)) + { + ERR("AdjustWindowRect() failed"); + free(w); + return NULL; + } + + minimal_width = GetSystemMetrics(SM_CXMIN); + minimal_height = GetSystemMetrics(SM_CYMIN); +/* if (((rect.right - rect.left) < minimal_width) || */ +/* ((rect.bottom - rect.top) < minimal_height)) */ +/* { */ +/* fprintf (stderr, "[Ecore] [Win32] ERROR !!\n"); */ +/* fprintf (stderr, " Wrong size %ld\n", rect.right - rect.left); */ +/* free(w); */ +/* return NULL; */ +/* } */ + if ((rect.right - rect.left) < minimal_width) + { + rect.right = rect.left + minimal_width; + } + + w->window = CreateWindowEx(0, + ECORE_WIN32_WINDOW_CLASS, "", + style, + x, y, + rect.right - rect.left, + rect.bottom - rect.top, + parent ? ((struct _Ecore_Win32_Window *)parent)->window : NULL, + NULL, _ecore_win32_instance, NULL); + if (!w->window) + { + ERR("CreateWindowEx() failed"); + free(w); + return NULL; + } + + SetLastError(0); + if (!SetWindowLongPtr(w->window, GWL_USERDATA, (LONG)w) && (GetLastError() != 0)) + { + ERR("SetWindowLongPtr() failed"); + DestroyWindow(w->window); + free(w); + return NULL; + } + w->min_width = 0; + w->min_height = 0; + w->max_width = 32767; + w->max_height = 32767; + w->base_width = -1; + w->base_height = -1; + w->step_width = -1; + w->step_height = -1; -/***** API *****/ + w->state.iconified = 0; + w->state.modal = 0; + w->state.sticky = 0; + w->state.maximized_vert = 0; + w->state.maximized_horz = 0; + w->state.shaded = 0; + w->state.hidden = 0; + w->state.fullscreen = 0; + w->state.above = 0; + w->state.below = 0; + w->state.demands_attention = 0; -Ecore_Win32_Window * + w->type.desktop = 0; + w->type.dock = 0; + w->type.toolbar = 0; + w->type.menu = 0; + w->type.utility = 0; + w->type.splash = 0; + w->type.dialog = 0; + w->type.normal = 0; + + w->pointer_is_in = 0; + w->borderless = 0; + w->iconified = 0; + w->fullscreen = 0; + + return w; +} + +/** + * @endcond + */ + + +/*============================================================================* + * Global * + *============================================================================*/ + +/*============================================================================* + * API * + *============================================================================*/ + +/** + * @addtogroup Ecore_Win32_Group Ecore_Win32 library + * + * @{ + */ + +/** + * @brief Creates a new window. + * + * @param parent The parent window. + * @param x The x coordinate of the top-left corner of the window. + * @param y The y coordinate of the top-left corner of the window. + * @param width The width of the window. + * @param height The height of hte window. + * @return A newly allocated window. + * + * This function creates a new window which parent is @p parent. @p width and + * @p height are the size of the window content (the client part), + * without the border and title bar. @p x and @p y are the system + * coordinates of the top left cerner of the window (that is, of the + * title bar). This function returns a newly created window on + * success, and @c NULL on failure. + */ +EAPI Ecore_Win32_Window * ecore_win32_window_new(Ecore_Win32_Window *parent, int x, int y, @@ -52,8 +191,20 @@ ecore_win32_window_new(Ecore_Win32_Window *parent, WS_OVERLAPPEDWINDOW | WS_SIZEBOX); } -/* simulate X11 override windows */ -Ecore_Win32_Window * +/** + * @brief Creates a new borderless window. + * + * @param parent The parent window. + * @param x The x coordinate of the top-left corner of the window. + * @param y The y coordinate of the top-left corner of the window. + * @param width The width of the window. + * @param height The height of hte window. + * @return A newly allocated window. + * + * This function is the same than ecore_win32_window_override_new() + * but the returned window is borderless. + */ +EAPI Ecore_Win32_Window * ecore_win32_window_override_new(Ecore_Win32_Window *parent, int x, int y, @@ -68,7 +219,15 @@ ecore_win32_window_override_new(Ecore_Win32_Window *parent, WS_POPUP); } -void +/** + * @brief Free the given window. + * + * @param window The window to free. + * + * This function frees @p window. If @p window is @c NULL, this + * function does nothing. + */ +EAPI void ecore_win32_window_free(Ecore_Win32_Window *window) { struct _Ecore_Win32_Window *wnd = window; @@ -84,7 +243,15 @@ ecore_win32_window_free(Ecore_Win32_Window *window) free(window); } -void * +/** + * @brief Return the window HANDLE associated to the given window. + * + * @param window The window to retrieve the HANDLE from. + * + * This function returns the window HANDLE associated to @p window. If + * @p window is @c NULL, this function returns @c NULL. + */ +EAPI void * ecore_win32_window_hwnd_get(Ecore_Win32_Window *window) { if (!window) return NULL; @@ -124,7 +291,18 @@ ecore_win32_window_configure(Ecore_Win32_Window *window, } */ -void +/** + * @brief Move the given window to a given position. + * + * @param window The window to move. + * @param x The x coordinate of the destination position. + * @param y The y coordinate of the destination position. + * + * This function move @p window to the new position of coordinates @p x + * and @p y. If @p window is @c NULL, or if it is fullscreen, or on + * error, this function does nothing. + */ +EAPI void ecore_win32_window_move(Ecore_Win32_Window *window, int x, int y) @@ -132,6 +310,7 @@ ecore_win32_window_move(Ecore_Win32_Window *window, RECT rect; HWND w; + /* FIXME: on fullscreen, should not move it */ if (!window) return; INF("moving window (%dx%d)", x, y); @@ -152,7 +331,18 @@ ecore_win32_window_move(Ecore_Win32_Window *window, } } -void +/** + * @brief Resize the given window to a given size. + * + * @param window The window to resize. + * @param width The new width. + * @param height The new height. + * + * This function resize @p window to the new @p width and @p height. + * If @p window is @c NULL, or if it is fullscreen, or on error, this + * function does nothing. + */ +EAPI void ecore_win32_window_resize(Ecore_Win32_Window *window, int width, int height) @@ -163,6 +353,7 @@ ecore_win32_window_resize(Ecore_Win32_Window *window, int x; int y; + /* FIXME: on fullscreen, should not resize it */ if (!window) return; INF("resizing window (%dx%d)", width, height); @@ -207,7 +398,20 @@ ecore_win32_window_resize(Ecore_Win32_Window *window, } } -void +/** + * @brief Move and resize the given window to a given position and size. + * + * @param window The window to move and resize. + * @param x The x coordinate of the destination position. + * @param y The x coordinate of the destination position. + * @param width The new width. + * @param height The new height. + * + * This function resize @p window to the new position of coordinates @p x + * and @p y and the new @p width and @p height. If @p window is @c NULL, + * or if it is fullscreen, or on error, this function does nothing. + */ +EAPI void ecore_win32_window_move_resize(Ecore_Win32_Window *window, int x, int y, @@ -218,6 +422,7 @@ ecore_win32_window_move_resize(Ecore_Win32_Window *window, struct _Ecore_Win32_Window *w; DWORD style; + /* FIXME: on fullscreen, should not move/resize it */ if (!window) return; INF("moving and resizing window (%dx%d %dx%d)", x, y, width, height); @@ -251,7 +456,23 @@ ecore_win32_window_move_resize(Ecore_Win32_Window *window, } } -void +/** + * @brief Get the geometry of the given window. + * + * @param window The window to retrieve the geometry from. + * @param x The x coordinate of the position. + * @param y The x coordinate of the position. + * @param width The width. + * @param height The height. + * + * This function retrieves the position and size of @p window. @p x, + * @p y, @p width and @p height can be buffers that will be filled with + * the corresponding values. If one of them is @c NULL, nothing will + * be done for that parameter. If @p window is @c NULL, and if the + * buffers are not @c NULL, they will be filled with respectively 0, + * 0, the size of the screen and the height of the screen. + */ +EAPI void ecore_win32_window_geometry_get(Ecore_Win32_Window *window, int *x, int *y, @@ -309,7 +530,21 @@ ecore_win32_window_geometry_get(Ecore_Win32_Window *window, if (height) *height = h; } -void +/** + * @brief Get the size of the given window. + * + * @param window The window to retrieve the size from. + * @param width The width. + * @param height The height. + * + * This function retrieves the size of @p window. @p width and + * @p height can be buffers that will be filled with the corresponding + * values. If one of them is @c NULL, nothing will be done for that + * parameter. If @p window is @c NULL, and if the buffers are not + * @c NULL, they will be filled with respectively the size of the screen + * and the height of the screen. + */ +EAPI void ecore_win32_window_size_get(Ecore_Win32_Window *window, int *width, int *height) @@ -339,7 +574,18 @@ ecore_win32_window_size_get(Ecore_Win32_Window *window, if (height) *height = rect.bottom - rect.top; } -void +/** + * @brief Set the minimum size of the given window. + * + * @param window The window. + * @param min_width The minimal width. + * @param min_height The minimal height. + * + * This function sets the minimum size of @p window to @p min_width + * and *p min_height. If @p window is @c NULL, this functions does + * nothing. + */ +EAPI void ecore_win32_window_size_min_set(Ecore_Win32_Window *window, unsigned int min_width, unsigned int min_height) @@ -354,7 +600,18 @@ ecore_win32_window_size_min_set(Ecore_Win32_Window *window, w->min_height = min_height; } -void +/** + * @brief Get the minimum size of the given window. + * + * @param window The window. + * @param min_width The minimal width. + * @param min_height The minimal height. + * + * This function fills the minimum size of @p window in the buffers + * @p min_width and *p min_height. They both can be @c NULL. If + * @p window is @c NULL, this functions does nothing. + */ +EAPI void ecore_win32_window_size_min_get(Ecore_Win32_Window *window, unsigned int *min_width, unsigned int *min_height) @@ -369,7 +626,18 @@ ecore_win32_window_size_min_get(Ecore_Win32_Window *window, if (min_height) *min_height = w->min_height; } -void +/** + * @brief Set the maximum size of the given window. + * + * @param window The window. + * @param max_width The maximal width. + * @param max_height The maximal height. + * + * This function sets the maximum size of @p window to @p max_width + * and *p max_height. If @p window is @c NULL, this functions does + * nothing. + */ +EAPI void ecore_win32_window_size_max_set(Ecore_Win32_Window *window, unsigned int max_width, unsigned int max_height) @@ -384,7 +652,18 @@ ecore_win32_window_size_max_set(Ecore_Win32_Window *window, w->max_height = max_height; } -void +/** + * @brief Get the maximum size of the given window. + * + * @param window The window. + * @param max_width The maximal width. + * @param max_height The maximal height. + * + * This function fills the maximum size of @p window in the buffers + * @p max_width and *p max_height. They both can be @c NULL. If + * @p window is @c NULL, this functions does nothing. + */ +EAPI void ecore_win32_window_size_max_get(Ecore_Win32_Window *window, unsigned int *max_width, unsigned int *max_height) @@ -399,7 +678,18 @@ ecore_win32_window_size_max_get(Ecore_Win32_Window *window, if (max_height) *max_height = w->max_height; } -void +/** + * @brief Set the base size of the given window. + * + * @param window The window. + * @param base_width The base width. + * @param base_height The base height. + * + * This function sets the base size of @p window to @p base_width + * and *p base_height. If @p window is @c NULL, this functions does + * nothing. + */ +EAPI void ecore_win32_window_size_base_set(Ecore_Win32_Window *window, unsigned int base_width, unsigned int base_height) @@ -414,7 +704,18 @@ ecore_win32_window_size_base_set(Ecore_Win32_Window *window, w->base_height = base_height; } -void +/** + * @brief Get the base size of the given window. + * + * @param window The window. + * @param base_width The base width. + * @param base_height The bas height. + * + * This function fills the base size of @p window in the buffers + * @p base_width and *p base_height. They both can be @c NULL. If + * @p window is @c NULL, this functions does nothing. + */ +EAPI void ecore_win32_window_size_base_get(Ecore_Win32_Window *window, unsigned int *base_width, unsigned int *base_height) @@ -429,7 +730,18 @@ ecore_win32_window_size_base_get(Ecore_Win32_Window *window, if (base_height) *base_height = w->base_height; } -void +/** + * @brief Set the step size of the given window. + * + * @param window The window. + * @param step_width The step width. + * @param step_height The step height. + * + * This function sets the step size of @p window to @p step_width + * and *p step_height. If @p window is @c NULL, this functions does + * nothing. + */ +EAPI void ecore_win32_window_size_step_set(Ecore_Win32_Window *window, unsigned int step_width, unsigned int step_height) @@ -444,7 +756,18 @@ ecore_win32_window_size_step_set(Ecore_Win32_Window *window, w->step_height = step_height; } -void +/** + * @brief Get the step size of the given window. + * + * @param window The window. + * @param step_width The step width. + * @param step_height The bas height. + * + * This function fills the step size of @p window in the buffers + * @p step_width and *p step_height. They both can be @c NULL. If + * @p window is @c NULL, this functions does nothing. + */ +EAPI void ecore_win32_window_size_step_get(Ecore_Win32_Window *window, unsigned int *step_width, unsigned int *step_height) @@ -459,7 +782,7 @@ ecore_win32_window_size_step_get(Ecore_Win32_Window *window, if (step_height) *step_height = w->step_height; } -void +EAPI void ecore_win32_window_shape_set(Ecore_Win32_Window *window, unsigned short width, unsigned short height, @@ -596,7 +919,15 @@ ecore_win32_window_shape_set(Ecore_Win32_Window *window, } } -void +/** + * @brief Show the given window. + * + * @param window The window to show. + * + * This function shows @p window. If @p window is @c NULL, or on + * error, this function does nothing. + */ +EAPI void ecore_win32_window_show(Ecore_Win32_Window *window) { if (!window) return; @@ -611,7 +942,15 @@ ecore_win32_window_show(Ecore_Win32_Window *window) } /* FIXME: seems to block the taskbar */ -void +/** + * @brief Hide the given window. + * + * @param window The window to show. + * + * This function hides @p window. If @p window is @c NULL, or on + * error, this function does nothing. + */ +EAPI void ecore_win32_window_hide(Ecore_Win32_Window *window) { if (!window) return; @@ -621,7 +960,15 @@ ecore_win32_window_hide(Ecore_Win32_Window *window) ShowWindow(((struct _Ecore_Win32_Window *)window)->window, SW_HIDE); } -void +/** + * @brief Place the given window at the top of the Z order. + * + * @param window The window to place at the top. + * + * This function places @p window at the top of the Z order. If + * @p window is @c NULL, this function does nothing. + */ +EAPI void ecore_win32_window_raise(Ecore_Win32_Window *window) { if (!window) return; @@ -636,7 +983,15 @@ ecore_win32_window_raise(Ecore_Win32_Window *window) } } -void +/** + * @brief Place the given window at the bottom of the Z order. + * + * @param window The window to place at the bottom. + * + * This function places @p window at the bottom of the Z order. If + * @p window is @c NULL, this function does nothing. + */ +EAPI void ecore_win32_window_lower(Ecore_Win32_Window *window) { if (!window) return; @@ -651,7 +1006,17 @@ ecore_win32_window_lower(Ecore_Win32_Window *window) } } -void +/** + * @brief Set the title of the given window. + * + * @param window The window to set the title. + * @param title The new title. + * + * This function sets the title of @p window to @p title. If @p window + * is @c NULL, or if @p title is @c NULL or empty, or on error, this + * function does nothing. + */ +EAPI void ecore_win32_window_title_set(Ecore_Win32_Window *window, const char *title) { @@ -667,7 +1032,15 @@ ecore_win32_window_title_set(Ecore_Win32_Window *window, } } -void +/** + * @brief Set the focus to the given window. + * + * @param window The window to give focus to. + * + * This function gives the focus to @p window. If @p window is + * @c NULL, this function does nothing. + */ +EAPI void ecore_win32_window_focus_set(Ecore_Win32_Window *window) { if (!window) return; @@ -680,9 +1053,21 @@ ecore_win32_window_focus_set(Ecore_Win32_Window *window) } } -void +/** + * @brief Iconify or restore the given window. + * + * @param window The window. + * @param on EINA_TRUE to iconify the window, EINA_FALSE to restore it. + * + * This function iconify or restore @p window. If @p on + * is set to EINA_TRUE, the window will be iconified, if it is set to + * EINA_FALSE, it will be restored. If @p window is @c NULL or if the + * state does not change (like iconifying the window while it is + * already iconified), this function does nothing. + */ +EAPI void ecore_win32_window_iconified_set(Ecore_Win32_Window *window, - int on) + Eina_Bool on) { struct _Ecore_Win32_Window *ew; @@ -699,9 +1084,21 @@ ecore_win32_window_iconified_set(Ecore_Win32_Window *window, ew->iconified = on; } -void +/** + * @brief Remove or restore the border of the given window. + * + * @param window The window. + * @param on EINA_TRUE to remove the border, EINA_FALSE to restore it. + * + * This function remove or restore the border of @p window. If @p on + * is set to EINA_TRUE, the window will have no border, if it is set to + * EINA_FALSE, it will have a border. If @p window is @c NULL or if the + * state does not change (like setting to borderless while the window + * has no border), this function does nothing. + */ +EAPI void ecore_win32_window_borderless_set(Ecore_Win32_Window *window, - int on) + Eina_Bool on) { RECT rect; DWORD style; @@ -765,9 +1162,21 @@ ecore_win32_window_borderless_set(Ecore_Win32_Window *window, ew->borderless = on; } -void +/** + * @brief Set the given window to fullscreen. + * + * @param window The window. + * @param on EINA_TRUE for fullscreen mode, EINA_FALSE for windowed mode. + * + * This function set @p window to fullscreen or windowed mode. If @p on + * is set to EINA_TRUE, the window will be fullscreen, if it is set to + * EINA_FALSE, it will be windowed. If @p window is @c NULL or if the + * state does not change (like setting to fullscreen while the window + * is already fullscreen), this function does nothing. + */ +EAPI void ecore_win32_window_fullscreen_set(Ecore_Win32_Window *window, - int on) + Eina_Bool on) { struct _Ecore_Win32_Window *ew; HWND w; @@ -847,12 +1256,26 @@ ecore_win32_window_fullscreen_set(Ecore_Win32_Window *window, } } -void +/** + * @brief Set the given cursor to the given window. + * + * @param window The window to modify the cursor. + * @param cursor The new cursor. + * + * This function sets @p cursor to @p window. @p cursor must have been + * obtained by ecore_win32_cursor_new() or + * ecore_win32_cursor_shaped_new(). If @p window or @p cursor is + * @c NULL, the function does nothing. + */ +EAPI void ecore_win32_window_cursor_set(Ecore_Win32_Window *window, Ecore_Win32_Cursor *cursor) { INF("setting cursor"); + if (!window || !cursor) + return; + if (!SetClassLong(((struct _Ecore_Win32_Window *)window)->window, GCL_HCURSOR, (LONG)cursor)) { @@ -860,14 +1283,25 @@ ecore_win32_window_cursor_set(Ecore_Win32_Window *window, } } -void +/** + * @brief Set the state of the given window. + * + * @param window The window to modify the state. + * @param state An array of the new states. + * @param num The number of states in the array. + * + * This function set the state of @p window. @p state is an array of + * states of size @p num. If @p window or @p state are @c NULL, or if + * @p num is less or equal than 0, the function does nothing. + */ +EAPI void ecore_win32_window_state_set(Ecore_Win32_Window *window, Ecore_Win32_Window_State *state, unsigned int num) { unsigned int i; - if (!window || !state || !num) + if (!window || !state || (num <= 0)) return; INF("setting cursor state"); @@ -920,7 +1354,20 @@ ecore_win32_window_state_set(Ecore_Win32_Window *window, } } -void +/** + * @brief Apply the modification of the state to the given window. + * + * @param window The window. + * @param state The state to apply changes. + * @param set The value of the state change. + * + * This function applies the modification of the state @p state of + * @p window. @p set is used only for + * #ECORE_WIN32_WINDOW_STATE_ICONIFIED and + * #ECORE_WIN32_WINDOW_STATE_FULLSCREEN. If @p window is @c NULL, the + * function does nothing. + */ +EAPI void ecore_win32_window_state_request_send(Ecore_Win32_Window *window, Ecore_Win32_Window_State state, unsigned int set) @@ -1058,7 +1505,16 @@ ecore_win32_window_state_request_send(Ecore_Win32_Window *window, } } -void +/** + * @brief Set the type of the given window. + * + * @param window The window to modify the type. + * @param type The new types. + * + * This function set the type of @p window to @p type. If + * @p window is @c NULL, the function does nothing. + */ +EAPI void ecore_win32_window_type_set(Ecore_Win32_Window *window, Ecore_Win32_Window_Type type) { @@ -1099,113 +1555,6 @@ ecore_win32_window_type_set(Ecore_Win32_Window *window, } } - -/***** Private functions definitions *****/ - -static Ecore_Win32_Window * -ecore_win32_window_internal_new(Ecore_Win32_Window *parent, - int x, - int y, - int width, - int height, - DWORD style) -{ - RECT rect; - struct _Ecore_Win32_Window *w; - int minimal_width; - int minimal_height; - - w = (struct _Ecore_Win32_Window *)calloc(1, sizeof(struct _Ecore_Win32_Window)); - if (!w) - { - ERR("malloc() failed"); - return NULL; - } - - rect.left = 0; - rect.top = 0; - rect.right = width; - rect.bottom = height; - if (!AdjustWindowRect(&rect, style, FALSE)) - { - ERR("AdjustWindowRect() failed"); - free(w); - return NULL; - } - - minimal_width = GetSystemMetrics(SM_CXMIN); - minimal_height = GetSystemMetrics(SM_CYMIN); -/* if (((rect.right - rect.left) < minimal_width) || */ -/* ((rect.bottom - rect.top) < minimal_height)) */ -/* { */ -/* fprintf (stderr, "[Ecore] [Win32] ERROR !!\n"); */ -/* fprintf (stderr, " Wrong size %ld\n", rect.right - rect.left); */ -/* free(w); */ -/* return NULL; */ -/* } */ - if ((rect.right - rect.left) < minimal_width) - { - rect.right = rect.left + minimal_width; - } - - w->window = CreateWindowEx(0, - ECORE_WIN32_WINDOW_CLASS, "", - style, - x, y, - rect.right - rect.left, - rect.bottom - rect.top, - parent ? ((struct _Ecore_Win32_Window *)parent)->window : NULL, - NULL, _ecore_win32_instance, NULL); - if (!w->window) - { - ERR("CreateWindowEx() failed"); - free(w); - return NULL; - } - - SetLastError(0); - if (!SetWindowLongPtr(w->window, GWL_USERDATA, (LONG)w) && (GetLastError() != 0)) - { - ERR("SetWindowLongPtr() failed"); - DestroyWindow(w->window); - free(w); - return NULL; - } - - w->min_width = 0; - w->min_height = 0; - w->max_width = 32767; - w->max_height = 32767; - w->base_width = -1; - w->base_height = -1; - w->step_width = -1; - w->step_height = -1; - - w->state.iconified = 0; - w->state.modal = 0; - w->state.sticky = 0; - w->state.maximized_vert = 0; - w->state.maximized_horz = 0; - w->state.shaded = 0; - w->state.hidden = 0; - w->state.fullscreen = 0; - w->state.above = 0; - w->state.below = 0; - w->state.demands_attention = 0; - - w->type.desktop = 0; - w->type.dock = 0; - w->type.toolbar = 0; - w->type.menu = 0; - w->type.utility = 0; - w->type.splash = 0; - w->type.dialog = 0; - w->type.normal = 0; - - w->pointer_is_in = 0; - w->borderless = 0; - w->iconified = 0; - w->fullscreen = 0; - - return w; -} +/** + * @} + */ diff --git a/src/lib/ecore_wince/Ecore_WinCE.h b/src/lib/ecore_wince/Ecore_WinCE.h index de535a3..9a51acc 100644 --- a/src/lib/ecore_wince/Ecore_WinCE.h +++ b/src/lib/ecore_wince/Ecore_WinCE.h @@ -37,107 +37,202 @@ extern "C" { typedef void Ecore_WinCE_Window; #endif +/** + * @defgroup Ecore_WinCE_Group Ecore_WinCE library + * + * @{ + */ -/* Events */ +/** + * @typedef Ecore_WinCE_Event_Mouse_In + * Event sent when the mouse enters the window. + */ typedef struct _Ecore_WinCE_Event_Mouse_In Ecore_WinCE_Event_Mouse_In; + +/** + * @typedef Ecore_WinCE_Event_Mouse_Out + * Event sent when the mouse leaves the window. + */ typedef struct _Ecore_WinCE_Event_Mouse_Out Ecore_WinCE_Event_Mouse_Out; + +/** + * @typedef Ecore_WinCE_Event_Window_Focus_In + * Event sent when the window gets the focus. + */ typedef struct _Ecore_WinCE_Event_Window_Focus_In Ecore_WinCE_Event_Window_Focus_In; + +/** + * @typedef Ecore_WinCE_Event_Window_Focus_Out + * Event sent when the window looses the focus. + */ typedef struct _Ecore_WinCE_Event_Window_Focus_Out Ecore_WinCE_Event_Window_Focus_Out; + +/** + * @typedef Ecore_WinCE_Event_Window_Damage + * Event sent when the window is damaged. + */ typedef struct _Ecore_WinCE_Event_Window_Damage Ecore_WinCE_Event_Window_Damage; + +/** + * @typedef Ecore_WinCE_Event_Window_Create + * Event sent when the window is created. + */ typedef struct _Ecore_WinCE_Event_Window_Create Ecore_WinCE_Event_Window_Create; + +/** + * @typedef Ecore_WinCE_Event_Window_Destroy + * Event sent when the window is destroyed. + */ typedef struct _Ecore_WinCE_Event_Window_Destroy Ecore_WinCE_Event_Window_Destroy; + +/** + * @typedef Ecore_WinCE_Event_Window_Hide + * Event sent when the window is hidden. + */ typedef struct _Ecore_WinCE_Event_Window_Hide Ecore_WinCE_Event_Window_Hide; + +/** + * @typedef Ecore_WinCE_Event_Window_Show + * Event sent when the window is shown. + */ typedef struct _Ecore_WinCE_Event_Window_Show Ecore_WinCE_Event_Window_Show; + +/** + * @typedef Ecore_WinCE_Event_Window_Delete_Request + * Event sent when the window is deleted. + */ typedef struct _Ecore_WinCE_Event_Window_Delete_Request Ecore_WinCE_Event_Window_Delete_Request; + +/** + * @struct _Ecore_WinCE_Event_Mouse_In + * Event sent when the mouse enters the window. + */ struct _Ecore_WinCE_Event_Mouse_In { - Ecore_WinCE_Window *window; - int x; - int y; - long time; + Ecore_WinCE_Window *window; /**< The window that received the event */ + int x; /**< The x coordinate where the mouse entered */ + int y; /**< The y coordinate where the mouse entered */ + long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_WinCE_Event_Mouse_Out + * Event sent when the mouse leaves the window. + */ struct _Ecore_WinCE_Event_Mouse_Out { - Ecore_WinCE_Window *window; - int x; - int y; - long time; + Ecore_WinCE_Window *window; /**< The window that received the event */ + int x; /**< The x coordinate where the mouse leaved */ + int y; /**< The y coordinate where the mouse leaved */ + long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_WinCE_Event_Window_Focus_In + * Event sent when the window gets the focus. + */ struct _Ecore_WinCE_Event_Window_Focus_In { - Ecore_WinCE_Window *window; - long time; + Ecore_WinCE_Window *window; /**< The window that received the event */ + long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_WinCE_Event_Window_Focus_Out + * Event sent when the window looses the focus. + */ struct _Ecore_WinCE_Event_Window_Focus_Out { - Ecore_WinCE_Window *window; - long time; + Ecore_WinCE_Window *window; /**< The window that received the event */ + long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_WinCE_Event_Window_Damage + * Event sent when the window is damaged. + */ struct _Ecore_WinCE_Event_Window_Damage { - Ecore_WinCE_Window *window; - int x; - int y; - int width; - int height; - long time; + Ecore_WinCE_Window *window; /**< The window that received the event */ + int x; /**< The x coordinate of the top left corner of the damaged region */ + int y; /**< The y coordinate of the top left corner of the damaged region */ + int width; /**< The width of the damaged region */ + int height; /**< The height of the damaged region */ + long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_WinCE_Event_Window_Create + * Event sent when the window is created. + */ struct _Ecore_WinCE_Event_Window_Create { - Ecore_WinCE_Window *window; - long time; + Ecore_WinCE_Window *window; /**< The window that received the event */ + long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_WinCE_Event_Window_Destroy + * Event sent when the window is destroyed. + */ struct _Ecore_WinCE_Event_Window_Destroy { - Ecore_WinCE_Window *window; - long time; + Ecore_WinCE_Window *window; /**< The window that received the event */ + long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_WinCE_Event_Window_Hide + * Event sent when the window is hidden. + */ struct _Ecore_WinCE_Event_Window_Hide { - Ecore_WinCE_Window *window; - long time; + Ecore_WinCE_Window *window; /**< The window that received the event */ + long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_WinCE_Event_Window_Show + * Event sent when the window is shown. + */ struct _Ecore_WinCE_Event_Window_Show { - Ecore_WinCE_Window *window; - long time; + Ecore_WinCE_Window *window; /**< The window that received the event */ + long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_WinCE_Event_Window_Delete_Request + * Event sent when the window is deleted. + */ struct _Ecore_WinCE_Event_Window_Delete_Request { - Ecore_WinCE_Window *window; - long time; + Ecore_WinCE_Window *window; /**< The window that received the event */ + long time; /**< The time the event occured */ }; -EAPI extern int ECORE_WINCE_EVENT_MOUSE_IN; -EAPI extern int ECORE_WINCE_EVENT_MOUSE_OUT; -EAPI extern int ECORE_WINCE_EVENT_WINDOW_FOCUS_IN; -EAPI extern int ECORE_WINCE_EVENT_WINDOW_FOCUS_OUT; -EAPI extern int ECORE_WINCE_EVENT_WINDOW_DAMAGE; -EAPI extern int ECORE_WINCE_EVENT_WINDOW_CREATE; -EAPI extern int ECORE_WINCE_EVENT_WINDOW_DESTROY; -EAPI extern int ECORE_WINCE_EVENT_WINDOW_HIDE; -EAPI extern int ECORE_WINCE_EVENT_WINDOW_SHOW; -EAPI extern int ECORE_WINCE_EVENT_WINDOW_DELETE_REQUEST; +EAPI extern int ECORE_WINCE_EVENT_MOUSE_IN; /**< Ecore_Event for the #Ecore_WinCE_Event_Mouse_In event */ +EAPI extern int ECORE_WINCE_EVENT_MOUSE_OUT; /**< Ecore_Event for the #Ecore_WinCE_Event_Mouse_Out event */ +EAPI extern int ECORE_WINCE_EVENT_WINDOW_FOCUS_IN; /**< Ecore_Event for the #Ecore_WinCE_Event_Window_Focus_In event */ +EAPI extern int ECORE_WINCE_EVENT_WINDOW_FOCUS_OUT; /**< Ecore_Event for the #Ecore_WinCE_Event_Window_Focus_Out event */ +EAPI extern int ECORE_WINCE_EVENT_WINDOW_DAMAGE; /**< Ecore_Event for the #Ecore_WinCE_Event_Damage event */ +EAPI extern int ECORE_WINCE_EVENT_WINDOW_CREATE; /**< Ecore_Event for the #Ecore_WinCE_Event_Create event */ +EAPI extern int ECORE_WINCE_EVENT_WINDOW_DESTROY; /**< Ecore_Event for the #Ecore_WinCE_Event_Destroy event */ +EAPI extern int ECORE_WINCE_EVENT_WINDOW_HIDE; /**< Ecore_Event for the #Ecore_WinCE_Event_Hide event */ +EAPI extern int ECORE_WINCE_EVENT_WINDOW_SHOW; /**< Ecore_Event for the #Ecore_WinCE_Event_Show event */ +EAPI extern int ECORE_WINCE_EVENT_WINDOW_DELETE_REQUEST; /**< Ecore_Event for the #Ecore_WinCE_Event_Window_Delete_Request event */ /* Core */ EAPI int ecore_wince_init(); EAPI int ecore_wince_shutdown(); +EAPI void ecore_wince_double_click_time_set(double t); +EAPI double ecore_wince_double_click_time_get(void); EAPI long ecore_wince_current_time_get(void); -EAPI void ecore_wince_message_loop_begin (void); /* Window */ @@ -174,9 +269,9 @@ EAPI void ecore_wince_window_title_set(Ecore_WinCE_Window *window, EAPI void ecore_wince_window_backend_set(Ecore_WinCE_Window *window, int backend); -EAPI void ecore_wince_window_suspend_set(Ecore_WinCE_Window *window, int (*suspend)(int)); +EAPI void ecore_wince_window_suspend_set(Ecore_WinCE_Window *window, int (*suspend_cb)(int)); -EAPI void ecore_wince_window_resume_set(Ecore_WinCE_Window *window, int (*resume)(int)); +EAPI void ecore_wince_window_resume_set(Ecore_WinCE_Window *window, int (*resume_cb)(int)); EAPI void ecore_wince_window_geometry_get(Ecore_WinCE_Window *window, int *x, @@ -189,8 +284,11 @@ EAPI void ecore_wince_window_size_get(Ecore_WinCE_Window *window, int *height); EAPI void ecore_wince_window_fullscreen_set(Ecore_WinCE_Window *window, - int on); + Eina_Bool on); +/** + * @} + */ #ifdef __cplusplus } diff --git a/src/lib/ecore_wince/ecore_wince.c b/src/lib/ecore_wince/ecore_wince.c index 41a5314..9f7b594 100644 --- a/src/lib/ecore_wince/ecore_wince.c +++ b/src/lib/ecore_wince/ecore_wince.c @@ -16,8 +16,173 @@ #include "Ecore_WinCE.h" #include "ecore_wince_private.h" +/*============================================================================* + * Local * + *============================================================================*/ + +/** + * @cond LOCAL + */ + +static int _ecore_wince_init_count = 0; + +LRESULT CALLBACK +_ecore_wince_window_procedure(HWND window, + UINT message, + WPARAM window_param, + LPARAM data_param) +{ + Ecore_WinCE_Callback_Data *data; + POINTS pt; + DWORD coord; + + data = (Ecore_WinCE_Callback_Data *)malloc(sizeof(Ecore_WinCE_Callback_Data)); + if (!data) return DefWindowProc(window, message, window_param, data_param); + + data->window = window; + data->message = message; + data->window_param = window_param; + data->data_param = data_param; + data->time = GetTickCount(); + coord = GetMessagePos(); + pt = MAKEPOINTS(coord); + data->x = pt.x; + data->y = pt.y; + + switch (data->message) + { + /* Keyboard input notifications */ + case WM_CHAR: + _ecore_wince_event_handle_key_press(data, 0); + break; + case WM_HOTKEY: + _ecore_wince_event_handle_key_press(data, 1); + break; + case WM_KEYDOWN: + case WM_SYSKEYDOWN: + _ecore_wince_event_handle_key_press(data, 1); + break; + case WM_KEYUP: + case WM_SYSKEYUP: + _ecore_wince_event_handle_key_release(data, 1); + break; + case WM_SETFOCUS: + _ecore_wince_event_handle_focus_in(data); + break; + case WM_KILLFOCUS: + _ecore_wince_event_handle_focus_out(data); + break; + /* Mouse input notifications */ + case WM_LBUTTONDOWN: + _ecore_wince_event_handle_button_press(data, 1); + break; + case WM_LBUTTONUP: + _ecore_wince_event_handle_button_release(data, 1); + break; + case WM_MOUSEMOVE: + { + RECT rect; + struct _Ecore_WinCE_Window *w = NULL; + + w = (struct _Ecore_WinCE_Window *)GetWindowLong(window, GWL_USERDATA); + + if (GetClientRect(window, &rect)) + { + POINT pt; + + INF("mouse in window"); + + pt.x = LOWORD(data_param); + pt.y = HIWORD(data_param); + if (!PtInRect(&rect, pt)) + { + if (w->pointer_is_in) + { + w->pointer_is_in = 0; + _ecore_wince_event_handle_leave_notify(data); + } + } + else + { + if (!w->pointer_is_in) + { + w->pointer_is_in = 1; + _ecore_wince_event_handle_enter_notify(data); + } + } + } + else + { + ERR("GetClientRect() failed"); + } + _ecore_wince_event_handle_motion_notify(data); + + break; + } + /* Window notifications */ + case WM_CREATE: + _ecore_wince_event_handle_create_notify(data); + break; + case WM_DESTROY: + _ecore_wince_event_handle_destroy_notify(data); + break; + case WM_SHOWWINDOW: + if ((data->data_param == SW_OTHERUNZOOM) || + (data->data_param == SW_OTHERZOOM)) + break; + + if (data->window_param) + _ecore_wince_event_handle_map_notify(data); + else + _ecore_wince_event_handle_unmap_notify(data); + + break; + case WM_CLOSE: + _ecore_wince_event_handle_delete_request(data); + break; + /* GDI notifications */ + case WM_PAINT: + { + PAINTSTRUCT paint; + + if (BeginPaint(window, &paint)) + { + data->update = paint.rcPaint; + _ecore_wince_event_handle_expose(data); + EndPaint(window, &paint); + } + break; + } + default: + return DefWindowProc(window, message, window_param, data_param); + } + + return 0; +} + +static void +_ecore_wince_error_print_cb(const Eina_Log_Domain *d __UNUSED__, + Eina_Log_Level level __UNUSED__, + const char *file __UNUSED__, + const char *fnc, + int line, + const char *fmt, + void *data __UNUSED__, + va_list args) +{ + fprintf(stderr, "[%s:%d] ", fnc, line); + vfprintf(stderr, fmt, args); +} + +/** + * @endcond + */ + + +/*============================================================================* + * Global * + *============================================================================*/ -/***** Global declarations *****/ double _ecore_wince_double_click_time = 0.25; long _ecore_wince_event_last_time = 0; @@ -36,29 +201,32 @@ int ECORE_WINCE_EVENT_WINDOW_SHOW = 0; int ECORE_WINCE_EVENT_WINDOW_HIDE = 0; int ECORE_WINCE_EVENT_WINDOW_DELETE_REQUEST = 0; +/*============================================================================* + * API * + *============================================================================*/ -/***** Private declarations *****/ - -static int _ecore_wince_init_count = 0; - -LRESULT CALLBACK _ecore_wince_window_procedure(HWND window, - UINT message, - WPARAM window_param, - LPARAM data_param); - -static void _ecore_wince_error_print_cb(const Eina_Log_Domain *d, - Eina_Log_Level level, - const char *file, - const char *fnc, - int line, - const char *fmt, - void *data, - va_list args); - - -/***** API *****/ +/** + * @addtogroup Ecore_WinCE_Group Ecore_WinCE library + * + * Ecore_WinCE is a library that wraps Windows CE graphic functions + * and integrate them nicely into the Ecore main loop. + * + * @{ + */ -int +/** + * @brief Initialize the Ecore_WinCE library. + * + * @return 1 or greater on success, 0 on error. + * + * This function sets up the Windows CE graphic system. It returns 0 on + * failure, otherwise it returns the number of times it has already been + * called. + * + * When Ecore_WinCE is not used anymore, call ecore_wince_shutdown() + * to shut down the Ecore_WinCE library. + */ +EAPI int ecore_wince_init() { WNDCLASS wc; @@ -136,7 +304,17 @@ ecore_wince_init() return --_ecore_wince_init_count; } -int +/** + * @brief Shut down the Ecore_WinCE library. + * + * @return 0 when the library is completely shut down, 1 or + * greater otherwise. + * + * This function shuts down the Ecore_WinCE library. It returns 0 when it has + * been called the same number of times than ecore_wince_init(). In that case + * it shut down all the Windows CE graphic system. + */ +EAPI int ecore_wince_shutdown() { HWND task_bar; @@ -170,13 +348,13 @@ ecore_wince_shutdown() } /** - * Sets the timeout for a double and triple clicks to be flagged. + * @brief Set the timeout for a double and triple clicks to be flagged. * - * This sets the time between clicks before the double_click flag is - * set in a button down event. If 3 clicks occur within double this - * time, the triple_click flag is also set. + * @param t The time in seconds. * - * @param t The time in seconds + * This function sets the time @p t between clicks before the + * double_click flag is set in a button down event. If 3 clicks occur + * within double this time, the triple_click flag is also set. */ EAPI void ecore_wince_double_click_time_set(double t) @@ -186,11 +364,14 @@ ecore_wince_double_click_time_set(double t) } /** - * Retrieves the double and triple click flag timeout. - * - * See @ref ecore_wince_double_click_time_set for more information. + * @brief Retrieve the double and triple click flag timeout. * * @return The timeout for double clicks in seconds. + * + * This function returns the double clicks in seconds. If + * ecore_wince_double_click_time_set() has not been called, the + * default value is returned. See ecore_wince_double_click_time_set() + * for more informations. */ EAPI double ecore_wince_double_click_time_get(void) @@ -199,7 +380,11 @@ ecore_wince_double_click_time_get(void) } /** - * Return the last event time + * @brief Return the last event time. + * + * @return The last envent time. + * + * This function returns the last event time. */ EAPI long ecore_wince_current_time_get(void) @@ -207,153 +392,6 @@ ecore_wince_current_time_get(void) return _ecore_wince_event_last_time; } - -/***** Private functions definitions *****/ - -LRESULT CALLBACK -_ecore_wince_window_procedure(HWND window, - UINT message, - WPARAM window_param, - LPARAM data_param) -{ - Ecore_WinCE_Callback_Data *data; - POINTS pt; - DWORD coord; - - data = (Ecore_WinCE_Callback_Data *)malloc(sizeof(Ecore_WinCE_Callback_Data)); - if (!data) return DefWindowProc(window, message, window_param, data_param); - - data->window = window; - data->message = message; - data->window_param = window_param; - data->data_param = data_param; - data->time = GetTickCount(); - coord = GetMessagePos(); - pt = MAKEPOINTS(coord); - data->x = pt.x; - data->y = pt.y; - - switch (data->message) - { - /* Keyboard input notifications */ - case WM_CHAR: - _ecore_wince_event_handle_key_press(data, 0); - break; - case WM_HOTKEY: - _ecore_wince_event_handle_key_press(data, 1); - break; - case WM_KEYDOWN: - case WM_SYSKEYDOWN: - _ecore_wince_event_handle_key_press(data, 1); - break; - case WM_KEYUP: - case WM_SYSKEYUP: - _ecore_wince_event_handle_key_release(data, 1); - break; - case WM_SETFOCUS: - _ecore_wince_event_handle_focus_in(data); - break; - case WM_KILLFOCUS: - _ecore_wince_event_handle_focus_out(data); - break; - /* Mouse input notifications */ - case WM_LBUTTONDOWN: - _ecore_wince_event_handle_button_press(data, 1); - break; - case WM_LBUTTONUP: - _ecore_wince_event_handle_button_release(data, 1); - break; - case WM_MOUSEMOVE: - { - RECT rect; - struct _Ecore_WinCE_Window *w = NULL; - - w = (struct _Ecore_WinCE_Window *)GetWindowLong(window, GWL_USERDATA); - - if (GetClientRect(window, &rect)) - { - POINT pt; - - INF("mouse in window"); - - pt.x = LOWORD(data_param); - pt.y = HIWORD(data_param); - if (!PtInRect(&rect, pt)) - { - if (w->pointer_is_in) - { - w->pointer_is_in = 0; - _ecore_wince_event_handle_leave_notify(data); - } - } - else - { - if (!w->pointer_is_in) - { - w->pointer_is_in = 1; - _ecore_wince_event_handle_enter_notify(data); - } - } - } - else - { - ERR("GetClientRect() failed"); - } - _ecore_wince_event_handle_motion_notify(data); - - break; - } - /* Window notifications */ - case WM_CREATE: - _ecore_wince_event_handle_create_notify(data); - break; - case WM_DESTROY: - _ecore_wince_event_handle_destroy_notify(data); - break; - case WM_SHOWWINDOW: - if ((data->data_param == SW_OTHERUNZOOM) || - (data->data_param == SW_OTHERZOOM)) - break; - - if (data->window_param) - _ecore_wince_event_handle_map_notify(data); - else - _ecore_wince_event_handle_unmap_notify(data); - - break; - case WM_CLOSE: - _ecore_wince_event_handle_delete_request(data); - break; - /* GDI notifications */ - case WM_PAINT: - { - PAINTSTRUCT paint; - - if (BeginPaint(window, &paint)) - { - data->update = paint.rcPaint; - _ecore_wince_event_handle_expose(data); - EndPaint(window, &paint); - } - break; - } - default: - return DefWindowProc(window, message, window_param, data_param); - } - - return 0; -} - -static void -_ecore_wince_error_print_cb(const Eina_Log_Domain *d __UNUSED__, - Eina_Log_Level level __UNUSED__, - const char *file __UNUSED__, - const char *fnc, - int line, - const char *fmt, - void *data __UNUSED__, - va_list args) -{ - fprintf(stderr, "[%s:%d] ", fnc, line); - vfprintf(stderr, fmt, args); -} +/** + * @} + */ diff --git a/src/lib/ecore_wince/ecore_wince_event.c b/src/lib/ecore_wince/ecore_wince_event.c index 5e35b5a..e2599d9 100644 --- a/src/lib/ecore_wince/ecore_wince_event.c +++ b/src/lib/ecore_wince/ecore_wince_event.c @@ -15,8 +15,13 @@ #include "Ecore_WinCE.h" #include "ecore_wince_private.h" +/*============================================================================* + * Local * + *============================================================================*/ -/***** Private declarations *****/ +/** + * @cond LOCAL + */ static Ecore_WinCE_Window *_ecore_wince_mouse_down_last_window = NULL; static Ecore_WinCE_Window *_ecore_wince_mouse_down_last_last_window = NULL; @@ -25,282 +30,527 @@ static long _ecore_wince_mouse_down_last_last_time = 0; static int _ecore_wince_mouse_down_did_triple = 0; static int _ecore_wince_mouse_up_count = 0; - -static void _ecore_wince_event_free_key_down(void *data, - void *ev); - -static void _ecore_wince_event_free_key_up(void *data, - void *ev); - -static int _ecore_wince_event_keystroke_get(int key, - char **keyname, - char **keysymbol, - char **keycompose); - -static int _ecore_wince_event_char_get(int key, - char **keyname, - char **keysymbol, - char **keycompose); - - -/***** Global functions *****/ - -void -_ecore_wince_event_handle_key_press(Ecore_WinCE_Callback_Data *msg, - int is_keystroke) +static void +_ecore_wince_event_free_key_down(void *data __UNUSED__, + void *ev) { Ecore_Event_Key *e; - INF("key pressed"); - - e = (Ecore_Event_Key *)malloc(sizeof(Ecore_Event_Key)); - if (!e) return; - - if (is_keystroke) - { - if (!_ecore_wince_event_keystroke_get(LOWORD(msg->window_param), - (char **)&e->keyname, - (char **)&e->key, - (char **)&e->string)) - { - free(e); - return; - } - } - else - { - if (!_ecore_wince_event_char_get(LOWORD(msg->window_param), - (char **)&e->keyname, - (char **)&e->key, - (char **)&e->string)) - { - free(e); - return; - } - } - - e->window = (Ecore_Window)GetWindowLong(msg->window, GWL_USERDATA); - if (!e->window) - { - free(e); - return; - } - e->timestamp = msg->time; - - _ecore_wince_event_last_time = e->timestamp; - - ecore_event_add(ECORE_EVENT_KEY_DOWN, e, _ecore_wince_event_free_key_down, NULL); + e = ev; + if (e->keyname) free((char *)e->keyname); + if (e->key) free((char *)e->key); + if (e->string) free((char *)e->string); + free(e); } -void -_ecore_wince_event_handle_key_release(Ecore_WinCE_Callback_Data *msg, - int is_keystroke) +static void +_ecore_wince_event_free_key_up(void *data __UNUSED__, + void *ev) { Ecore_Event_Key *e; - INF("key released"); - - e = (Ecore_Event_Key *)calloc(1, sizeof(Ecore_Event_Key)); - if (!e) return; - - if (is_keystroke) - { - if (!_ecore_wince_event_keystroke_get(LOWORD(msg->window_param), - (char **)&e->keyname, - (char **)&e->key, - (char **)&e->string)) - { - free(e); - return; - } - } - else - { - if (!_ecore_wince_event_char_get(LOWORD(msg->window_param), - (char **)&e->keyname, - (char **)&e->key, - (char **)&e->string)) - { - free(e); - return; - } - } - - e->window = (Ecore_Window)GetWindowLong(msg->window, GWL_USERDATA); - if (!e->window) - { - free(e); - return; - } - e->timestamp = msg->time; - - _ecore_wince_event_last_time = e->timestamp; - - ecore_event_add(ECORE_EVENT_KEY_UP, e, _ecore_wince_event_free_key_up, NULL); -} - -void -_ecore_wince_event_handle_button_press(Ecore_WinCE_Callback_Data *msg, - int button) -{ - Ecore_WinCE_Window *window; - - INF("mouse button pressed"); - - window = (Ecore_WinCE_Window *)GetWindowLong(msg->window, GWL_USERDATA); - - { - Ecore_Event_Mouse_Move *e; - - e = (Ecore_Event_Mouse_Move *)calloc(1, sizeof(Ecore_Event_Mouse_Move)); - if (!e) return; - - e->window = (Ecore_Window)window; - e->x = LOWORD(msg->data_param); - e->y = HIWORD(msg->data_param); - e->timestamp = msg->time; - - _ecore_wince_event_last_time = e->timestamp; - _ecore_wince_event_last_window = (Ecore_WinCE_Window *)e->window; - - ecore_event_add(ECORE_EVENT_MOUSE_MOVE, e, NULL, NULL); - } - - { - Ecore_Event_Mouse_Button *e; - - if (_ecore_wince_mouse_down_did_triple) - { - _ecore_wince_mouse_down_last_window = NULL; - _ecore_wince_mouse_down_last_last_window = NULL; - _ecore_wince_mouse_down_last_time = 0; - _ecore_wince_mouse_down_last_last_time = 0; - } - - e = (Ecore_Event_Mouse_Button *)calloc(1, sizeof(Ecore_Event_Mouse_Button)); - if (!e) return; - - e->window = (Ecore_Window)window; - e->buttons = button; - e->x = LOWORD(msg->data_param); - e->y = HIWORD(msg->data_param); - e->timestamp = msg->time; - - if (((e->timestamp - _ecore_wince_mouse_down_last_time) <= (long)(1000 * _ecore_wince_double_click_time)) && - (e->window == (Ecore_Window)_ecore_wince_mouse_down_last_window)) - e->double_click = 1; - - if (((e->timestamp - _ecore_wince_mouse_down_last_last_time) <= (long)(2 * 1000 * _ecore_wince_double_click_time)) && - (e->window == (Ecore_Window)_ecore_wince_mouse_down_last_window) && - (e->window == (Ecore_Window)_ecore_wince_mouse_down_last_last_window)) - { - e->triple_click = 1; - _ecore_wince_mouse_down_did_triple = 1; - } - else - _ecore_wince_mouse_down_did_triple = 0; - - if (!e->double_click && !e->triple_click) - _ecore_wince_mouse_up_count = 0; - - _ecore_wince_event_last_time = e->timestamp; - _ecore_wince_event_last_window = (Ecore_WinCE_Window *)e->window; - - if (!_ecore_wince_mouse_down_did_triple) - { - _ecore_wince_mouse_down_last_last_window = _ecore_wince_mouse_down_last_window; - _ecore_wince_mouse_down_last_window = (Ecore_WinCE_Window *)e->window; - _ecore_wince_mouse_down_last_last_time = _ecore_wince_mouse_down_last_time; - _ecore_wince_mouse_down_last_time = e->timestamp; - } - - ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, e, NULL, NULL); - } + e = ev; + if (e->keyname) free((char *)e->keyname); + if (e->key) free((char *)e->key); + if (e->string) free((char *)e->string); + free(e); } -void -_ecore_wince_event_handle_button_release(Ecore_WinCE_Callback_Data *msg, - int button) +static int +_ecore_wince_event_keystroke_get(int key, + char **keyname, + char **keysymbol, + char **keycompose) { - Ecore_WinCE_Window *window; - - INF("mouse button released"); - - window = (void *)GetWindowLong(msg->window, GWL_USERDATA); - - { - Ecore_Event_Mouse_Move *e; - - e = (Ecore_Event_Mouse_Move *)calloc(1, sizeof(Ecore_Event_Mouse_Move)); - if (!e) return; - - e->window = (Ecore_Window)window; - e->x = LOWORD(msg->data_param); - e->y = HIWORD(msg->data_param); - e->timestamp = msg->time; - - _ecore_wince_event_last_time = e->timestamp; - _ecore_wince_event_last_window = (Ecore_WinCE_Window *)e->window; - - ecore_event_add(ECORE_EVENT_MOUSE_MOVE, e, NULL, NULL); - } - - { - Ecore_Event_Mouse_Button *e; - - e = (Ecore_Event_Mouse_Button *)calloc(1, sizeof(Ecore_Event_Mouse_Button)); - if (!e) return; - - e->window = (Ecore_Window)window; - e->buttons = button; - e->x = LOWORD(msg->data_param); - e->y = HIWORD(msg->data_param); - e->timestamp = msg->time; - - _ecore_wince_mouse_up_count++; - - if ((_ecore_wince_mouse_up_count >= 2) && - ((e->timestamp - _ecore_wince_mouse_down_last_time) <= (long)(1000 * _ecore_wince_double_click_time)) && - (e->window == (Ecore_Window)_ecore_wince_mouse_down_last_window)) - e->double_click = 1; - - if ((_ecore_wince_mouse_up_count >= 3) && - ((e->timestamp - _ecore_wince_mouse_down_last_last_time) <= (long)(2 * 1000 * _ecore_wince_double_click_time)) && - (e->window == (Ecore_Window)_ecore_wince_mouse_down_last_window) && - (e->window == (Ecore_Window)_ecore_wince_mouse_down_last_last_window)) - e->triple_click = 1; - - _ecore_wince_event_last_time = e->timestamp; - _ecore_wince_event_last_window = (Ecore_WinCE_Window *)e->window; + char *kn; + char *ks; + char *kc; - ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, e, NULL, NULL); - } -} + *keyname = NULL; + *keysymbol = NULL; + *keycompose = NULL; -void -_ecore_wince_event_handle_motion_notify(Ecore_WinCE_Callback_Data *msg) -{ - Ecore_Event_Mouse_Move *e; + switch (key) + { + /* Keystroke */ + case VK_PRIOR: + kn = "Prior"; + ks = "Prior"; + kc = "Prior"; + break; + case VK_NEXT: + kn = "Next"; + ks = "Next"; + kc = "Next"; + break; + case VK_END: + kn = "End"; + ks = "End"; + kc = "End"; + break; + case VK_HOME: + kn = "Home"; + ks = "Home"; + kc = "Home"; + break; + case VK_LEFT: + kn = "Left"; + ks = "Left"; + kc = "Left"; + break; + case VK_UP: + kn = "Up"; + ks = "Up"; + kc = "Up"; + break; + case VK_RIGHT: + kn = "Right"; + ks = "Right"; + kc = "Right"; + break; + case VK_DOWN: + kn = "Down"; + ks = "Down"; + kc = "Down"; + break; + case VK_INSERT: + kn = "Insert"; + ks = "Insert"; + kc = "Insert"; + break; + case VK_DELETE: + kn = "Delete"; + ks = "Delete"; + kc = "Delete"; + break; + case VK_F1: + kn = "F1"; + ks = "F1"; + kc = ""; + break; + case VK_F2: + kn = "F2"; + ks = "F2"; + kc = ""; + break; + case VK_F3: + kn = "F3"; + ks = "F3"; + kc = ""; + break; + case VK_F4: + kn = "F4"; + ks = "F4"; + kc = ""; + break; + case VK_F5: + kn = "F5"; + ks = "F5"; + kc = ""; + break; + case VK_F6: + kn = "F6"; + ks = "F6"; + kc = ""; + break; + case VK_F7: + kn = "F7"; + ks = "F7"; + kc = ""; + break; + case VK_F8: + kn = "F8"; + ks = "F8"; + kc = ""; + break; + case VK_F9: + kn = "F9"; + ks = "F9"; + kc = ""; + break; + case VK_F10: + kn = "F10"; + ks = "F10"; + kc = ""; + break; + case VK_F11: + kn = "F11"; + ks = "F11"; + kc = ""; + break; + case VK_F12: + kn = "F12"; + ks = "F12"; + kc = ""; + break; + case VK_F13: + kn = "F13"; + ks = "F13"; + kc = ""; + break; + case VK_F14: + kn = "F14"; + ks = "F14"; + kc = ""; + break; + case VK_F15: + kn = "F15"; + ks = "F15"; + kc = ""; + break; + case VK_F16: + kn = "F16"; + ks = "F16"; + kc = ""; + break; + case VK_F17: + kn = "F17"; + ks = "F17"; + kc = ""; + break; + case VK_F18: + kn = "F18"; + ks = "F18"; + kc = ""; + break; + case VK_F19: + kn = "F19"; + ks = "F19"; + kc = ""; + break; + case VK_F20: + /* + * VK_F20 indicates that an arrow key came from a rocker. + * This can safely be ignored. + */ + return 0; + case VK_F21: + /* + * VK_F21 indicates that an arrow key came from a directional + * pad. This can safely be ignored. + */ + return 0; + case VK_F22: + kn = "F22"; + ks = "F22"; + kc = ""; + break; + case VK_F23: + /* + * Sent with VK_RETURN when doing an action (usually the middle + * button on a directional pad. This can safely be ignored. + */ + return 0; + case VK_F24: + kn = "F24"; + ks = "F24"; + kc = ""; + break; + case VK_APPS: + kn = "Application"; + ks = "Application"; + kc = ""; + break; + case VK_MENU: + kn = "Menu"; + ks = "Menu"; + kc = ""; + break; + default: + /* other non keystroke characters */ + return 0; + } + *keyname = strdup(kn); + if (!*keyname) return 0; + *keysymbol = strdup(ks); + if (!*keysymbol) + { + free(*keyname); + *keyname = NULL; + return 0; + } + *keycompose = strdup(kc); + if (!*keycompose) + { + free(*keyname); + free(*keysymbol); + *keyname = NULL; + *keysymbol = NULL; + return 0; + } - INF("mouse moved"); + return 1; +} - e = (Ecore_Event_Mouse_Move *)calloc(1, sizeof(Ecore_Event_Mouse_Move)); +static int +_ecore_wince_event_char_get(int key, + char **keyname, + char **keysymbol, + char **keycompose) +{ + char kn[32]; + char ks[32]; + char kc[32]; + + *keyname = NULL; + *keysymbol = NULL; + *keycompose = NULL; + + switch (key) + { + case VK_APP3: + case VK_BACK: + strncpy(kn, "BackSpace", 32); + strncpy(ks, "BackSpace", 32); + strncpy(kc, "BackSpace", 32); + break; + case VK_APP4: + case VK_TAB: + strncpy(kn, "Tab", 32); + strncpy(ks, "Tab", 32); + strncpy(kc, "Tab", 32); + break; + case VK_APP5: + case 0x0a: + /* Line feed (Shift + Enter) */ + strncpy(kn, "LineFeed", 32); + strncpy(ks, "LineFeed", 32); + strncpy(kc, "LineFeed", 32); + break; + case VK_APP2: + case VK_RETURN: + strncpy(kn, "Return", 32); + strncpy(ks, "Return", 32); + strncpy(kc, "Return", 32); + break; + case VK_APP1: + case VK_ESCAPE: + strncpy(kn, "Escape", 32); + strncpy(ks, "Escape", 32); + strncpy(kc, "Escape", 32); + break; + default: + /* displayable characters */ + printf (" * key : %d\n", key); + kn[0] = (TCHAR)key; + kn[1] = '\0'; + ks[0] = (TCHAR)key; + ks[1] = '\0'; + kc[0] = (TCHAR)key; + kc[1] = '\0'; + break; + } + *keyname = strdup(kn); + if (!*keyname) return 0; + *keysymbol = strdup(ks); + if (!*keysymbol) + { + free(*keyname); + *keyname = NULL; + return 0; + } + *keycompose = strdup(kc); + if (!*keycompose) + { + free(*keyname); + free(*keysymbol); + *keyname = NULL; + *keysymbol = NULL; + return 0; + } + + return 1; +} + +/** + * @endcond + */ + + +/*============================================================================* + * Global * + *============================================================================*/ + +void +_ecore_wince_event_handle_key_press(Ecore_WinCE_Callback_Data *msg, + int is_keystroke) +{ + Ecore_Event_Key *e; + + INF("key pressed"); + + e = (Ecore_Event_Key *)malloc(sizeof(Ecore_Event_Key)); if (!e) return; + if (is_keystroke) + { + if (!_ecore_wince_event_keystroke_get(LOWORD(msg->window_param), + (char **)&e->keyname, + (char **)&e->key, + (char **)&e->string)) + { + free(e); + return; + } + } + else + { + if (!_ecore_wince_event_char_get(LOWORD(msg->window_param), + (char **)&e->keyname, + (char **)&e->key, + (char **)&e->string)) + { + free(e); + return; + } + } + e->window = (Ecore_Window)GetWindowLong(msg->window, GWL_USERDATA); - e->x = LOWORD(msg->data_param); - e->y = HIWORD(msg->data_param); + if (!e->window) + { + free(e); + return; + } e->timestamp = msg->time; - ecore_event_add(ECORE_EVENT_MOUSE_MOVE, e, NULL, NULL); + _ecore_wince_event_last_time = e->timestamp; + + ecore_event_add(ECORE_EVENT_KEY_DOWN, e, _ecore_wince_event_free_key_down, NULL); } void -_ecore_wince_event_handle_enter_notify(Ecore_WinCE_Callback_Data *msg) +_ecore_wince_event_handle_key_release(Ecore_WinCE_Callback_Data *msg, + int is_keystroke) +{ + Ecore_Event_Key *e; + + INF("key released"); + + e = (Ecore_Event_Key *)calloc(1, sizeof(Ecore_Event_Key)); + if (!e) return; + + if (is_keystroke) + { + if (!_ecore_wince_event_keystroke_get(LOWORD(msg->window_param), + (char **)&e->keyname, + (char **)&e->key, + (char **)&e->string)) + { + free(e); + return; + } + } + else + { + if (!_ecore_wince_event_char_get(LOWORD(msg->window_param), + (char **)&e->keyname, + (char **)&e->key, + (char **)&e->string)) + { + free(e); + return; + } + } + + e->window = (Ecore_Window)GetWindowLong(msg->window, GWL_USERDATA); + if (!e->window) + { + free(e); + return; + } + e->timestamp = msg->time; + + _ecore_wince_event_last_time = e->timestamp; + + ecore_event_add(ECORE_EVENT_KEY_UP, e, _ecore_wince_event_free_key_up, NULL); +} + +void +_ecore_wince_event_handle_button_press(Ecore_WinCE_Callback_Data *msg, + int button) +{ + Ecore_WinCE_Window *window; + + INF("mouse button pressed"); + + window = (Ecore_WinCE_Window *)GetWindowLong(msg->window, GWL_USERDATA); + + { + Ecore_Event_Mouse_Move *e; + + e = (Ecore_Event_Mouse_Move *)calloc(1, sizeof(Ecore_Event_Mouse_Move)); + if (!e) return; + + e->window = (Ecore_Window)window; + e->x = LOWORD(msg->data_param); + e->y = HIWORD(msg->data_param); + e->timestamp = msg->time; + + _ecore_wince_event_last_time = e->timestamp; + _ecore_wince_event_last_window = (Ecore_WinCE_Window *)e->window; + + ecore_event_add(ECORE_EVENT_MOUSE_MOVE, e, NULL, NULL); + } + + { + Ecore_Event_Mouse_Button *e; + + if (_ecore_wince_mouse_down_did_triple) + { + _ecore_wince_mouse_down_last_window = NULL; + _ecore_wince_mouse_down_last_last_window = NULL; + _ecore_wince_mouse_down_last_time = 0; + _ecore_wince_mouse_down_last_last_time = 0; + } + + e = (Ecore_Event_Mouse_Button *)calloc(1, sizeof(Ecore_Event_Mouse_Button)); + if (!e) return; + + e->window = (Ecore_Window)window; + e->buttons = button; + e->x = LOWORD(msg->data_param); + e->y = HIWORD(msg->data_param); + e->timestamp = msg->time; + + if (((e->timestamp - _ecore_wince_mouse_down_last_time) <= (long)(1000 * _ecore_wince_double_click_time)) && + (e->window == (Ecore_Window)_ecore_wince_mouse_down_last_window)) + e->double_click = 1; + + if (((e->timestamp - _ecore_wince_mouse_down_last_last_time) <= (long)(2 * 1000 * _ecore_wince_double_click_time)) && + (e->window == (Ecore_Window)_ecore_wince_mouse_down_last_window) && + (e->window == (Ecore_Window)_ecore_wince_mouse_down_last_last_window)) + { + e->triple_click = 1; + _ecore_wince_mouse_down_did_triple = 1; + } + else + _ecore_wince_mouse_down_did_triple = 0; + + if (!e->double_click && !e->triple_click) + _ecore_wince_mouse_up_count = 0; + + _ecore_wince_event_last_time = e->timestamp; + _ecore_wince_event_last_window = (Ecore_WinCE_Window *)e->window; + + if (!_ecore_wince_mouse_down_did_triple) + { + _ecore_wince_mouse_down_last_last_window = _ecore_wince_mouse_down_last_window; + _ecore_wince_mouse_down_last_window = (Ecore_WinCE_Window *)e->window; + _ecore_wince_mouse_down_last_last_time = _ecore_wince_mouse_down_last_time; + _ecore_wince_mouse_down_last_time = e->timestamp; + } + + ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, e, NULL, NULL); + } +} + +void +_ecore_wince_event_handle_button_release(Ecore_WinCE_Callback_Data *msg, + int button) { Ecore_WinCE_Window *window; - INF("mouse in"); + INF("mouse button released"); window = (void *)GetWindowLong(msg->window, GWL_USERDATA); @@ -311,8 +561,8 @@ _ecore_wince_event_handle_enter_notify(Ecore_WinCE_Callback_Data *msg) if (!e) return; e->window = (Ecore_Window)window; - e->x = msg->x; - e->y = msg->y; + e->x = LOWORD(msg->data_param); + e->y = HIWORD(msg->data_param); e->timestamp = msg->time; _ecore_wince_event_last_time = e->timestamp; @@ -322,28 +572,61 @@ _ecore_wince_event_handle_enter_notify(Ecore_WinCE_Callback_Data *msg) } { - Ecore_WinCE_Event_Mouse_In *e; + Ecore_Event_Mouse_Button *e; - e = (Ecore_WinCE_Event_Mouse_In *)calloc(1, sizeof(Ecore_WinCE_Event_Mouse_In)); + e = (Ecore_Event_Mouse_Button *)calloc(1, sizeof(Ecore_Event_Mouse_Button)); if (!e) return; - e->window = window; - e->x = msg->x; - e->y = msg->y; - e->time = msg->time; + e->window = (Ecore_Window)window; + e->buttons = button; + e->x = LOWORD(msg->data_param); + e->y = HIWORD(msg->data_param); + e->timestamp = msg->time; - _ecore_wince_event_last_time = e->time; + _ecore_wince_mouse_up_count++; - ecore_event_add(ECORE_WINCE_EVENT_MOUSE_IN, e, NULL, NULL); + if ((_ecore_wince_mouse_up_count >= 2) && + ((e->timestamp - _ecore_wince_mouse_down_last_time) <= (long)(1000 * _ecore_wince_double_click_time)) && + (e->window == (Ecore_Window)_ecore_wince_mouse_down_last_window)) + e->double_click = 1; + + if ((_ecore_wince_mouse_up_count >= 3) && + ((e->timestamp - _ecore_wince_mouse_down_last_last_time) <= (long)(2 * 1000 * _ecore_wince_double_click_time)) && + (e->window == (Ecore_Window)_ecore_wince_mouse_down_last_window) && + (e->window == (Ecore_Window)_ecore_wince_mouse_down_last_last_window)) + e->triple_click = 1; + + _ecore_wince_event_last_time = e->timestamp; + _ecore_wince_event_last_window = (Ecore_WinCE_Window *)e->window; + + ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, e, NULL, NULL); } } void -_ecore_wince_event_handle_leave_notify(Ecore_WinCE_Callback_Data *msg) +_ecore_wince_event_handle_motion_notify(Ecore_WinCE_Callback_Data *msg) +{ + Ecore_Event_Mouse_Move *e; + + INF("mouse moved"); + + e = (Ecore_Event_Mouse_Move *)calloc(1, sizeof(Ecore_Event_Mouse_Move)); + if (!e) return; + + e->window = (Ecore_Window)GetWindowLong(msg->window, GWL_USERDATA); + e->x = LOWORD(msg->data_param); + e->y = HIWORD(msg->data_param); + e->timestamp = msg->time; + + ecore_event_add(ECORE_EVENT_MOUSE_MOVE, e, NULL, NULL); +} + +void +_ecore_wince_event_handle_enter_notify(Ecore_WinCE_Callback_Data *msg) { Ecore_WinCE_Window *window; - INF("mouse out"); + INF("mouse in"); window = (void *)GetWindowLong(msg->window, GWL_USERDATA); @@ -365,9 +648,9 @@ _ecore_wince_event_handle_leave_notify(Ecore_WinCE_Callback_Data *msg) } { - Ecore_WinCE_Event_Mouse_Out *e; + Ecore_WinCE_Event_Mouse_In *e; - e = (Ecore_WinCE_Event_Mouse_Out *)calloc(1, sizeof(Ecore_WinCE_Event_Mouse_Out)); + e = (Ecore_WinCE_Event_Mouse_In *)calloc(1, sizeof(Ecore_WinCE_Event_Mouse_In)); if (!e) return; e->window = window; @@ -377,537 +660,250 @@ _ecore_wince_event_handle_leave_notify(Ecore_WinCE_Callback_Data *msg) _ecore_wince_event_last_time = e->time; - ecore_event_add(ECORE_WINCE_EVENT_MOUSE_OUT, e, NULL, NULL); + ecore_event_add(ECORE_WINCE_EVENT_MOUSE_IN, e, NULL, NULL); } } void -_ecore_wince_event_handle_focus_in(Ecore_WinCE_Callback_Data *msg) -{ - Ecore_WinCE_Event_Window_Focus_In *e; - struct _Ecore_WinCE_Window *window; - - INF("focus in"); - - e = (Ecore_WinCE_Event_Window_Focus_In *)calloc(1, sizeof(Ecore_WinCE_Event_Window_Focus_In)); - if (!e) return; - - window = (void *)GetWindowLong(msg->window, GWL_USERDATA); - if (!e->window) - { - free(e); - return; - } - - if (window->resume) - window->resume(window->backend); - - e->window = window; - - e->time = _ecore_wince_event_last_time; - _ecore_wince_event_last_time = e->time; - - ecore_event_add(ECORE_WINCE_EVENT_WINDOW_FOCUS_IN, e, NULL, NULL); -} - -void -_ecore_wince_event_handle_focus_out(Ecore_WinCE_Callback_Data *msg) -{ - Ecore_WinCE_Event_Window_Focus_Out *e; - struct _Ecore_WinCE_Window *window; - - INF("focus out"); - - e = (Ecore_WinCE_Event_Window_Focus_Out *)calloc(1, sizeof(Ecore_WinCE_Event_Window_Focus_Out)); - if (!e) return; - - window = (void *)GetWindowLong(msg->window, GWL_USERDATA); - if (!e->window) - { - free(e); - return; - } - if (window->suspend) - window->suspend(window->backend); - - e->window = window; - - e->time = _ecore_wince_event_last_time; - _ecore_wince_event_last_time = e->time; - - ecore_event_add(ECORE_WINCE_EVENT_WINDOW_FOCUS_OUT, e, NULL, NULL); -} - -void -_ecore_wince_event_handle_expose(Ecore_WinCE_Callback_Data *msg) -{ - Ecore_WinCE_Event_Window_Damage *e; - - INF("window expose"); - - e = (Ecore_WinCE_Event_Window_Damage *)calloc(1, sizeof(Ecore_WinCE_Event_Window_Damage)); - if (!e) return; - - e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA); - if (!e->window) - { - free(e); - return; - } - - e->x = msg->update.left; - e->y = msg->update.top; - e->width = msg->update.right - msg->update.left; - e->height = msg->update.bottom - msg->update.top; - INF("window expose size: %dx%d", e->width, e->height); - - e->time = _ecore_wince_event_last_time; - - ecore_event_add(ECORE_WINCE_EVENT_WINDOW_DAMAGE, e, NULL, NULL); -} - -void -_ecore_wince_event_handle_create_notify(Ecore_WinCE_Callback_Data *msg) -{ - Ecore_WinCE_Event_Window_Create *e; - - INF("window create notify"); - - e = calloc(1, sizeof(Ecore_WinCE_Event_Window_Create)); - if (!e) return; - - e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA); - if (!e->window) - { - free(e); - return; - } - - e->time = _ecore_wince_event_last_time; - - ecore_event_add(ECORE_WINCE_EVENT_WINDOW_CREATE, e, NULL, NULL); -} - -void -_ecore_wince_event_handle_destroy_notify(Ecore_WinCE_Callback_Data *msg) -{ - Ecore_WinCE_Event_Window_Destroy *e; - - INF("window destroy notify"); - - e = calloc(1, sizeof(Ecore_WinCE_Event_Window_Destroy)); - if (!e) return; - - e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA); - if (!e->window) - { - free(e); - return; - } - - e->time = _ecore_wince_event_last_time; -/* if (e->window == _ecore_wince_event_last_window) _ecore_wince_event_last_window = NULL; */ - - ecore_event_add(ECORE_WINCE_EVENT_WINDOW_DESTROY, e, NULL, NULL); -} - -void -_ecore_wince_event_handle_map_notify(Ecore_WinCE_Callback_Data *msg) -{ - Ecore_WinCE_Event_Window_Show *e; - - INF("window map notify"); - - e = calloc(1, sizeof(Ecore_WinCE_Event_Window_Show)); - if (!e) return; - - e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA); - if (!e->window) - { - free(e); - return; - } - - e->time = _ecore_wince_event_last_time; - - ecore_event_add(ECORE_WINCE_EVENT_WINDOW_SHOW, e, NULL, NULL); -} - -void -_ecore_wince_event_handle_unmap_notify(Ecore_WinCE_Callback_Data *msg) -{ - Ecore_WinCE_Event_Window_Hide *e; - - INF("window unmap notify"); - - e = calloc(1, sizeof(Ecore_WinCE_Event_Window_Hide)); - if (!e) return; - - e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA); - if (!e->window) - { - free(e); - return; - } - - e->time = _ecore_wince_event_last_time; - - ecore_event_add(ECORE_WINCE_EVENT_WINDOW_HIDE, e, NULL, NULL); -} - -void -_ecore_wince_event_handle_delete_request(Ecore_WinCE_Callback_Data *msg) +_ecore_wince_event_handle_leave_notify(Ecore_WinCE_Callback_Data *msg) { - Ecore_WinCE_Event_Window_Delete_Request *e; - - INF("window delete request"); + Ecore_WinCE_Window *window; - e = calloc(1, sizeof(Ecore_WinCE_Event_Window_Delete_Request)); - if (!e) return; + INF("mouse out"); - e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA); - if (!e->window) - { - free(e); - return; - } + window = (void *)GetWindowLong(msg->window, GWL_USERDATA); - e->time = _ecore_wince_event_last_time; + { + Ecore_Event_Mouse_Move *e; - ecore_event_add(ECORE_WINCE_EVENT_WINDOW_DELETE_REQUEST, e, NULL, NULL); -} + e = (Ecore_Event_Mouse_Move *)calloc(1, sizeof(Ecore_Event_Mouse_Move)); + if (!e) return; + e->window = (Ecore_Window)window; + e->x = msg->x; + e->y = msg->y; + e->timestamp = msg->time; -/***** Private functions definitions *****/ + _ecore_wince_event_last_time = e->timestamp; + _ecore_wince_event_last_window = (Ecore_WinCE_Window *)e->window; -static void -_ecore_wince_event_free_key_down(void *data __UNUSED__, - void *ev) -{ - Ecore_Event_Key *e; + ecore_event_add(ECORE_EVENT_MOUSE_MOVE, e, NULL, NULL); + } - e = ev; - if (e->keyname) free((char *)e->keyname); - if (e->key) free((char *)e->key); - if (e->string) free((char *)e->string); - free(e); -} + { + Ecore_WinCE_Event_Mouse_Out *e; -static void -_ecore_wince_event_free_key_up(void *data __UNUSED__, - void *ev) -{ - Ecore_Event_Key *e; + e = (Ecore_WinCE_Event_Mouse_Out *)calloc(1, sizeof(Ecore_WinCE_Event_Mouse_Out)); + if (!e) return; - e = ev; - if (e->keyname) free((char *)e->keyname); - if (e->key) free((char *)e->key); - if (e->string) free((char *)e->string); - free(e); -} + e->window = window; + e->x = msg->x; + e->y = msg->y; + e->time = msg->time; -static int -_ecore_wince_event_keystroke_get(int key, - char **keyname, - char **keysymbol, - char **keycompose) -{ - char *kn; - char *ks; - char *kc; + _ecore_wince_event_last_time = e->time; - *keyname = NULL; - *keysymbol = NULL; - *keycompose = NULL; + ecore_event_add(ECORE_WINCE_EVENT_MOUSE_OUT, e, NULL, NULL); + } +} - switch (key) - { - /* Keystroke */ - case VK_PRIOR: - kn = "Prior"; - ks = "Prior"; - kc = "Prior"; - break; - case VK_NEXT: - kn = "Next"; - ks = "Next"; - kc = "Next"; - break; - case VK_END: - kn = "End"; - ks = "End"; - kc = "End"; - break; - case VK_HOME: - kn = "Home"; - ks = "Home"; - kc = "Home"; - break; - case VK_LEFT: - kn = "Left"; - ks = "Left"; - kc = "Left"; - break; - case VK_UP: - kn = "Up"; - ks = "Up"; - kc = "Up"; - break; - case VK_RIGHT: - kn = "Right"; - ks = "Right"; - kc = "Right"; - break; - case VK_DOWN: - kn = "Down"; - ks = "Down"; - kc = "Down"; - break; - case VK_INSERT: - kn = "Insert"; - ks = "Insert"; - kc = "Insert"; - break; - case VK_DELETE: - kn = "Delete"; - ks = "Delete"; - kc = "Delete"; - break; - case VK_F1: - kn = "F1"; - ks = "F1"; - kc = ""; - break; - case VK_F2: - kn = "F2"; - ks = "F2"; - kc = ""; - break; - case VK_F3: - kn = "F3"; - ks = "F3"; - kc = ""; - break; - case VK_F4: - kn = "F4"; - ks = "F4"; - kc = ""; - break; - case VK_F5: - kn = "F5"; - ks = "F5"; - kc = ""; - break; - case VK_F6: - kn = "F6"; - ks = "F6"; - kc = ""; - break; - case VK_F7: - kn = "F7"; - ks = "F7"; - kc = ""; - break; - case VK_F8: - kn = "F8"; - ks = "F8"; - kc = ""; - break; - case VK_F9: - kn = "F9"; - ks = "F9"; - kc = ""; - break; - case VK_F10: - kn = "F10"; - ks = "F10"; - kc = ""; - break; - case VK_F11: - kn = "F11"; - ks = "F11"; - kc = ""; - break; - case VK_F12: - kn = "F12"; - ks = "F12"; - kc = ""; - break; - case VK_F13: - kn = "F13"; - ks = "F13"; - kc = ""; - break; - case VK_F14: - kn = "F14"; - ks = "F14"; - kc = ""; - break; - case VK_F15: - kn = "F15"; - ks = "F15"; - kc = ""; - break; - case VK_F16: - kn = "F16"; - ks = "F16"; - kc = ""; - break; - case VK_F17: - kn = "F17"; - ks = "F17"; - kc = ""; - break; - case VK_F18: - kn = "F18"; - ks = "F18"; - kc = ""; - break; - case VK_F19: - kn = "F19"; - ks = "F19"; - kc = ""; - break; - case VK_F20: - /* - * VK_F20 indicates that an arrow key came from a rocker. - * This can safely be ignored. - */ - return 0; - case VK_F21: - /* - * VK_F21 indicates that an arrow key came from a directional - * pad. This can safely be ignored. - */ - return 0; - case VK_F22: - kn = "F22"; - ks = "F22"; - kc = ""; - break; - case VK_F23: - /* - * Sent with VK_RETURN when doing an action (usually the middle - * button on a directional pad. This can safely be ignored. - */ - return 0; - case VK_F24: - kn = "F24"; - ks = "F24"; - kc = ""; - break; - case VK_APPS: - kn = "Application"; - ks = "Application"; - kc = ""; - break; - case VK_MENU: - kn = "Menu"; - ks = "Menu"; - kc = ""; - break; - default: - /* other non keystroke characters */ - return 0; +void +_ecore_wince_event_handle_focus_in(Ecore_WinCE_Callback_Data *msg) +{ + Ecore_WinCE_Event_Window_Focus_In *e; + struct _Ecore_WinCE_Window *window; + + INF("focus in"); + + e = (Ecore_WinCE_Event_Window_Focus_In *)calloc(1, sizeof(Ecore_WinCE_Event_Window_Focus_In)); + if (!e) return; + + window = (void *)GetWindowLong(msg->window, GWL_USERDATA); + if (!e->window) + { + free(e); + return; } - *keyname = strdup(kn); - if (!*keyname) return 0; - *keysymbol = strdup(ks); - if (!*keysymbol) + + if (window->resume) + window->resume(window->backend); + + e->window = window; + + e->time = _ecore_wince_event_last_time; + _ecore_wince_event_last_time = e->time; + + ecore_event_add(ECORE_WINCE_EVENT_WINDOW_FOCUS_IN, e, NULL, NULL); +} + +void +_ecore_wince_event_handle_focus_out(Ecore_WinCE_Callback_Data *msg) +{ + Ecore_WinCE_Event_Window_Focus_Out *e; + struct _Ecore_WinCE_Window *window; + + INF("focus out"); + + e = (Ecore_WinCE_Event_Window_Focus_Out *)calloc(1, sizeof(Ecore_WinCE_Event_Window_Focus_Out)); + if (!e) return; + + window = (void *)GetWindowLong(msg->window, GWL_USERDATA); + if (!e->window) { - free(*keyname); - *keyname = NULL; - return 0; + free(e); + return; } - *keycompose = strdup(kc); - if (!*keycompose) + if (window->suspend) + window->suspend(window->backend); + + e->window = window; + + e->time = _ecore_wince_event_last_time; + _ecore_wince_event_last_time = e->time; + + ecore_event_add(ECORE_WINCE_EVENT_WINDOW_FOCUS_OUT, e, NULL, NULL); +} + +void +_ecore_wince_event_handle_expose(Ecore_WinCE_Callback_Data *msg) +{ + Ecore_WinCE_Event_Window_Damage *e; + + INF("window expose"); + + e = (Ecore_WinCE_Event_Window_Damage *)calloc(1, sizeof(Ecore_WinCE_Event_Window_Damage)); + if (!e) return; + + e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA); + if (!e->window) { - free(*keyname); - free(*keysymbol); - *keyname = NULL; - *keysymbol = NULL; - return 0; + free(e); + return; } - return 1; + e->x = msg->update.left; + e->y = msg->update.top; + e->width = msg->update.right - msg->update.left; + e->height = msg->update.bottom - msg->update.top; + INF("window expose size: %dx%d", e->width, e->height); + + e->time = _ecore_wince_event_last_time; + + ecore_event_add(ECORE_WINCE_EVENT_WINDOW_DAMAGE, e, NULL, NULL); } -static int -_ecore_wince_event_char_get(int key, - char **keyname, - char **keysymbol, - char **keycompose) +void +_ecore_wince_event_handle_create_notify(Ecore_WinCE_Callback_Data *msg) { - char kn[32]; - char ks[32]; - char kc[32]; + Ecore_WinCE_Event_Window_Create *e; - *keyname = NULL; - *keysymbol = NULL; - *keycompose = NULL; + INF("window create notify"); - switch (key) + e = calloc(1, sizeof(Ecore_WinCE_Event_Window_Create)); + if (!e) return; + + e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA); + if (!e->window) { - case VK_APP3: - case VK_BACK: - strncpy(kn, "BackSpace", 32); - strncpy(ks, "BackSpace", 32); - strncpy(kc, "BackSpace", 32); - break; - case VK_APP4: - case VK_TAB: - strncpy(kn, "Tab", 32); - strncpy(ks, "Tab", 32); - strncpy(kc, "Tab", 32); - break; - case VK_APP5: - case 0x0a: - /* Line feed (Shift + Enter) */ - strncpy(kn, "LineFeed", 32); - strncpy(ks, "LineFeed", 32); - strncpy(kc, "LineFeed", 32); - break; - case VK_APP2: - case VK_RETURN: - strncpy(kn, "Return", 32); - strncpy(ks, "Return", 32); - strncpy(kc, "Return", 32); - break; - case VK_APP1: - case VK_ESCAPE: - strncpy(kn, "Escape", 32); - strncpy(ks, "Escape", 32); - strncpy(kc, "Escape", 32); - break; - default: - /* displayable characters */ - printf (" * key : %d\n", key); - kn[0] = (TCHAR)key; - kn[1] = '\0'; - ks[0] = (TCHAR)key; - ks[1] = '\0'; - kc[0] = (TCHAR)key; - kc[1] = '\0'; - break; + free(e); + return; } - *keyname = strdup(kn); - if (!*keyname) return 0; - *keysymbol = strdup(ks); - if (!*keysymbol) + + e->time = _ecore_wince_event_last_time; + + ecore_event_add(ECORE_WINCE_EVENT_WINDOW_CREATE, e, NULL, NULL); +} + +void +_ecore_wince_event_handle_destroy_notify(Ecore_WinCE_Callback_Data *msg) +{ + Ecore_WinCE_Event_Window_Destroy *e; + + INF("window destroy notify"); + + e = calloc(1, sizeof(Ecore_WinCE_Event_Window_Destroy)); + if (!e) return; + + e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA); + if (!e->window) { - free(*keyname); - *keyname = NULL; - return 0; + free(e); + return; } - *keycompose = strdup(kc); - if (!*keycompose) + + e->time = _ecore_wince_event_last_time; +/* if (e->window == _ecore_wince_event_last_window) _ecore_wince_event_last_window = NULL; */ + + ecore_event_add(ECORE_WINCE_EVENT_WINDOW_DESTROY, e, NULL, NULL); +} + +void +_ecore_wince_event_handle_map_notify(Ecore_WinCE_Callback_Data *msg) +{ + Ecore_WinCE_Event_Window_Show *e; + + INF("window map notify"); + + e = calloc(1, sizeof(Ecore_WinCE_Event_Window_Show)); + if (!e) return; + + e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA); + if (!e->window) { - free(*keyname); - free(*keysymbol); - *keyname = NULL; - *keysymbol = NULL; - return 0; + free(e); + return; } - return 1; + e->time = _ecore_wince_event_last_time; + + ecore_event_add(ECORE_WINCE_EVENT_WINDOW_SHOW, e, NULL, NULL); +} + +void +_ecore_wince_event_handle_unmap_notify(Ecore_WinCE_Callback_Data *msg) +{ + Ecore_WinCE_Event_Window_Hide *e; + + INF("window unmap notify"); + + e = calloc(1, sizeof(Ecore_WinCE_Event_Window_Hide)); + if (!e) return; + + e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA); + if (!e->window) + { + free(e); + return; + } + + e->time = _ecore_wince_event_last_time; + + ecore_event_add(ECORE_WINCE_EVENT_WINDOW_HIDE, e, NULL, NULL); +} + +void +_ecore_wince_event_handle_delete_request(Ecore_WinCE_Callback_Data *msg) +{ + Ecore_WinCE_Event_Window_Delete_Request *e; + + INF("window delete request"); + + e = calloc(1, sizeof(Ecore_WinCE_Event_Window_Delete_Request)); + if (!e) return; + + e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA); + if (!e->window) + { + free(e); + return; + } + + e->time = _ecore_wince_event_last_time; + + ecore_event_add(ECORE_WINCE_EVENT_WINDOW_DELETE_REQUEST, e, NULL, NULL); } + +/*============================================================================* + * API * + *============================================================================*/ + diff --git a/src/lib/ecore_wince/ecore_wince_window.c b/src/lib/ecore_wince/ecore_wince_window.c index 1863f07..12cbcfb 100644 --- a/src/lib/ecore_wince/ecore_wince_window.c +++ b/src/lib/ecore_wince/ecore_wince_window.c @@ -12,17 +12,87 @@ #include "Ecore_WinCE.h" #include "ecore_wince_private.h" +/*============================================================================* + * Local * + *============================================================================*/ + +/** + * @cond LOCAL + */ -/***** Private declarations *****/ typedef BOOL (__stdcall *UnregisterFunc1Proc)(UINT, UINT); -static int _ecore_wince_hardware_keys_register(HWND window); +static int +_ecore_wince_hardware_keys_register(HWND window) +{ + HINSTANCE core_dll; + UnregisterFunc1Proc unregister_fct; + int i; + core_dll = LoadLibrary(L"coredll.dll"); + if (!core_dll) + { + ERR("LoadLibrary() failed"); + return 0; + } -/***** API *****/ + unregister_fct = (UnregisterFunc1Proc)GetProcAddress(core_dll, L"UnregisterFunc1"); + if (!unregister_fct) + { + ERR("GetProcAddress() failed"); + FreeLibrary(core_dll); + return 0; + } + + for (i = 0xc1; i <= 0xcf; i++) + { + unregister_fct(MOD_WIN, i); + RegisterHotKey(window, i, MOD_WIN, i); + } + + FreeLibrary(core_dll); + + return 1; +} -Ecore_WinCE_Window * +/** + * @endcond + */ + + +/*============================================================================* + * Global * + *============================================================================*/ + +/*============================================================================* + * API * + *============================================================================*/ + +/** + * @addtogroup Ecore_WinCE_Group Ecore_WinCE library + * + * @{ + */ + +/** + * @brief Creates a new window. + * + * @param parent The parent window. + * @param x The x coordinate of the top-left corner of the window. + * @param y The y coordinate of the top-left corner of the window. + * @param width The width of the window. + * @param height The height of hte window. + * @return A newly allocated window. + * + * This function creates a new window which parent is @p parent. @p width and + * @p height are the size of the window content (the client part), + * without the border and title bar. @p x and @p y are the system + * coordinates of the top left cerner of the window (that is, of the + * title bar). This function returns a newly created window on + * success, and @c NULL on failure. + */ +EAPI Ecore_WinCE_Window * ecore_wince_window_new(Ecore_WinCE_Window *parent, int x, int y, @@ -92,7 +162,15 @@ ecore_wince_window_new(Ecore_WinCE_Window *parent, return w; } -void +/** + * @brief Free the given window. + * + * @param window The window to free. + * + * This function frees @p window. If @p window is @c NULL, this + * function does nothing. + */ +EAPI void ecore_wince_window_free(Ecore_WinCE_Window *window) { if (!window) return; @@ -103,7 +181,15 @@ ecore_wince_window_free(Ecore_WinCE_Window *window) free(window); } -void * +/** + * @brief Return the window HANDLE associated to the given window. + * + * @param window The window to retrieve the HANDLE from. + * + * This function returns the window HANDLE associated to @p window. If + * @p window is @c NULL, this function returns @c NULL. + */ +EAPI void * ecore_wince_window_hwnd_get(Ecore_WinCE_Window *window) { if (!window) @@ -112,7 +198,18 @@ ecore_wince_window_hwnd_get(Ecore_WinCE_Window *window) return ((struct _Ecore_WinCE_Window *)window)->window; } -void +/** + * @brief Move the given window to a given position. + * + * @param window The window to move. + * @param x The x coordinate of the destination position. + * @param y The y coordinate of the destination position. + * + * This function move @p window to the new position of coordinates @p x + * and @p y. If @p window is @c NULL, or if it is fullscreen, or on + * error, this function does nothing. + */ +EAPI void ecore_wince_window_move(Ecore_WinCE_Window *window, int x, int y) @@ -141,7 +238,18 @@ ecore_wince_window_move(Ecore_WinCE_Window *window, } } -void +/** + * @brief Resize the given window to a given size. + * + * @param window The window to resize. + * @param width The new width. + * @param height The new height. + * + * This function resize @p window to the new @p width and @p height. + * If @p window is @c NULL, or if it is fullscreen, or on error, this + * function does nothing. + */ +EAPI void ecore_wince_window_resize(Ecore_WinCE_Window *window, int width, int height) @@ -196,7 +304,20 @@ ecore_wince_window_resize(Ecore_WinCE_Window *window, } } -void +/** + * @brief Move and resize the given window to a given position and size. + * + * @param window The window to move and resize. + * @param x The x coordinate of the destination position. + * @param y The x coordinate of the destination position. + * @param width The new width. + * @param height The new height. + * + * This function resize @p window to the new position of coordinates @p x + * and @p y and the new @p width and @p height. If @p window is @c NULL, + * or if it is fullscreen, or on error, this function does nothing. + */ +EAPI void ecore_wince_window_move_resize(Ecore_WinCE_Window *window, int x, int y, @@ -243,7 +364,15 @@ ecore_wince_window_move_resize(Ecore_WinCE_Window *window, } } -void +/** + * @brief Show the given window. + * + * @param window The window to show. + * + * This function shows @p window. If @p window is @c NULL, or on + * error, this function does nothing. + */ +EAPI void ecore_wince_window_show(Ecore_WinCE_Window *window) { if (!window) return; @@ -265,7 +394,15 @@ ecore_wince_window_show(Ecore_WinCE_Window *window) } } -void +/** + * @brief Hide the given window. + * + * @param window The window to show. + * + * This function hides @p window. If @p window is @c NULL, or on + * error, this function does nothing. + */ +EAPI void ecore_wince_window_hide(Ecore_WinCE_Window *window) { if (!window) return; @@ -283,7 +420,17 @@ ecore_wince_window_hide(Ecore_WinCE_Window *window) } } -void +/** + * @brief Set the title of the given window. + * + * @param window The window to set the title. + * @param title The new title. + * + * This function sets the title of @p window to @p title. If @p window + * is @c NULL, or if @p title is @c NULL or empty, or on error, this + * function does nothing. + */ +EAPI void ecore_wince_window_title_set(Ecore_WinCE_Window *window, const char *title) { @@ -305,8 +452,30 @@ ecore_wince_window_title_set(Ecore_WinCE_Window *window, free(wtitle); } -void -ecore_wince_window_backend_set(Ecore_WinCE_Window *window, int backend) +/** + * @brief Set the graphic backend used for the given window. + * + * @param window The window. + * @param backend The backend. + * + * This function sets the graphic backend to use with @p window to + * @p backend. If @p window if @c NULL, this function does nothing. + * + * The valid values for @p backend are + * + * @li 0: automatic choice of the backend. + * @li 1: the framebuffer (fast but could be not well suported). + * @li 2: GAPI (less fast but almost always supported). + * @li 3: DirectDraw (less fast than GAPI but almost always + * supported). + * @li 4: GDI (the slowest but always supported). + * + * The @p backend is used only in Evas and Ecore_Evas. So this + * function should not be called if Ecore_Evas is used. + */ +EAPI void +ecore_wince_window_backend_set(Ecore_WinCE_Window *window, + int backend) { struct _Ecore_WinCE_Window *w; @@ -319,8 +488,20 @@ ecore_wince_window_backend_set(Ecore_WinCE_Window *window, int backend) w->backend = backend; } -void -ecore_wince_window_suspend_set(Ecore_WinCE_Window *window, int (*suspend)(int)) +/** + * @brief Set the suspend callback used for the given window. + * + * @param window The window. + * @param suspend_cb The suspend callback. + * + * This function sets the suspend callback to use with @p window to + * @p suspend_cb. If @p window if @c NULL, this function does nothing. + * + * The @p suspend_cb is used only in Evas and Ecore_Evas. So this + * function should not be called if Ecore_Evas is used. + */ +EAPI void +ecore_wince_window_suspend_set(Ecore_WinCE_Window *window, int (*suspend_cb)(int)) { struct _Ecore_WinCE_Window *w; @@ -333,8 +514,20 @@ ecore_wince_window_suspend_set(Ecore_WinCE_Window *window, int (*suspend)(int)) w->suspend = suspend; } -void -ecore_wince_window_resume_set(Ecore_WinCE_Window *window, int (*resume)(int)) +/** + * @brief Set the resume callback used for the given window. + * + * @param window The window. + * @param resume_cb The resume callback. + * + * This function sets the resume callback to use with @p window to + * @p resume_cb. If @p window if @c NULL, this function does nothing. + * + * The @p resume_cb is used only in Evas and Ecore_Evas. So this + * function should not be called if Ecore_Evas is used. + */ +EAPI void +ecore_wince_window_resume_set(Ecore_WinCE_Window *window, int (*resume_cb)(int)) { struct _Ecore_WinCE_Window *w; @@ -347,7 +540,23 @@ ecore_wince_window_resume_set(Ecore_WinCE_Window *window, int (*resume)(int)) w->resume = resume; } -void +/** + * @brief Get the geometry of the given window. + * + * @param window The window to retrieve the geometry from. + * @param x The x coordinate of the position. + * @param y The x coordinate of the position. + * @param width The width. + * @param height The height. + * + * This function retrieves the position and size of @p window. @p x, + * @p y, @p width and @p height can be buffers that will be filled with + * the corresponding values. If one of them is @c NULL, nothing will + * be done for that parameter. If @p window is @c NULL, and if the + * buffers are not @c NULL, they will be filled with respectively 0, + * 0, the size of the screen and the height of the screen. + */ +EAPI void ecore_wince_window_geometry_get(Ecore_WinCE_Window *window, int *x, int *y, @@ -405,7 +614,21 @@ ecore_wince_window_geometry_get(Ecore_WinCE_Window *window, if (height) *height = h; } -void +/** + * @brief Get the size of the given window. + * + * @param window The window to retrieve the size from. + * @param width The width. + * @param height The height. + * + * This function retrieves the size of @p window. @p width and + * @p height can be buffers that will be filled with the corresponding + * values. If one of them is @c NULL, nothing will be done for that + * parameter. If @p window is @c NULL, and if the buffers are not + * @c NULL, they will be filled with respectively the size of the screen + * and the height of the screen. + */ +EAPI void ecore_wince_window_size_get(Ecore_WinCE_Window *window, int *width, int *height) @@ -435,9 +658,21 @@ ecore_wince_window_size_get(Ecore_WinCE_Window *window, if (height) *height = rect.bottom - rect.top; } -void +/** + * @brief Set the given window to fullscreen. + * + * @param window The window. + * @param on EINA_TRUE for fullscreen mode, EINA_FALSE for windowed mode. + * + * This function set @p window to fullscreen or windowed mode. If @p on + * is set to EINA_TRUE, the window will be fullscreen, if it is set to + * EINA_FALSE, it will be windowed. If @p window is @c NULL or if the + * state does not change (like setting to fullscreen while the window + * is already fullscreen), this function does nothing. + */ +EAPI void ecore_wince_window_fullscreen_set(Ecore_WinCE_Window *window, - int on) + Eina_Bool on) { struct _Ecore_WinCE_Window *ew; HWND w; @@ -555,38 +790,6 @@ ecore_wince_window_fullscreen_set(Ecore_WinCE_Window *window, } } - -/***** Private functions definitions *****/ - -static int -_ecore_wince_hardware_keys_register(HWND window) -{ - HINSTANCE core_dll; - UnregisterFunc1Proc unregister_fct; - int i; - - core_dll = LoadLibrary(L"coredll.dll"); - if (!core_dll) - { - ERR("LoadLibrary() failed"); - return 0; - } - - unregister_fct = (UnregisterFunc1Proc)GetProcAddress(core_dll, L"UnregisterFunc1"); - if (!unregister_fct) - { - ERR("GetProcAddress() failed"); - FreeLibrary(core_dll); - return 0; - } - - for (i = 0xc1; i <= 0xcf; i++) - { - unregister_fct(MOD_WIN, i); - RegisterHotKey(window, i, MOD_WIN, i); - } - - FreeLibrary(core_dll); - - return 1; -} +/** + * @} + */ -- 2.7.4