ecore_win32: add support of X11 shaped cursors

@feature

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
Vincent Torri 2015-10-16 07:08:09 +02:00 committed by Cedric BAIL
parent abf4364b30
commit ba4fbb99bc
7 changed files with 5821 additions and 14 deletions

View File

@ -20,6 +20,7 @@ lib/ecore_win32/ecore_win32_dnd_drop_target.cpp \
lib/ecore_win32/ecore_win32_event.c \
lib/ecore_win32/ecore_win32_window.c \
lib/ecore_win32/ecore_win32_private.h \
lib/ecore_win32/ecore_win32_cursor_x11.h \
lib/ecore_win32/ecore_win32_dnd_enumformatetc.h \
lib/ecore_win32/ecore_win32_dnd_data_object.h \
lib/ecore_win32/ecore_win32_dnd_drop_source.h \

View File

@ -116,6 +116,91 @@ typedef enum
ECORE_WIN32_CURSOR_SHAPE_WAIT /**< Hourglass */
} Ecore_Win32_Cursor_Shape;
/**
* @typedef Ecore_Win32_Cursor_X11_Shape
* Shape of an X11 cursor.
*/
typedef enum
{
ECORE_WIN32_CURSOR_X11_SHAPE_X,
ECORE_WIN32_CURSOR_X11_SHAPE_ARROW,
ECORE_WIN32_CURSOR_X11_SHAPE_BASED_ARROW_DOWN,
ECORE_WIN32_CURSOR_X11_SHAPE_UP,
ECORE_WIN32_CURSOR_X11_SHAPE_BOAT,
ECORE_WIN32_CURSOR_X11_SHAPE_BOGOSITY,
ECORE_WIN32_CURSOR_X11_SHAPE_BOTTOM_LEFT_CORNER,
ECORE_WIN32_CURSOR_X11_SHAPE_BOTTOM_RIGHT_CORNER,
ECORE_WIN32_CURSOR_X11_SHAPE_BOTTOM_SIDE,
ECORE_WIN32_CURSOR_X11_SHAPE_BOTTOM_TEE,
ECORE_WIN32_CURSOR_X11_SHAPE_BOX_SPIRAL,
ECORE_WIN32_CURSOR_X11_SHAPE_CENTER_PTR,
ECORE_WIN32_CURSOR_X11_SHAPE_CIRCLE,
ECORE_WIN32_CURSOR_X11_SHAPE_CLOCK,
ECORE_WIN32_CURSOR_X11_SHAPE_COFFEE_MUG,
ECORE_WIN32_CURSOR_X11_SHAPE_CROSS,
ECORE_WIN32_CURSOR_X11_SHAPE_CROSS_REVERSE,
ECORE_WIN32_CURSOR_X11_SHAPE_CROSSHAIR,
ECORE_WIN32_CURSOR_X11_SHAPE_DIAMOND_CROSS,
ECORE_WIN32_CURSOR_X11_SHAPE_DOT,
ECORE_WIN32_CURSOR_X11_SHAPE_DOT_BOX_MASK,
ECORE_WIN32_CURSOR_X11_SHAPE_DOUBLE_ARROW,
ECORE_WIN32_CURSOR_X11_SHAPE_DRAFT_LARGE,
ECORE_WIN32_CURSOR_X11_SHAPE_DRAFT_SMALL,
ECORE_WIN32_CURSOR_X11_SHAPE_DRAPED_BOX,
ECORE_WIN32_CURSOR_X11_SHAPE_EXCHANGE,
ECORE_WIN32_CURSOR_X11_SHAPE_FLEUR,
ECORE_WIN32_CURSOR_X11_SHAPE_GOBBLER,
ECORE_WIN32_CURSOR_X11_SHAPE_GUMBY,
ECORE_WIN32_CURSOR_X11_SHAPE_HAND1,
ECORE_WIN32_CURSOR_X11_SHAPE_HAND2,
ECORE_WIN32_CURSOR_X11_SHAPE_HEART,
ECORE_WIN32_CURSOR_X11_SHAPE_ICON,
ECORE_WIN32_CURSOR_X11_SHAPE_IRON_CROSS,
ECORE_WIN32_CURSOR_X11_SHAPE_LEFT_PTR,
ECORE_WIN32_CURSOR_X11_SHAPE_LEFT_SIDE,
ECORE_WIN32_CURSOR_X11_SHAPE_LEFT_TEE,
ECORE_WIN32_CURSOR_X11_SHAPE_LEFTBUTTON,
ECORE_WIN32_CURSOR_X11_SHAPE_LL_ANGLE,
ECORE_WIN32_CURSOR_X11_SHAPE_LR_ANGLE,
ECORE_WIN32_CURSOR_X11_SHAPE_MAN,
ECORE_WIN32_CURSOR_X11_SHAPE_MIDDLEBUTTON,
ECORE_WIN32_CURSOR_X11_SHAPE_MOUSE,
ECORE_WIN32_CURSOR_X11_SHAPE_PENCIL,
ECORE_WIN32_CURSOR_X11_SHAPE_PIRATE,
ECORE_WIN32_CURSOR_X11_SHAPE_PLUS,
ECORE_WIN32_CURSOR_X11_SHAPE_QUESTION_ARROW,
ECORE_WIN32_CURSOR_X11_SHAPE_RIGHT_PTR,
ECORE_WIN32_CURSOR_X11_SHAPE_RIGHT_SIDE,
ECORE_WIN32_CURSOR_X11_SHAPE_RIGHT_TEE,
ECORE_WIN32_CURSOR_X11_SHAPE_RIGHTBUTTON,
ECORE_WIN32_CURSOR_X11_SHAPE_RTL_LOGO,
ECORE_WIN32_CURSOR_X11_SHAPE_SAILBOAT,
ECORE_WIN32_CURSOR_X11_SHAPE_SB_DOWN_ARROW,
ECORE_WIN32_CURSOR_X11_SHAPE_SB_H_DOUBLE_ARROW,
ECORE_WIN32_CURSOR_X11_SHAPE_SB_LEFT_ARROW,
ECORE_WIN32_CURSOR_X11_SHAPE_SB_RIGHT_ARROW,
ECORE_WIN32_CURSOR_X11_SHAPE_SB_UP_ARROW,
ECORE_WIN32_CURSOR_X11_SHAPE_SB_V_DOUBLE_ARROW,
ECORE_WIN32_CURSOR_X11_SHAPE_SHUTTLE,
ECORE_WIN32_CURSOR_X11_SHAPE_SIZING,
ECORE_WIN32_CURSOR_X11_SHAPE_SPIDER,
ECORE_WIN32_CURSOR_X11_SHAPE_SPRAYCAN,
ECORE_WIN32_CURSOR_X11_SHAPE_STAR,
ECORE_WIN32_CURSOR_X11_SHAPE_TARGET,
ECORE_WIN32_CURSOR_X11_SHAPE_TCROSS,
ECORE_WIN32_CURSOR_X11_SHAPE_TOP_LEFT_ARROW,
ECORE_WIN32_CURSOR_X11_SHAPE_TOP_LEFT_CORNER,
ECORE_WIN32_CURSOR_X11_SHAPE_TOP_RIGHT_CORNER,
ECORE_WIN32_CURSOR_X11_SHAPE_TOP_SIDE,
ECORE_WIN32_CURSOR_X11_SHAPE_TOP_TEE,
ECORE_WIN32_CURSOR_X11_SHAPE_TREK,
ECORE_WIN32_CURSOR_X11_SHAPE_UL_ANGLE,
ECORE_WIN32_CURSOR_X11_SHAPE_UMBRELLA,
ECORE_WIN32_CURSOR_X11_SHAPE_UR_ANGLE,
ECORE_WIN32_CURSOR_X11_SHAPE_WATCH,
ECORE_WIN32_CURSOR_X11_SHAPE_XTERM,
} Ecore_Win32_Cursor_X11_Shape;
/**
* @typedef Ecore_Win32_DnD_State
* State of a DnD operation.
@ -563,6 +648,8 @@ EAPI void ecore_win32_cursor_free(Ecore_Win32_Cursor *cursor);
EAPI Ecore_Win32_Cursor *ecore_win32_cursor_shaped_new(Ecore_Win32_Cursor_Shape shape);
EAPI const Ecore_Win32_Cursor *ecore_win32_cursor_x11_shaped_get(Ecore_Win32_Cursor_X11_Shape shape);
EAPI void ecore_win32_cursor_size_get(int *width, int *height);

View File

@ -334,6 +334,19 @@ _ecore_win32_window_procedure(HWND window,
INF("clipboard data updated");
_ecore_win32_event_handle_selection_notify(data);
return 0;
case WM_SETCURSOR:
{
Ecore_Win32_Window *w;
INF("SetCursor");
w = (Ecore_Win32_Window *)GetWindowLongPtr(window, GWLP_USERDATA);
if (w && w->cursor)
{
SetCursor(w->cursor);
return 1;
}
return 0;
}
/* GDI notifications */
case WM_PAINT:
{
@ -375,11 +388,12 @@ _ecore_win32_window_procedure(HWND window,
*============================================================================*/
HINSTANCE _ecore_win32_instance = NULL;
double _ecore_win32_double_click_time = 0.25;
unsigned long _ecore_win32_event_last_time = 0;
Ecore_Win32_Window *_ecore_win32_event_last_window = NULL;
int _ecore_win32_log_dom_global = -1;
HINSTANCE _ecore_win32_instance = NULL;
double _ecore_win32_double_click_time = 0.25;
unsigned long _ecore_win32_event_last_time = 0;
Ecore_Win32_Window *_ecore_win32_event_last_window = NULL;
int _ecore_win32_log_dom_global = -1;
Ecore_Win32_Cursor *_ecore_win32_cursor_x[77];
int ECORE_WIN32_EVENT_MOUSE_IN = 0;
int ECORE_WIN32_EVENT_MOUSE_OUT = 0;
@ -456,6 +470,7 @@ ecore_win32_init()
WNDCLASSEX wc;
HICON icon;
HICON icon_sm;
int i;
if (++_ecore_win32_init_count != 1)
return _ecore_win32_init_count;
@ -545,6 +560,9 @@ ecore_win32_init()
ECORE_WIN32_EVENT_SELECTION_NOTIFY = ecore_event_type_new();
}
for (i = 0; i < 77; i++)
_ecore_win32_cursor_x[i] = _ecore_win32_cursor_x11_shaped_new(i);
return _ecore_win32_init_count;
unregister_class:
@ -574,9 +592,14 @@ ecore_win32_init()
EAPI int
ecore_win32_shutdown()
{
int i;
if (--_ecore_win32_init_count != 0)
return _ecore_win32_init_count;
for (i = 0; i < 77; i++)
ecore_win32_cursor_free(_ecore_win32_cursor_x[i]);
ecore_win32_dnd_shutdown();
if (!UnregisterClass(ECORE_WIN32_WINDOW_CLASS, _ecore_win32_instance))

View File

@ -10,12 +10,30 @@
#include "Ecore_Win32.h"
#include "ecore_win32_private.h"
#include "ecore_win32_cursor_x11.h"
/*============================================================================*
* Local *
*============================================================================*/
Ecore_Win32_Cursor *
_ecore_win32_cursor_x11_shaped_new(Ecore_Win32_Cursor_X11_Shape shape)
{
INF("creating X11 shaped cursor");
if ((shape < ECORE_WIN32_CURSOR_X11_SHAPE_X) ||
(shape > ECORE_WIN32_CURSOR_X11_SHAPE_XTERM))
return NULL;
return ecore_win32_cursor_new(_ecore_win32_cursors_x11[shape].mask_and,
_ecore_win32_cursors_x11[shape].mask_xor,
32, 32,
_ecore_win32_cursors_x11[shape].hotspot_x,
_ecore_win32_cursors_x11[shape].hotspot_y);
}
/*============================================================================*
* Global *
*============================================================================*/
@ -157,7 +175,11 @@
* };
*
* Ecore_Win32_Cursor *cursor = ecore_win32_cursor_new(pixels_and, pixels_xor, 32, 32, 19, 2);
* ecore_win32_window_cursor_set(window, cursor);
* @endcode
*
* @see ecore_win32_cursor_free()
* @see ecore_win32_window_cursor_set()
*/
EAPI Ecore_Win32_Cursor *
ecore_win32_cursor_new(const void *pixels_and,
@ -199,13 +221,19 @@ ecore_win32_cursor_new(const void *pixels_and,
* @param cursor The cursor to free.
*
* This function free @p cursor. @p cursor must have been obtained
* with ecore_win32_cursor_new().
* with ecore_win32_cursor_new() or ecore_win32_cursor_x11_shaped_new().
*
* @see ecore_win32_cursor_new()
* @see ecore_win32_cursor_x11_shaped_new()
*/
EAPI void
ecore_win32_cursor_free(Ecore_Win32_Cursor *cursor)
{
INF("destroying cursor");
if (!cursor)
return;
DestroyCursor(cursor);
}
@ -217,7 +245,7 @@ ecore_win32_cursor_free(Ecore_Win32_Cursor *cursor)
*
* This function 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.
* from an existing resource. On error @c NULL is returned.
*/
EAPI Ecore_Win32_Cursor *
ecore_win32_cursor_shaped_new(Ecore_Win32_Cursor_Shape shape)
@ -281,6 +309,33 @@ ecore_win32_cursor_shaped_new(Ecore_Win32_Cursor_Shape shape)
return cursor;
}
/**
* @brief Retrieve a X11 cursor from a X Id.
*
* @param[in] shape The defined X11 shape of the cursor.
* @return The new cursor.
*
* This function returns a defined cursor with a specified X11
* @p shape. Do not use ecore_win32_cursor_free() to free the
* ressources as it is created once the libray is initialized and
* detroyed when it is shut down.
*
* @see ecore_win32_cursor_new()
*
* @since 1.16
*/
EAPI const Ecore_Win32_Cursor *
ecore_win32_cursor_x11_shaped_get(Ecore_Win32_Cursor_X11_Shape shape)
{
INF("getting X11 shaped cursor");
if ((shape < ECORE_WIN32_CURSOR_X11_SHAPE_X) ||
(shape > ECORE_WIN32_CURSOR_X11_SHAPE_XTERM))
return NULL;
return _ecore_win32_cursor_x[shape];
}
/**
* @brief Retrieve the size of a valid cursor.
*

File diff suppressed because it is too large Load Diff

View File

@ -74,6 +74,8 @@ struct _Ecore_Win32_Window
DWORD style; /* used to go fullscreen to normal */
RECT rect; /* used to go fullscreen to normal */
Ecore_Win32_Cursor *cursor;
struct {
Ecore_Win32_Pos_Hints_Flags flags;
int min_width;
@ -145,6 +147,7 @@ extern HINSTANCE _ecore_win32_instance;
extern double _ecore_win32_double_click_time;
extern unsigned long _ecore_win32_event_last_time;
extern Ecore_Win32_Window *_ecore_win32_event_last_window;
extern Ecore_Win32_Cursor *_ecore_win32_cursor_x[77];
void _ecore_win32_event_handle_key_press(Ecore_Win32_Callback_Data *msg);
@ -174,7 +177,9 @@ void *_ecore_win32_dnd_register_drop_window(HWND hwnd,
Ecore_Win32_Dnd_DropTarget_Callback callback, void *ptr);
void _ecore_win32_dnd_unregister_drop_window(HWND hwnd, void *drop_target);
Eina_Bool ecore_win32_window_drag(Ecore_Win32_Window *w, int ptx, int pty);
Eina_Bool ecore_win32_window_drag(Ecore_Win32_Window *w, int ptx, int pty);
Ecore_Win32_Cursor *_ecore_win32_cursor_x11_shaped_new(Ecore_Win32_Cursor_X11_Shape shape);
#ifdef __cplusplus

View File

@ -155,6 +155,8 @@ _ecore_win32_window_internal_new(Ecore_Win32_Window *parent,
w->drag.current_mouse_x = -32768;
w->drag.current_mouse_y = -32768;
w->cursor = LoadCursor (NULL, IDC_ARROW);
return w;
}
@ -1436,8 +1438,13 @@ ecore_win32_window_fullscreen_set(Ecore_Win32_Window *window,
*
* 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
* ecore_win32_cursor_shaped_new() or
* ecore_win32_cursor_x11_shaped_new(). If @p window or @p cursor is
* @c NULL, the function does nothing.
*
* @see ecore_win32_cursor_new()
* @see ecore_win32_cursor_shaped_new()
* @see ecore_win32_cursor_x11_shaped_new()
*/
EAPI void
ecore_win32_window_cursor_set(Ecore_Win32_Window *window,
@ -1448,11 +1455,7 @@ ecore_win32_window_cursor_set(Ecore_Win32_Window *window,
if (!window || !cursor)
return;
if (!SetClassLongPtr(window->window,
GCLP_HCURSOR, (LONG_PTR)cursor))
{
ERR("SetClassLong() failed");
}
window->cursor = cursor;
}
/**