* add cursor support

* add mouse wheel, window create, window configure and window resize events
 * fix fullscreen function
 * fix button release even
 * add _geometry_get function
 * minor cleanups


SVN revision: 31789
This commit is contained in:
doursse 2007-09-23 11:08:52 +00:00 committed by doursse
parent 251f9a2f62
commit 99a0034778
7 changed files with 578 additions and 157 deletions

View File

@ -29,6 +29,7 @@
typedef void Ecore_Win32_Window;
typedef void Ecore_Win32_Cursor;
typedef void Ecore_Win32_DDraw_Object;
typedef void Ecore_Win32_DDraw_Surface;
typedef void Ecore_Win32_Direct3D_Object;
@ -36,22 +37,46 @@ typedef void Ecore_Win32_Direct3D_Device;
typedef void Ecore_Win32_Direct3D_Sprite;
typedef void Ecore_Win32_Direct3D_Texture;
/*cursor shapes */
typedef enum
{
ECORE_WIN32_CURSO_SHAPE_APP_STARTING, /* Standard arrow and small hourglass */
ECORE_WIN32_CURSO_SHAPE_ARROW, /* Standard arrow */
ECORE_WIN32_CURSO_SHAPE_CROSS, /* Crosshair */
ECORE_WIN32_CURSO_SHAPE_HAND, /* Hand */
ECORE_WIN32_CURSO_SHAPE_HELP, /* Arrow and question mark */
ECORE_WIN32_CURSO_SHAPE_I_BEAM, /* I-beam */
ECORE_WIN32_CURSO_SHAPE_NO, /* Slashed circle */
ECORE_WIN32_CURSO_SHAPE_SIZE_ALL, /* Four-pointed arrow pointing north, south, east, and west */
ECORE_WIN32_CURSO_SHAPE_SIZE_NESW, /* Double-pointed arrow pointing northeast and southwest */
ECORE_WIN32_CURSO_SHAPE_SIZE_NS, /* Double-pointed arrow pointing north and south */
ECORE_WIN32_CURSO_SHAPE_SIZE_NWSE, /* Double-pointed arrow pointing northwest and southeast */
ECORE_WIN32_CURSO_SHAPE_SIZE_WE, /* Double-pointed arrow pointing west and east */
ECORE_WIN32_CURSO_SHAPE_UP_ARROW, /* Vertical arrow */
ECORE_WIN32_CURSO_SHAPE_WAIT /* Hourglass */
} Ecore_Win32_Cursor_Shape;
/* Events */
typedef struct _Ecore_Win32_Event_Key_Down Ecore_Win32_Event_Key_Down;
typedef struct _Ecore_Win32_Event_Key_Up Ecore_Win32_Event_Key_Up;
typedef struct _Ecore_Win32_Event_Mouse_Button_Down Ecore_Win32_Event_Mouse_Button_Down;
typedef struct _Ecore_Win32_Event_Mouse_Button_Up Ecore_Win32_Event_Mouse_Button_Up;
typedef struct _Ecore_Win32_Event_Mouse_Move Ecore_Win32_Event_Mouse_Move;
typedef struct _Ecore_Win32_Event_Mouse_In Ecore_Win32_Event_Mouse_In;
typedef struct _Ecore_Win32_Event_Mouse_Out Ecore_Win32_Event_Mouse_Out;
typedef struct _Ecore_Win32_Event_Window_Focus_In Ecore_Win32_Event_Window_Focus_In;
typedef struct _Ecore_Win32_Event_Window_Focus_Out Ecore_Win32_Event_Window_Focus_Out;
typedef struct _Ecore_Win32_Event_Window_Damage Ecore_Win32_Event_Window_Damage;
typedef struct _Ecore_Win32_Event_Window_Destroy Ecore_Win32_Event_Window_Destroy;
typedef struct _Ecore_Win32_Event_Window_Hide Ecore_Win32_Event_Window_Hide;
typedef struct _Ecore_Win32_Event_Window_Show Ecore_Win32_Event_Window_Show;
typedef struct _Ecore_Win32_Event_Window_Delete Ecore_Win32_Event_Window_Delete;
typedef struct _Ecore_Win32_Event_Key_Down Ecore_Win32_Event_Key_Down;
typedef struct _Ecore_Win32_Event_Key_Up Ecore_Win32_Event_Key_Up;
typedef struct _Ecore_Win32_Event_Mouse_Button_Down Ecore_Win32_Event_Mouse_Button_Down;
typedef struct _Ecore_Win32_Event_Mouse_Button_Up Ecore_Win32_Event_Mouse_Button_Up;
typedef struct _Ecore_Win32_Event_Mouse_Move Ecore_Win32_Event_Mouse_Move;
typedef struct _Ecore_Win32_Event_Mouse_In Ecore_Win32_Event_Mouse_In;
typedef struct _Ecore_Win32_Event_Mouse_Out Ecore_Win32_Event_Mouse_Out;
typedef struct _Ecore_Win32_Event_Mouse_Wheel Ecore_Win32_Event_Mouse_Wheel;
typedef struct _Ecore_Win32_Event_Window_Focus_In Ecore_Win32_Event_Window_Focus_In;
typedef struct _Ecore_Win32_Event_Window_Focus_Out Ecore_Win32_Event_Window_Focus_Out;
typedef struct _Ecore_Win32_Event_Window_Damage Ecore_Win32_Event_Window_Damage;
typedef struct _Ecore_Win32_Event_Window_Create Ecore_Win32_Event_Window_Create;
typedef struct _Ecore_Win32_Event_Window_Destroy Ecore_Win32_Event_Window_Destroy;
typedef struct _Ecore_Win32_Event_Window_Hide Ecore_Win32_Event_Window_Hide;
typedef struct _Ecore_Win32_Event_Window_Show Ecore_Win32_Event_Window_Show;
typedef struct _Ecore_Win32_Event_Window_Configure Ecore_Win32_Event_Window_Configure;
typedef struct _Ecore_Win32_Event_Window_Resize Ecore_Win32_Event_Window_Resize;
typedef struct _Ecore_Win32_Event_Window_Delete_Request Ecore_Win32_Event_Window_Delete_Request;
struct _Ecore_Win32_Event_Key_Down
{
@ -117,6 +142,17 @@ struct _Ecore_Win32_Event_Mouse_Out
double time;
};
struct _Ecore_Win32_Event_Mouse_Wheel
{
Ecore_Win32_Window *window;
int direction; /* 0 = default up/down wheel FIXME: more wheel types */
int z; /* ...,-2,-1 = down, 1,2,... = up */
int modifiers;
int x;
int y;
double time;
};
struct _Ecore_Win32_Event_Window_Focus_In
{
Ecore_Win32_Window *window;
@ -139,6 +175,12 @@ struct _Ecore_Win32_Event_Window_Damage
double time;
};
struct _Ecore_Win32_Event_Window_Create
{
Ecore_Win32_Window *window;
double time;
};
struct _Ecore_Win32_Event_Window_Destroy
{
Ecore_Win32_Window *window;
@ -157,7 +199,26 @@ struct _Ecore_Win32_Event_Window_Show
double time;
};
struct _Ecore_Win32_Event_Window_Delete
struct _Ecore_Win32_Event_Window_Configure
{
Ecore_Win32_Window *window;
Ecore_Win32_Window *abovewin;
int x;
int y;
int width;
int height;
double time;
};
struct _Ecore_Win32_Event_Window_Resize
{
Ecore_Win32_Window *window;
int width;
int height;
double time;
};
struct _Ecore_Win32_Event_Window_Delete_Request
{
Ecore_Win32_Window *window;
double time;
@ -170,13 +231,17 @@ EAPI extern int ECORE_WIN32_EVENT_MOUSE_BUTTON_UP;
EAPI extern int ECORE_WIN32_EVENT_MOUSE_MOVE;
EAPI extern int ECORE_WIN32_EVENT_MOUSE_IN;
EAPI extern int ECORE_WIN32_EVENT_MOUSE_OUT;
EAPI extern int ECORE_WIN32_EVENT_MOUSE_WHEEL;
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_DELETE;
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;
/* Core */
@ -209,6 +274,12 @@ EAPI void ecore_win32_window_move_resize(Ecore_Win32_Window *window,
int width,
int height);
EAPI void ecore_win32_window_geometry_get(Ecore_Win32_Window *window,
int *x,
int *y,
int *width,
int *height);
EAPI void ecore_win32_window_size_get(Ecore_Win32_Window *window,
int *width,
int *height);
@ -251,19 +322,37 @@ EAPI void ecore_win32_window_borderless_set(Ecore_Win32_Window *window,
EAPI void ecore_win32_window_fullscreen_set(Ecore_Win32_Window *window,
int on);
EAPI void ecore_win32_window_cursor_set(Ecore_Win32_Window *window,
Ecore_Win32_Cursor *cursor);
/* Cursor */
EAPI Ecore_Win32_Cursor *ecore_win32_cursor_new(const void *pixels_and,
const void *pixels_xor,
int width,
int height,
int hot_x,
int hot_y);
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 int ecore_win32_cursor_size_get(void);
/* DirectDraw */
EAPI int ecore_win32_ddraw_init(Ecore_Win32_Window *window);
EAPI int ecore_win32_ddraw_init(Ecore_Win32_Window *window);
EAPI void ecore_win32_ddraw_shutdown(Ecore_Win32_Window *window);
EAPI void ecore_win32_ddraw_shutdown(Ecore_Win32_Window *window);
EAPI Ecore_Win32_DDraw_Object *ecore_win32_ddraw_object_get(Ecore_Win32_Window *window);
EAPI Ecore_Win32_DDraw_Object *ecore_win32_ddraw_object_get(Ecore_Win32_Window *window);
EAPI Ecore_Win32_DDraw_Surface *ecore_win32_ddraw_surface_primary_get(Ecore_Win32_Window *window);
EAPI Ecore_Win32_DDraw_Surface *ecore_win32_ddraw_surface_back_get(Ecore_Win32_Window *window);
EAPI int ecore_win32_ddraw_depth_get(Ecore_Win32_Window *window);
EAPI int ecore_win32_ddraw_depth_get(Ecore_Win32_Window *window);
/* Direct3D */
@ -271,19 +360,19 @@ EAPI int ecore_win32_ddraw_depth_get(Ecore_Win32_Window *window);
extern "C" {
#endif
EAPI int ecore_win32_direct3d_init(Ecore_Win32_Window *window);
EAPI int ecore_win32_direct3d_init(Ecore_Win32_Window *window);
EAPI void ecore_win32_direct3d_shutdown(Ecore_Win32_Window *window);
EAPI void ecore_win32_direct3d_shutdown(Ecore_Win32_Window *window);
EAPI Ecore_Win32_Direct3D_Object *ecore_win32_direct3d_object_get(Ecore_Win32_Window *window);
EAPI Ecore_Win32_Direct3D_Object *ecore_win32_direct3d_object_get(Ecore_Win32_Window *window);
EAPI Ecore_Win32_Direct3D_Device *ecore_win32_direct3d_device_get(Ecore_Win32_Window *window);
EAPI Ecore_Win32_Direct3D_Device *ecore_win32_direct3d_device_get(Ecore_Win32_Window *window);
EAPI Ecore_Win32_Direct3D_Sprite *ecore_win32_direct3d_sprite_get(Ecore_Win32_Window *window);
EAPI Ecore_Win32_Direct3D_Sprite *ecore_win32_direct3d_sprite_get(Ecore_Win32_Window *window);
EAPI Ecore_Win32_Direct3D_Texture *ecore_win32_direct3d_texture_get(Ecore_Win32_Window *window);
EAPI int ecore_win32_direct3d_depth_get(Ecore_Win32_Window *window);
EAPI int ecore_win32_direct3d_depth_get(Ecore_Win32_Window *window);
#ifdef __cplusplus
}

View File

@ -6,6 +6,7 @@ INCLUDES = \
libecore_win32_la_LDFLAGS = \
-version-info 1:0:0 \
@create_shared_lib@ \
-L$(top_builddir)/src/lib/ecore/.libs
@ -17,6 +18,7 @@ Ecore_Win32.h
libecore_win32_la_SOURCES = \
ecore_win32.c \
ecore_win32_cursor.c \
ecore_win32_direct3d.cpp \
ecore_win32_ddraw.c \
ecore_win32_event.c \
@ -25,7 +27,7 @@ ecore_win32_private.h
libecore_win32_la_LIBADD = \
@ddraw_libs@ @direct3d_libs@ \
@create_shared_lib@ -lwsock32 \
-lwsock32 \
$(top_builddir)/src/lib/ecore/libecore.la
endif
@ -33,6 +35,7 @@ endif
EXTRA_DIST = \
Ecore_Win32.h \
ecore_win32.c \
ecore_win32_cursor.c \
ecore_win32_direct3d.cpp \
ecore_win32_ddraw.c \
ecore_win32_event.c \

View File

@ -53,6 +53,7 @@ _ecore_win32_window_procedure(HWND window,
switch (data->message)
{
/* Keyboard input notifications */
case WM_KEYDOWN:
printf (" * ecore message : keystroke down\n");
_ecore_win32_event_handle_key_press(data, 1);
@ -64,6 +65,15 @@ _ecore_win32_window_procedure(HWND window,
printf (" * ecore message : keystroke up\n");
_ecore_win32_event_handle_key_release(data, 1);
return 0;
case WM_SETFOCUS:
printf (" * ecore message : focus in\n");
_ecore_win32_event_handle_focus_in(data);
return 0;
case WM_KILLFOCUS:
printf (" * ecore message : focus out\n");
_ecore_win32_event_handle_focus_out(data);
return 0;
/* Mouse input notifications */
case WM_LBUTTONDOWN:
printf (" * ecore message : lbuttondown\n");
_ecore_win32_event_handle_button_press(data, 1);
@ -131,6 +141,15 @@ _ecore_win32_window_procedure(HWND window,
return 0;
}
case WM_MOUSEWHEEL:
printf (" * ecore message : mouse wheel\n");
_ecore_win32_event_handle_button_press(data, 4);
return 0;
/* Window notifications */
case WM_CREATE:
printf (" * ecore message : create\n");
_ecore_win32_event_handle_create_notify(data);
return 0;
case WM_DESTROY:
printf (" * ecore message : destroy\n");
_ecore_win32_event_handle_destroy_notify(data);
@ -147,6 +166,37 @@ _ecore_win32_window_procedure(HWND window,
_ecore_win32_event_handle_unmap_notify(data);
return 0;
case WM_CLOSE:
printf (" * ecore message : close\n");
_ecore_win32_event_handle_delete_request(data);
return 0;
case WM_MOVING:
printf (" * ecore message : moving\n");
return TRUE;
case WM_MOVE:
printf (" * ecore message : moved\n");
return 0;
case WM_SIZING:
printf (" * ecore message : sizing\n");
_ecore_win32_event_handle_resize(data);
return TRUE;
case WM_SIZE:
printf (" * ecore message : sized\n");
return 0;
case WM_WINDOWPOSCHANGING:
printf (" * ecore message : WM_WINDOWPOSCHANGING\n");
return 0;
case WM_WINDOWPOSCHANGED:
printf (" * ecore message : WM_WINDOWPOSCHANGED\n");
_ecore_win32_event_handle_configure_notify(data);
return 0;
case WM_ENTERSIZEMOVE :
printf (" * ecore message : WM_ENTERSIZEMOVE \n");
return 0;
case WM_EXITSIZEMOVE:
printf (" * ecore message : WM_EXITSIZEMOVE\n");
return 0;
/* GDI notifications */
case WM_PAINT:
{
RECT rect;
@ -158,34 +208,29 @@ _ecore_win32_window_procedure(HWND window,
HDC hdc;
hdc = BeginPaint(window, &ps);
data->update = rect;
_ecore_win32_event_handle_expose(data);
EndPaint(window, &ps);
printf ("%ld %ld %ld %ld\n",
printf (" * %ld %ld %ld %ld\n",
rect.left,
rect.top,
rect.right - rect.left,
rect.bottom - rect.top);
data->update = rect;
_ecore_win32_event_handle_expose(data);
}
return 0;
}
case WM_CLOSE:
printf (" * ecore message : close\n");
_ecore_win32_event_handle_delete(data);
case WM_SETREDRAW:
printf (" * ecore message : WM_SETREDRAW\n");
return 0;
case WM_SETFOCUS:
printf (" * ecore message : focus in\n");
_ecore_win32_event_handle_focus_in(data);
return 0;
case WM_KILLFOCUS:
printf (" * ecore message : focus out\n");
_ecore_win32_event_handle_focus_out(data);
case WM_SYNCPAINT:
printf (" * ecore message : WM_SYNCPAINT\n");
return 0;
default:
return DefWindowProc(window, message, window_param, data_param);
}
}
/*
Events:
@ -199,31 +244,37 @@ x * mouse button down right
x * mouse button up left
x * mouse button up middle
x * mouse button up right
* mouse move (contains enter)
* mouse leave
* focus in
* focus out
* expose
* create
* destroy
* resize
x * mouse move (contains enter)
x * mouse leave
x * focus in
x * focus out
x * expose
x * create
x * destroy
x * configure
x * resize
x * delete
*/
EAPI int ECORE_WIN32_EVENT_KEY_DOWN = 0;
EAPI int ECORE_WIN32_EVENT_KEY_UP = 0;
EAPI int ECORE_WIN32_EVENT_MOUSE_BUTTON_DOWN = 0;
EAPI int ECORE_WIN32_EVENT_MOUSE_BUTTON_UP = 0;
EAPI int ECORE_WIN32_EVENT_MOUSE_MOVE = 0;
EAPI int ECORE_WIN32_EVENT_MOUSE_IN = 0;
EAPI int ECORE_WIN32_EVENT_MOUSE_OUT = 0;
EAPI int ECORE_WIN32_EVENT_WINDOW_FOCUS_IN = 0;
EAPI int ECORE_WIN32_EVENT_WINDOW_FOCUS_OUT = 0;
EAPI int ECORE_WIN32_EVENT_WINDOW_DAMAGE = 0;
EAPI int ECORE_WIN32_EVENT_WINDOW_DESTROY = 0;
EAPI int ECORE_WIN32_EVENT_WINDOW_SHOW = 0;
EAPI int ECORE_WIN32_EVENT_WINDOW_HIDE = 0;
EAPI int ECORE_WIN32_EVENT_WINDOW_DELETE = 0;
EAPI int ECORE_WIN32_EVENT_KEY_DOWN = 0;
EAPI int ECORE_WIN32_EVENT_KEY_UP = 0;
EAPI int ECORE_WIN32_EVENT_MOUSE_BUTTON_DOWN = 0;
EAPI int ECORE_WIN32_EVENT_MOUSE_BUTTON_UP = 0;
EAPI int ECORE_WIN32_EVENT_MOUSE_MOVE = 0;
EAPI int ECORE_WIN32_EVENT_MOUSE_IN = 0;
EAPI int ECORE_WIN32_EVENT_MOUSE_OUT = 0;
EAPI int ECORE_WIN32_EVENT_MOUSE_WHEEL = 0;
EAPI int ECORE_WIN32_EVENT_WINDOW_FOCUS_IN = 0;
EAPI int ECORE_WIN32_EVENT_WINDOW_FOCUS_OUT = 0;
EAPI int ECORE_WIN32_EVENT_WINDOW_DAMAGE = 0;
EAPI int ECORE_WIN32_EVENT_WINDOW_CREATE = 0;
EAPI int ECORE_WIN32_EVENT_WINDOW_DESTROY = 0;
EAPI int ECORE_WIN32_EVENT_WINDOW_SHOW = 0;
EAPI int ECORE_WIN32_EVENT_WINDOW_HIDE = 0;
EAPI int ECORE_WIN32_EVENT_WINDOW_CONFIGURE = 0;
EAPI int ECORE_WIN32_EVENT_WINDOW_RESIZE = 0;
EAPI int ECORE_WIN32_EVENT_WINDOW_DELETE_REQUEST = 0;
EAPI int
@ -270,20 +321,24 @@ ecore_win32_init()
if (!ECORE_WIN32_EVENT_KEY_DOWN)
{
ECORE_WIN32_EVENT_KEY_DOWN = ecore_event_type_new();
ECORE_WIN32_EVENT_KEY_UP = ecore_event_type_new();
ECORE_WIN32_EVENT_MOUSE_BUTTON_DOWN = ecore_event_type_new();
ECORE_WIN32_EVENT_MOUSE_BUTTON_UP = ecore_event_type_new();
ECORE_WIN32_EVENT_MOUSE_MOVE = ecore_event_type_new();
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_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_DELETE = ecore_event_type_new();
ECORE_WIN32_EVENT_KEY_DOWN = ecore_event_type_new();
ECORE_WIN32_EVENT_KEY_UP = ecore_event_type_new();
ECORE_WIN32_EVENT_MOUSE_BUTTON_DOWN = ecore_event_type_new();
ECORE_WIN32_EVENT_MOUSE_BUTTON_UP = ecore_event_type_new();
ECORE_WIN32_EVENT_MOUSE_MOVE = ecore_event_type_new();
ECORE_WIN32_EVENT_MOUSE_IN = ecore_event_type_new();
ECORE_WIN32_EVENT_MOUSE_OUT = ecore_event_type_new();
ECORE_WIN32_EVENT_MOUSE_WHEEL = 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();
}
_ecore_win32_init_count++;

View File

@ -0,0 +1,111 @@
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#include "ecore_win32_private.h"
EAPI Ecore_Win32_Cursor *
ecore_win32_cursor_new(const void *pixels_and,
const void *pixels_xor,
int width,
int height,
int hot_x,
int hot_y)
{
Ecore_Win32_Cursor *cursor = NULL;
int cursor_width;
int cursor_height;
cursor_width = GetSystemMetrics(SM_CXCURSOR);
cursor_height = GetSystemMetrics(SM_CYCURSOR);
if ((cursor_width != width) ||
(cursor_height != height))
return NULL;
if (!(cursor = CreateCursor(_ecore_win32_instance,
hot_x, hot_y,
width, height,
pixels_and,
pixels_xor)))
return NULL;
return cursor;
}
EAPI void
ecore_win32_cursor_free(Ecore_Win32_Cursor *cursor)
{
DestroyCursor(cursor);
}
EAPI Ecore_Win32_Cursor *
ecore_win32_cursor_shape_get(Ecore_Win32_Cursor_Shape shape)
{
Ecore_Win32_Cursor *cursor = NULL;
const char *cursor_name;
switch (shape)
{
case ECORE_WIN32_CURSO_SHAPE_APP_STARTING:
cursor_name = IDC_APPSTARTING;
break;
case ECORE_WIN32_CURSO_SHAPE_ARROW:
cursor_name = IDC_ARROW;
break;
case ECORE_WIN32_CURSO_SHAPE_CROSS:
cursor_name = IDC_CROSS;
break;
case ECORE_WIN32_CURSO_SHAPE_HAND:
cursor_name = IDC_HAND;
break;
case ECORE_WIN32_CURSO_SHAPE_HELP:
cursor_name = IDC_HELP;
break;
case ECORE_WIN32_CURSO_SHAPE_I_BEAM:
cursor_name = IDC_IBEAM;
break;
case ECORE_WIN32_CURSO_SHAPE_NO:
cursor_name = IDC_NO;
break;
case ECORE_WIN32_CURSO_SHAPE_SIZE_ALL:
cursor_name = IDC_SIZEALL;
break;
case ECORE_WIN32_CURSO_SHAPE_SIZE_NESW:
cursor_name = IDC_SIZENESW;
break;
case ECORE_WIN32_CURSO_SHAPE_SIZE_NS:
cursor_name = IDC_SIZENS;
break;
case ECORE_WIN32_CURSO_SHAPE_SIZE_NWSE:
cursor_name = IDC_SIZENWSE;
break;
case ECORE_WIN32_CURSO_SHAPE_SIZE_WE:
cursor_name = IDC_SIZEWE;
break;
case ECORE_WIN32_CURSO_SHAPE_UP_ARROW:
cursor_name = IDC_UPARROW;
break;
case ECORE_WIN32_CURSO_SHAPE_WAIT:
cursor_name = IDC_WAIT;
break;
default:
return NULL;
}
if (!(cursor = LoadCursor(NULL, cursor_name)))
return NULL;
return cursor;
}
EAPI int
ecore_win32_cursor_size_get(void)
{
int width;
int height;
width = GetSystemMetrics(SM_CXCURSOR);
height = GetSystemMetrics(SM_CYCURSOR);
return (width > height) ? width : height;
}

View File

@ -345,7 +345,8 @@ _ecore_win32_event_window_get(HWND window)
}
void
_ecore_win32_event_handle_key_press(Ecore_Win32_Callback_Data *msg, int is_keystroke)
_ecore_win32_event_handle_key_press(Ecore_Win32_Callback_Data *msg,
int is_keystroke)
{
Ecore_Win32_Event_Key_Down *e;
@ -386,7 +387,8 @@ _ecore_win32_event_handle_key_press(Ecore_Win32_Callback_Data *msg, int is_keyst
}
void
_ecore_win32_event_handle_key_release(Ecore_Win32_Callback_Data *msg, int is_keystroke)
_ecore_win32_event_handle_key_release(Ecore_Win32_Callback_Data *msg,
int is_keystroke)
{
Ecore_Win32_Event_Key_Up *e;
@ -428,85 +430,107 @@ _ecore_win32_event_handle_key_release(Ecore_Win32_Callback_Data *msg, int is_key
void
_ecore_win32_event_handle_button_press(Ecore_Win32_Callback_Data *msg,
int button)
int button)
{
Ecore_Win32_Window *window;
window = _ecore_win32_event_window_get(msg->window);
{
Ecore_Win32_Event_Mouse_Move *e;
if (button > 3)
{
Ecore_Win32_Event_Mouse_Wheel *e;
e = (Ecore_Win32_Event_Mouse_Move *)calloc(1, sizeof(Ecore_Win32_Event_Mouse_Move));
if (!e) return;
e = (Ecore_Win32_Event_Mouse_Wheel *)calloc(1, sizeof(Ecore_Win32_Event_Mouse_Wheel));
if (!e) return;
e->window = window;
e->x = GET_X_LPARAM(msg->data_param);
e->y = GET_Y_LPARAM(msg->data_param);
e->time = (double)msg->time / 1000.0;
e->direction = 0;
/* wheel delta is positive or negative, never 0 */
e->z = GET_WHEEL_DELTA_WPARAM(msg->window_param) > 0 ? 1 : -1;
e->x = GET_X_LPARAM(msg->data_param);
e->y = GET_Y_LPARAM(msg->data_param);
e->time = (double)msg->time / 1000.0;
_ecore_win32_event_last_time = e->time;
_ecore_win32_event_last_window = e->window;
_ecore_win32_event_last_time = e->time;
_ecore_win32_event_last_window = e->window;
ecore_event_add(ECORE_WIN32_EVENT_MOUSE_MOVE, e, NULL, NULL);
}
ecore_event_add(ECORE_WIN32_EVENT_MOUSE_WHEEL, e, NULL, NULL);
}
else
{
{
Ecore_Win32_Event_Mouse_Move *e;
{
Ecore_Win32_Event_Mouse_Button_Down *e;
e = (Ecore_Win32_Event_Mouse_Move *)calloc(1, sizeof(Ecore_Win32_Event_Mouse_Move));
if (!e) return;
if (_ecore_win32_mouse_down_did_triple)
{
_ecore_win32_mouse_down_last_window = NULL;
_ecore_win32_mouse_down_last_last_window = NULL;
_ecore_win32_mouse_down_last_time = 0.0;
_ecore_win32_mouse_down_last_last_time = 0.0;
}
e->window = window;
e->x = GET_X_LPARAM(msg->data_param);
e->y = GET_Y_LPARAM(msg->data_param);
e->time = (double)msg->time / 1000.0;
e = (Ecore_Win32_Event_Mouse_Button_Down *)calloc(1, sizeof(Ecore_Win32_Event_Mouse_Button_Down));
if (!e) return;
_ecore_win32_event_last_time = e->time;
_ecore_win32_event_last_window = e->window;
e->window = window;
e->button = button;
e->x = GET_X_LPARAM(msg->data_param);
e->y = GET_Y_LPARAM(msg->data_param);
e->time = (double)msg->time / 1000.0;
ecore_event_add(ECORE_WIN32_EVENT_MOUSE_MOVE, e, NULL, NULL);
}
if (((e->time - _ecore_win32_mouse_down_last_time) <= _ecore_win32_double_click_time) &&
(e->window == _ecore_win32_mouse_down_last_window))
e->double_click = 1;
{
Ecore_Win32_Event_Mouse_Button_Down *e;
if (((e->time - _ecore_win32_mouse_down_last_last_time) <= (2.0 * _ecore_win32_double_click_time)) &&
(e->window == _ecore_win32_mouse_down_last_window) &&
(e->window == _ecore_win32_mouse_down_last_last_window))
{
e->triple_click = 1;
_ecore_win32_mouse_down_did_triple = 1;
}
else
_ecore_win32_mouse_down_did_triple = 0;
if (_ecore_win32_mouse_down_did_triple)
{
_ecore_win32_mouse_down_last_window = NULL;
_ecore_win32_mouse_down_last_last_window = NULL;
_ecore_win32_mouse_down_last_time = 0.0;
_ecore_win32_mouse_down_last_last_time = 0.0;
}
if (!e->double_click && !e->triple_click)
_ecore_win32_mouse_up_count = 0;
e = (Ecore_Win32_Event_Mouse_Button_Down *)calloc(1, sizeof(Ecore_Win32_Event_Mouse_Button_Down));
if (!e) return;
_ecore_win32_event_last_time = e->time;
_ecore_win32_event_last_window = e->window;
e->window = window;
e->button = button;
e->x = GET_X_LPARAM(msg->data_param);
e->y = GET_Y_LPARAM(msg->data_param);
e->time = (double)msg->time / 1000.0;
if (!_ecore_win32_mouse_down_did_triple)
{
_ecore_win32_mouse_down_last_last_window = _ecore_win32_mouse_down_last_window;
_ecore_win32_mouse_down_last_window = e->window;
_ecore_win32_mouse_down_last_last_time = _ecore_win32_mouse_down_last_time;
_ecore_win32_mouse_down_last_time = e->time;
}
if (((e->time - _ecore_win32_mouse_down_last_time) <= _ecore_win32_double_click_time) &&
(e->window == _ecore_win32_mouse_down_last_window))
e->double_click = 1;
ecore_event_add(ECORE_WIN32_EVENT_MOUSE_BUTTON_DOWN, e, NULL, NULL);
}
if (((e->time - _ecore_win32_mouse_down_last_last_time) <= (2.0 * _ecore_win32_double_click_time)) &&
(e->window == _ecore_win32_mouse_down_last_window) &&
(e->window == _ecore_win32_mouse_down_last_last_window))
{
e->triple_click = 1;
_ecore_win32_mouse_down_did_triple = 1;
}
else
_ecore_win32_mouse_down_did_triple = 0;
if (!e->double_click && !e->triple_click)
_ecore_win32_mouse_up_count = 0;
_ecore_win32_event_last_time = e->time;
_ecore_win32_event_last_window = e->window;
if (!_ecore_win32_mouse_down_did_triple)
{
_ecore_win32_mouse_down_last_last_window = _ecore_win32_mouse_down_last_window;
_ecore_win32_mouse_down_last_window = e->window;
_ecore_win32_mouse_down_last_last_time = _ecore_win32_mouse_down_last_time;
_ecore_win32_mouse_down_last_time = e->time;
}
ecore_event_add(ECORE_WIN32_EVENT_MOUSE_BUTTON_DOWN, e, NULL, NULL);
}
}
printf (" * ecore event button press\n");
}
void
_ecore_win32_event_handle_button_release(Ecore_Win32_Callback_Data *msg,
int button)
int button)
{
Ecore_Win32_Window *window;
@ -557,7 +581,7 @@ _ecore_win32_event_handle_button_release(Ecore_Win32_Callback_Data *msg,
_ecore_win32_event_last_time = e->time;
_ecore_win32_event_last_window = e->window;
ecore_event_add(ECORE_WIN32_EVENT_MOUSE_BUTTON_DOWN, e, NULL, NULL);
ecore_event_add(ECORE_WIN32_EVENT_MOUSE_BUTTON_UP, e, NULL, NULL);
}
Ecore_Win32_Event_Mouse_Button_Up *e;
@ -718,6 +742,20 @@ _ecore_win32_event_handle_expose(Ecore_Win32_Callback_Data *msg)
ecore_event_add(ECORE_WIN32_EVENT_WINDOW_DAMAGE, e, NULL, NULL);
}
void
_ecore_win32_event_handle_create_notify(Ecore_Win32_Callback_Data *msg)
{
Ecore_Win32_Event_Window_Create *e;
e = calloc(1, sizeof(Ecore_Win32_Event_Window_Create));
if (!e) return;
e->window = _ecore_win32_event_window_get(msg->window);
e->time = _ecore_win32_event_last_time;
ecore_event_add(ECORE_WIN32_EVENT_WINDOW_CREATE, e, NULL, NULL);
}
void
_ecore_win32_event_handle_destroy_notify(Ecore_Win32_Callback_Data *msg)
{
@ -762,15 +800,64 @@ _ecore_win32_event_handle_unmap_notify(Ecore_Win32_Callback_Data *msg)
}
void
_ecore_win32_event_handle_delete(Ecore_Win32_Callback_Data *msg)
_ecore_win32_event_handle_configure_notify(Ecore_Win32_Callback_Data *msg)
{
Ecore_Win32_Event_Window_Delete *e;
RECT rect;
Ecore_Win32_Event_Window_Configure *e;
WINDOWPOS *window_pos;
e = calloc(1, sizeof(Ecore_Win32_Event_Window_Delete));
e = calloc(1, sizeof(Ecore_Win32_Event_Window_Configure));
if (!e) return;
window_pos = (WINDOWPOS *)msg->data_param;
if (!GetClientRect(window_pos->hwnd, &rect))
{
free(e);
return;
}
e->window = _ecore_win32_event_window_get(window_pos->hwnd);
e->abovewin = _ecore_win32_event_window_get(window_pos->hwndInsertAfter);
e->x = rect.left;
e->y = rect.top;
e->width = rect.right - rect.left;
e->height = rect.bottom - rect.top;
e->time = _ecore_win32_event_last_time;
ecore_event_add(ECORE_WIN32_EVENT_WINDOW_CONFIGURE, e, NULL, NULL);
}
void
_ecore_win32_event_handle_resize(Ecore_Win32_Callback_Data *msg)
{
RECT rect;
Ecore_Win32_Event_Window_Resize *e;
if (!GetClientRect(msg->window, &rect))
return;
e = calloc(1, sizeof(Ecore_Win32_Event_Window_Resize));
if (!e) return;
e->window = _ecore_win32_event_window_get(msg->window);
e->width = rect.right - rect.left;
e->height = rect.bottom - rect.top;
e->time = _ecore_win32_event_last_time;
printf (" * _ecore_win32_event_handle_resize %d %d\n", e->width, e->height);
ecore_event_add(ECORE_WIN32_EVENT_WINDOW_RESIZE, e, NULL, NULL);
}
void
_ecore_win32_event_handle_delete_request(Ecore_Win32_Callback_Data *msg)
{
Ecore_Win32_Event_Window_Delete_Request *e;
e = calloc(1, sizeof(Ecore_Win32_Event_Window_Delete_Request));
if (!e) return;
e->window = _ecore_win32_event_window_get(msg->window);
e->time = _ecore_win32_event_last_time;
ecore_event_add(ECORE_WIN32_EVENT_WINDOW_DELETE, e, NULL, NULL);
ecore_event_add(ECORE_WIN32_EVENT_WINDOW_DELETE_REQUEST, e, NULL, NULL);
}

View File

@ -7,9 +7,13 @@
#include <windows.h>
#include <ddraw.h>
#include <d3d9.h>
#include <d3dx9.h>
#ifdef HAVE_DIRECTDRAW
# include <ddraw.h>
#endif /* HAVE_DIRECTDRAW */
#ifdef HAVE_DIRECT3D
# include <d3d9.h>
# include <d3dx9.h>
#endif /* HAVE_DIRECT3D */
#include <Ecore_Data.h>
@ -95,10 +99,13 @@ void _ecore_win32_event_handle_leave_notify(Ecore_Win32_Callback_Data *msg);
void _ecore_win32_event_handle_focus_in(Ecore_Win32_Callback_Data *msg);
void _ecore_win32_event_handle_focus_out(Ecore_Win32_Callback_Data *msg);
void _ecore_win32_event_handle_expose(Ecore_Win32_Callback_Data *msg);
void _ecore_win32_event_handle_create_notify(Ecore_Win32_Callback_Data *msg);
void _ecore_win32_event_handle_destroy_notify(Ecore_Win32_Callback_Data *msg);
void _ecore_win32_event_handle_map_notify(Ecore_Win32_Callback_Data *msg);
void _ecore_win32_event_handle_unmap_notify(Ecore_Win32_Callback_Data *msg);
void _ecore_win32_event_handle_delete(Ecore_Win32_Callback_Data *msg);
void _ecore_win32_event_handle_configure_notify(Ecore_Win32_Callback_Data *msg);
void _ecore_win32_event_handle_resize(Ecore_Win32_Callback_Data *msg);
void _ecore_win32_event_handle_delete_request(Ecore_Win32_Callback_Data *msg);
#endif /* __ECORE_WIN32_PRIVATE_H__ */

View File

@ -79,14 +79,14 @@ ecore_win32_window_new(Ecore_Win32_Window *parent,
return NULL;
}
w->min_width = width;
w->min_height = height;
w->max_width = width;
w->max_height = height;
w->base_width = 0;
w->base_height = 0;
w->step_width = 1;
w->step_height = 1;
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->pointer_is_in = 0;
w->borderless = 0;
@ -239,6 +239,58 @@ ecore_win32_window_move_resize(Ecore_Win32_Window *window,
TRUE);
}
EAPI void
ecore_win32_window_geometry_get(Ecore_Win32_Window *window,
int *x,
int *y,
int *width,
int *height)
{
RECT rect;
int w;
int h;
if (!window)
{
if (x) *x = 0;
if (y) *y = 0;
if (width) *width = GetSystemMetrics(SM_CXSCREEN);
if (height) *height = GetSystemMetrics(SM_CYSCREEN);
return;
}
if (!GetClientRect(((struct _Ecore_Win32_Window *)window)->window,
&rect))
{
if (x) *x = 0;
if (y) *y = 0;
if (width) *width = 0;
if (height) *height = 0;
return;
}
w = rect.right - rect.left;
h = rect.bottom - rect.top;
if (!GetWindowRect(((struct _Ecore_Win32_Window *)window)->window,
&rect))
{
if (x) *x = 0;
if (y) *y = 0;
if (width) *width = 0;
if (height) *height = 0;
return;
}
if (x) *x = rect.left;
if (y) *y = rect.top;
if (width) *width = w;
if (height) *height = h;
}
EAPI void
ecore_win32_window_size_get(Ecore_Win32_Window *window,
int *width,
@ -246,7 +298,13 @@ ecore_win32_window_size_get(Ecore_Win32_Window *window,
{
RECT rect;
if (!window) return;
if (!window)
{
if (width) *width = GetSystemMetrics(SM_CXSCREEN);
if (height) *height = GetSystemMetrics(SM_CYSCREEN);
return;
}
if (!GetClientRect(((struct _Ecore_Win32_Window *)window)->window,
&rect))
@ -454,27 +512,38 @@ ecore_win32_window_fullscreen_set(Ecore_Win32_Window *window,
((!ew->fullscreen) && (!on)))
return;
ew->fullscreen = on;
w = ew->window;
if (on)
{
if (!GetWindowRect(w, &ew->rect)) return;
if (!GetWindowRect(w, &ew->rect)) return;
ew->style = GetWindowLong(w, GWL_STYLE);
width = GetSystemMetrics (SM_CXSCREEN);
height = GetSystemMetrics (SM_CYSCREEN);
ew->style = GetWindowLong(w, GWL_STYLE);
SetWindowLong(w, GWL_STYLE, (ew->style & ~WS_OVERLAPPEDWINDOW) | WS_POPUP);
if (!SetWindowLong(w, GWL_STYLE,
(ew->style & ~WS_OVERLAPPEDWINDOW) | WS_POPUP))
return;
SetWindowPos(w, HWND_TOP, 0, 0, width, height,
SWP_NOCOPYBITS | SWP_SHOWWINDOW);
}
else
{
SetWindowLong(w, GWL_STYLE, ew->style);
if (!SetWindowLong(w, GWL_STYLE, ew->style))
return;
SetWindowPos(w, HWND_NOTOPMOST,
ew->rect.left,
ew->rect.top,
ew->rect.right - ew->rect.left,
ew->rect.bottom - ew->rect.right,
ew->rect.bottom - ew->rect.top,
SWP_NOCOPYBITS | SWP_SHOWWINDOW);
}
ew->fullscreen = on;
}
EAPI void
ecore_win32_window_cursor_set(Ecore_Win32_Window *window,
Ecore_Win32_Cursor *cursor)
{
SetClassLong(((struct _Ecore_Win32_Window *)window)->window,
GCL_HCURSOR, (LONG)cursor);
}