Ecore_Win32: fix resize of windows when step and base sizes are set

This commit is contained in:
Vincent Torri 2014-07-08 23:21:35 +02:00 committed by Cedric BAIL
parent 925c258e6b
commit d1cbf6d080
4 changed files with 487 additions and 332 deletions

View File

@ -421,36 +421,36 @@ EAPI void ecore_win32_window_size_get(Ecore_Win32_Window *window,
int *height);
EAPI void ecore_win32_window_size_min_set(Ecore_Win32_Window *window,
unsigned int min_width,
unsigned int min_height);
int min_width,
int min_height);
EAPI void ecore_win32_window_size_min_get(Ecore_Win32_Window *window,
unsigned int *min_width,
unsigned int *min_height);
int *min_width,
int *min_height);
EAPI void ecore_win32_window_size_max_set(Ecore_Win32_Window *window,
unsigned int max_width,
unsigned int max_height);
int max_width,
int max_height);
EAPI void ecore_win32_window_size_max_get(Ecore_Win32_Window *window,
unsigned int *max_width,
unsigned int *max_height);
int *max_width,
int *max_height);
EAPI void ecore_win32_window_size_base_set(Ecore_Win32_Window *window,
unsigned int base_width,
unsigned int base_height);
int base_width,
int base_height);
EAPI void ecore_win32_window_size_base_get(Ecore_Win32_Window *window,
unsigned int *base_width,
unsigned int *base_height);
int *base_width,
int *base_height);
EAPI void ecore_win32_window_size_step_set(Ecore_Win32_Window *window,
unsigned int step_width,
unsigned int step_height);
int step_width,
int step_height);
EAPI void ecore_win32_window_size_step_get(Ecore_Win32_Window *window,
unsigned int *step_width,
unsigned int *step_height);
int *step_width,
int *step_height);
EAPI void ecore_win32_window_show(Ecore_Win32_Window *window);

View File

@ -38,24 +38,6 @@ DEFINE_OLEGUID(IID_IUnknown, 0x00000000L, 0, 0);
static int _ecore_win32_init_count = 0;
static void
_ecore_win32_size_check(Ecore_Win32_Window *win, int w, int h, int *dx, int *dy)
{
int minimal_width;
int minimal_height;
minimal_width = GetSystemMetrics(SM_CXMIN);
minimal_height = GetSystemMetrics(SM_CYMIN);
if ((w) < MAX(minimal_width, (int)win->min_width))
*dx = 0;
if ((w) > (int)win->max_width)
*dx = 0;
if ((h) < MAX(minimal_height, (int)win->min_height))
*dy = 0;
if ((h) > (int)win->max_height)
*dy = 0;
}
LRESULT CALLBACK
_ecore_win32_window_procedure(HWND window,
UINT message,
@ -124,7 +106,7 @@ _ecore_win32_window_procedure(HWND window,
w = (Ecore_Win32_Window *)GetWindowLongPtr(window, GWLP_USERDATA);
if (w->drag.dragging)
{
w->drag.dragging = 0;
w->drag.dragging = EINA_FALSE;
return 0;
}
@ -155,11 +137,11 @@ _ecore_win32_window_procedure(HWND window,
(w->drag.current_mouse_y == GET_Y_LPARAM(data_param)))
return 0;
INF("mouse move message");
w->drag.current_mouse_x = GET_X_LPARAM(data_param);
w->drag.current_mouse_y = GET_Y_LPARAM(data_param);
INF("mouse move message");
if (w->drag.dragging)
{
POINT pt;
@ -168,148 +150,8 @@ _ecore_win32_window_procedure(HWND window,
pt.y = GET_Y_LPARAM(data_param);
if (ClientToScreen(window, &pt))
{
if (w->drag.type == HTCAPTION)
{
int dx;
int dy;
dx = pt.x - w->drag.px;
dy = pt.y - w->drag.py;
ecore_win32_window_move(w, w->drag.x + dx, w->drag.y + dy);
w->drag.x += dx;
w->drag.y += dy;
w->drag.px = pt.x;
w->drag.py = pt.y;
return 0;
}
if (w->drag.type == HTLEFT)
{
int dw;
dw = pt.x - w->drag.px;
ecore_win32_window_move_resize(w, w->drag.x + dw, w->drag.y, w->drag.w - dw, w->drag.h);
w->drag.x += dw;
w->drag.w -= dw;
w->drag.px = pt.x;
w->drag.py = pt.y;
return 0;
}
if (w->drag.type == HTRIGHT)
{
int dw;
dw = pt.x - w->drag.px;
ecore_win32_window_resize(w, w->drag.w + dw, w->drag.h);
w->drag.w += dw;
w->drag.px = pt.x;
w->drag.py = pt.y;
return 0;
}
if (w->drag.type == HTTOP)
{
int dh;
dh = pt.y - w->drag.py;
ecore_win32_window_move_resize(w, w->drag.x, w->drag.y + dh, w->drag.w, w->drag.h - dh);
w->drag.y += dh;
w->drag.h -= dh;
w->drag.px = pt.x;
w->drag.py = pt.y;
return 0;
}
if (w->drag.type == HTBOTTOM)
{
int dh;
dh = pt.y - w->drag.py;
ecore_win32_window_resize(w, w->drag.w, w->drag.h + dh);
w->drag.h += dh;
w->drag.px = pt.x;
w->drag.py = pt.y;
return 0;
}
if (w->drag.type == HTTOPLEFT)
{
int dx;
int dy;
int dh;
int dw;
dw = pt.x - w->drag.px;
dh = pt.y - w->drag.py;
dx = dw;
dy = dh;
_ecore_win32_size_check(w,
w->drag.w - dw, w->drag.h - dh,
&dx, &dy);
ecore_win32_window_move_resize(w, w->drag.x + dx, w->drag.y + dy, w->drag.w - dw, w->drag.h - dh);
w->drag.x += dx;
w->drag.y += dy;
w->drag.w -= dw;
w->drag.h -= dh;
w->drag.px = pt.x;
w->drag.py = pt.y;
return 0;
}
if (w->drag.type == HTTOPRIGHT)
{
int dx;
int dy;
int dh;
int dw;
dw = pt.x - w->drag.px;
dh = pt.y - w->drag.py;
dx = dw;
dy = dh;
_ecore_win32_size_check(w,
w->drag.w, w->drag.h - dh,
&dx, &dy);
ecore_win32_window_move_resize(w, w->drag.x, w->drag.y + dy, w->drag.w, w->drag.h - dh);
w->drag.y += dy;
w->drag.w += dw;
w->drag.h -= dh;
w->drag.px = pt.x;
w->drag.py = pt.y;
return 0;
}
if (w->drag.type == HTBOTTOMLEFT)
{
int dx;
int dy;
int dh;
int dw;
dw = pt.x - w->drag.px;
dh = pt.y - w->drag.py;
dx = dw;
dy = dh;
_ecore_win32_size_check(w,
w->drag.w - dw, w->drag.h + dh,
&dx, &dy);
ecore_win32_window_move_resize(w, w->drag.x + dx, w->drag.y, w->drag.w - dw, w->drag.h + dh);
w->drag.x += dx;
w->drag.w -= dw;
w->drag.h += dh;
w->drag.px = pt.x;
w->drag.py = pt.y;
return 0;
}
if (w->drag.type == HTBOTTOMRIGHT)
{
int dh;
int dw;
dw = pt.x - w->drag.px;
dh = pt.y - w->drag.py;
ecore_win32_window_resize(w, w->drag.w + dw, w->drag.h + dh);
w->drag.w += dw;
w->drag.h += dh;
w->drag.px = pt.x;
w->drag.py = pt.y;
return 0;
}
if (ecore_win32_window_drag(w, pt.x, pt.y))
return 0;
}
}
@ -430,13 +272,13 @@ _ecore_win32_window_procedure(HWND window,
w = (Ecore_Win32_Window *)GetWindowLongPtr(window, GWLP_USERDATA);
ecore_win32_window_geometry_get(w,
NULL, NULL,
&w->drag.x, &w->drag.y,
&w->drag.w, &w->drag.h);
SetCapture(window);
w->drag.type = (DWORD)window_param;
w->drag.px = GET_X_LPARAM(data_param);
w->drag.py = GET_Y_LPARAM(data_param);
w->drag.dragging = 1;
w->drag.dragging = EINA_TRUE;
if ((DWORD)window_param == HTCAPTION)
ecore_win32_window_raise(w);
return 0;
@ -453,7 +295,7 @@ _ecore_win32_window_procedure(HWND window,
INF("sys command MOVE or SIZE window message : %dx%d", GET_X_LPARAM(data_param), GET_Y_LPARAM(data_param));
w = (Ecore_Win32_Window *)GetWindowLongPtr(window, GWLP_USERDATA);
w->drag.dragging = 1;
w->drag.dragging = EINA_TRUE;
return 0;
}
return DefWindowProc(window, message, window_param, data_param);

View File

@ -45,6 +45,14 @@ extern int _ecore_win32_log_dom_global;
#define ECORE_WIN32_WINDOW_CLASS "Ecore_Win32_Window_Class"
typedef enum
{
ECORE_WIN32_POS_HINTS_MIN_SIZE = 1 << 0,
ECORE_WIN32_POS_HINTS_MAX_SIZE = 1 << 1,
ECORE_WIN32_POS_HINTS_BASE_SIZE = 1 << 2,
ECORE_WIN32_POS_HINTS_STEP_SIZE = 1 << 3
} Ecore_Win32_Pos_Hints_Flags;
typedef struct _Ecore_Win32_Callback_Data Ecore_Win32_Callback_Data;
struct _Ecore_Win32_Callback_Data
@ -61,49 +69,52 @@ struct _Ecore_Win32_Callback_Data
struct _Ecore_Win32_Window
{
HWND window;
DWORD style; /* used to go fullscreen to normal */
RECT rect; /* used to go fullscreen to normal */
unsigned int min_width;
unsigned int min_height;
unsigned int max_width;
unsigned int max_height;
int base_width;
int base_height;
unsigned int step_width;
unsigned int step_height;
HWND window;
int mininal_window_width;
DWORD style; /* used to go fullscreen to normal */
RECT rect; /* used to go fullscreen to normal */
struct {
unsigned int iconified : 1;
unsigned int modal : 1;
unsigned int sticky : 1;
unsigned int maximized_vert : 1;
unsigned int maximized_horz : 1;
unsigned int shaded : 1;
unsigned int hidden : 1;
unsigned int fullscreen : 1;
unsigned int above : 1;
unsigned int below : 1;
unsigned int demands_attention : 1;
Ecore_Win32_Pos_Hints_Flags flags;
int min_width;
int min_height;
int max_width;
int max_height;
int base_width;
int base_height;
int step_width;
int step_height;
} pos_hints;
struct {
unsigned int iconified : 1;
unsigned int modal : 1;
unsigned int sticky : 1;
unsigned int maximized_vert : 1;
unsigned int maximized_horz : 1;
unsigned int shaded : 1;
unsigned int hidden : 1;
unsigned int fullscreen : 1;
unsigned int above : 1;
unsigned int below : 1;
unsigned int demands_attention : 1;
} state;
struct {
unsigned int desktop : 1;
unsigned int dock : 1;
unsigned int toolbar : 1;
unsigned int menu : 1;
unsigned int utility : 1;
unsigned int splash : 1;
unsigned int dialog : 1;
unsigned int normal : 1;
unsigned int desktop : 1;
unsigned int dock : 1;
unsigned int toolbar : 1;
unsigned int menu : 1;
unsigned int utility : 1;
unsigned int splash : 1;
unsigned int dialog : 1;
unsigned int normal : 1;
} type;
unsigned int pointer_is_in : 1;
unsigned int borderless : 1;
unsigned int iconified : 1;
unsigned int fullscreen : 1;
unsigned int pointer_is_in : 1;
unsigned int borderless : 1;
unsigned int iconified : 1;
unsigned int fullscreen : 1;
struct {
unsigned short width;
@ -114,15 +125,15 @@ struct _Ecore_Win32_Window
} shape;
struct {
DWORD type;
int x;
int y;
int w;
int h;
int px;
int py;
int current_mouse_x;
int current_mouse_y;
DWORD type;
int x;
int y;
int w;
int h;
int px;
int py;
int current_mouse_x;
int current_mouse_y;
unsigned int dragging : 1;
} drag;
@ -162,6 +173,8 @@ 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);
#ifdef __cplusplus
}

View File

@ -3,7 +3,6 @@
#endif
#include <stdlib.h>
#include <stdio.h> /* for printf */
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@ -33,7 +32,7 @@ enum _Ecore_Win32_Window_Z_Order
};
static Ecore_Win32_Window *
ecore_win32_window_internal_new(Ecore_Win32_Window *parent,
_ecore_win32_window_internal_new(Ecore_Win32_Window *parent,
int x,
int y,
int width,
@ -42,9 +41,6 @@ ecore_win32_window_internal_new(Ecore_Win32_Window *parent,
{
RECT rect;
Ecore_Win32_Window *w;
int minimal_width;
#warning "We need to handle minimal_height for window like we do with width."
/* int minimal_height; */
w = (Ecore_Win32_Window *)calloc(1, sizeof(Ecore_Win32_Window));
if (!w)
@ -53,6 +49,19 @@ ecore_win32_window_internal_new(Ecore_Win32_Window *parent,
return NULL;
}
rect.left = 0;
rect.top = 0;
rect.right = 0;
rect.bottom = 0;
if (!AdjustWindowRectEx(&rect, style, FALSE, 0))
{
ERR("AdjustWindowRect() failed");
free(w);
return NULL;
}
w->mininal_window_width = GetSystemMetrics(SM_CXMIN) - (rect.right - rect.left);
rect.left = 0;
rect.top = 0;
rect.right = width;
@ -64,19 +73,18 @@ ecore_win32_window_internal_new(Ecore_Win32_Window *parent,
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)
if (width < w->mininal_window_width)
width = w->mininal_window_width;
rect.left = 0;
rect.top = 0;
rect.right = width;
rect.bottom = height;
if (!AdjustWindowRectEx(&rect, style, FALSE, 0))
{
rect.right = rect.left + minimal_width;
ERR("AdjustWindowRect() failed");
free(w);
return NULL;
}
w->window = CreateWindowEx(0,
@ -104,14 +112,15 @@ ecore_win32_window_internal_new(Ecore_Win32_Window *parent,
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->pos_hints.flags = 0;
w->pos_hints.min_width = w->mininal_window_width;
w->pos_hints.min_height = 0;
w->pos_hints.max_width = 32767;
w->pos_hints.max_height = 32767;
w->pos_hints.base_width = w->mininal_window_width;
w->pos_hints.base_height = 0;
w->pos_hints.step_width = 0;
w->pos_hints.step_height = 0;
w->state.iconified = 0;
w->state.modal = 0;
@ -158,6 +167,255 @@ ecore_win32_window_internal_new(Ecore_Win32_Window *parent,
* Global *
*============================================================================*/
Eina_Bool
ecore_win32_window_drag(Ecore_Win32_Window *w, int ptx, int pty)
{
if (w->drag.type == HTCAPTION)
{
int dx;
int dy;
dx = ptx - w->drag.px;
dy = pty - w->drag.py;
if ((dx == 0) && (dy == 0))
return EINA_TRUE;
ecore_win32_window_move(w, w->drag.x + dx, w->drag.y + dy);
return EINA_TRUE;
}
if (w->drag.type == HTLEFT)
{
int dw;
dw = ptx - w->drag.px;
if (w->pos_hints.flags & ECORE_WIN32_POS_HINTS_STEP_SIZE)
{
int new_width;
new_width = w->pos_hints.base_width + ((w->drag.w - w->pos_hints.base_width - dw) / w->pos_hints.step_width) * w->pos_hints.step_width;
if ((new_width != w->drag.w) &&
(new_width >= w->pos_hints.base_width) &&
(new_width <= w->pos_hints.max_width))
ecore_win32_window_move_resize(w, w->drag.x - (new_width - w->drag.w), w->drag.y, new_width, w->drag.h);
}
else
{
if (((w->drag.w - dw) >= w->pos_hints.min_width) &&
((w->drag.w - dw) <= w->pos_hints.max_width))
ecore_win32_window_move_resize(w, w->drag.x + dw, w->drag.y, w->drag.w - dw, w->drag.h);
}
return EINA_TRUE;
}
if (w->drag.type == HTRIGHT)
{
int dw;
dw = ptx - w->drag.px;
if (w->pos_hints.flags & ECORE_WIN32_POS_HINTS_STEP_SIZE)
{
int new_width;
new_width = w->pos_hints.base_width + ((w->drag.w - w->pos_hints.base_width + dw) / w->pos_hints.step_width) * w->pos_hints.step_width;
if ((new_width != w->drag.w) &&
(new_width >= w->pos_hints.base_width) &&
(new_width <= w->pos_hints.max_width))
ecore_win32_window_resize(w, new_width, w->drag.h);
}
else
{
if (((w->drag.w + dw) >= w->pos_hints.min_width) &&
((w->drag.w + dw) <= w->pos_hints.max_width))
ecore_win32_window_resize(w, w->drag.w + dw, w->drag.h);
}
return EINA_TRUE;
}
if (w->drag.type == HTTOP)
{
int dh;
dh = pty - w->drag.py;
if (w->pos_hints.flags & ECORE_WIN32_POS_HINTS_STEP_SIZE)
{
int new_height;
new_height = w->pos_hints.base_height + ((w->drag.h - w->pos_hints.base_height - dh) / w->pos_hints.step_height) * w->pos_hints.step_height;
if ((new_height != w->drag.h) &&
(new_height >= w->pos_hints.base_height) &&
(new_height <= w->pos_hints.max_height))
ecore_win32_window_move_resize(w, w->drag.x, w->drag.y - (new_height - w->drag.h), w->drag.w, new_height);
}
else
{
if ((dh != 0) &&
((w->drag.h - dh) >= w->pos_hints.min_height) &&
((w->drag.h - dh) <= w->pos_hints.max_height))
ecore_win32_window_move_resize(w, w->drag.x, w->drag.y + dh, w->drag.w, w->drag.h - dh);
}
return EINA_TRUE;
}
if (w->drag.type == HTBOTTOM)
{
int dh;
dh = pty - w->drag.py;
if (w->pos_hints.flags & ECORE_WIN32_POS_HINTS_STEP_SIZE)
{
int new_height;
new_height = w->pos_hints.base_height + ((w->drag.h - w->pos_hints.base_height + dh) / w->pos_hints.step_height) * w->pos_hints.step_height;
if ((new_height != w->drag.h) &&
(new_height >= w->pos_hints.base_height) &&
(new_height <= w->pos_hints.max_height))
ecore_win32_window_resize(w, w->drag.w, new_height);
}
else
{
if (((w->drag.h + dh) >= w->pos_hints.min_height) &&
((w->drag.h + dh) <= w->pos_hints.max_height))
ecore_win32_window_resize(w, w->drag.w, w->drag.h + dh);
}
return EINA_TRUE;
}
if (w->drag.type == HTTOPLEFT)
{
int dh;
int dw;
dw = ptx - w->drag.px;
dh = pty - w->drag.py;
if (w->pos_hints.flags & ECORE_WIN32_POS_HINTS_STEP_SIZE)
{
int new_width;
int new_height;
new_width = w->pos_hints.base_width + ((w->drag.w - w->pos_hints.base_width - dw) / w->pos_hints.step_width) * w->pos_hints.step_width;
new_height = w->pos_hints.base_height + ((w->drag.h - w->pos_hints.base_height - dh) / w->pos_hints.step_height) * w->pos_hints.step_height;
if ((new_width != w->drag.w) &&
(new_width >= w->pos_hints.base_width) &&
(new_width <= w->pos_hints.max_width) &&
(new_height != w->drag.h) &&
(new_height >= w->pos_hints.base_height) &&
(new_height <= w->pos_hints.max_height))
ecore_win32_window_move_resize(w, w->drag.x - (new_width - w->drag.w), w->drag.y - (new_height - w->drag.h), new_width, new_height);
}
else
{
if (((w->drag.w - dw) >= w->pos_hints.min_width) &&
((w->drag.w - dw) <= w->pos_hints.max_width) &&
((w->drag.h - dh) >= w->pos_hints.min_height) &&
((w->drag.h - dh) <= w->pos_hints.max_height))
ecore_win32_window_move_resize(w, w->drag.x + dw, w->drag.y + dh, w->drag.w - dw, w->drag.h - dh);
}
return EINA_TRUE;
}
if (w->drag.type == HTTOPRIGHT)
{
int dh;
int dw;
dw = ptx - w->drag.px;
dh = pty - w->drag.py;
if (w->pos_hints.flags & ECORE_WIN32_POS_HINTS_STEP_SIZE)
{
int new_width;
int new_height;
new_width = w->pos_hints.base_width + ((w->drag.w - w->pos_hints.base_width + dw) / w->pos_hints.step_width) * w->pos_hints.step_width;
new_height = w->pos_hints.base_height + ((w->drag.h - w->pos_hints.base_height - dh) / w->pos_hints.step_height) * w->pos_hints.step_height;
if ((new_width != w->drag.w) &&
(new_width >= w->pos_hints.base_width) &&
(new_width <= w->pos_hints.max_width) &&
(new_height != w->drag.h) &&
(new_height >= w->pos_hints.base_height) &&
(new_height <= w->pos_hints.max_height))
ecore_win32_window_move_resize(w, w->drag.x, w->drag.y - (new_height - w->drag.h), new_width, new_height);
}
else
{
if (((w->drag.w + dw) >= w->pos_hints.min_width) &&
((w->drag.w + dw) <= w->pos_hints.max_width) &&
((w->drag.h - dh) >= w->pos_hints.min_height) &&
((w->drag.h - dh) <= w->pos_hints.max_height))
ecore_win32_window_move_resize(w, w->drag.x, w->drag.y + dh, w->drag.w + dw, w->drag.h - dh);
}
return EINA_TRUE;
}
if (w->drag.type == HTBOTTOMLEFT)
{
int dh;
int dw;
dw = ptx - w->drag.px;
dh = pty - w->drag.py;
if (w->pos_hints.flags & ECORE_WIN32_POS_HINTS_STEP_SIZE)
{
int new_width;
int new_height;
new_width = w->pos_hints.base_width + ((w->drag.w - w->pos_hints.base_width - dw) / w->pos_hints.step_width) * w->pos_hints.step_width;
new_height = w->pos_hints.base_height + ((w->drag.h - w->pos_hints.base_height + dh) / w->pos_hints.step_height) * w->pos_hints.step_height;
if ((new_width != w->drag.w) &&
(new_width >= w->pos_hints.base_width) &&
(new_width <= w->pos_hints.max_width) &&
(new_height != w->drag.h) &&
(new_height >= w->pos_hints.base_height) &&
(new_height <= w->pos_hints.max_height))
ecore_win32_window_move_resize(w, w->drag.x - (new_width - w->drag.w), w->drag.y, new_width, new_height);
}
else
{
if (((w->drag.w - dw) >= w->pos_hints.min_width) &&
((w->drag.w - dw) <= w->pos_hints.max_width) &&
((w->drag.h + dh) >= w->pos_hints.min_height) &&
((w->drag.h + dh) <= w->pos_hints.max_height))
ecore_win32_window_move_resize(w, w->drag.x + dw, w->drag.y, w->drag.w - dw, w->drag.h + dh);
}
return EINA_TRUE;
}
if (w->drag.type == HTBOTTOMRIGHT)
{
int dh;
int dw;
dw = ptx - w->drag.px;
dh = pty - w->drag.py;
if (w->pos_hints.flags & ECORE_WIN32_POS_HINTS_STEP_SIZE)
{
int new_width;
int new_height;
new_width = w->pos_hints.base_width + ((w->drag.w - w->pos_hints.base_width + dw) / w->pos_hints.step_width) * w->pos_hints.step_width;
new_height = w->pos_hints.base_height + ((w->drag.h - w->pos_hints.base_height + dh) / w->pos_hints.step_height) * w->pos_hints.step_height;
if ((new_width != w->drag.w) &&
(new_width >= w->pos_hints.base_width) &&
(new_width <= w->pos_hints.max_width) &&
(new_height != w->drag.h) &&
(new_height >= w->pos_hints.base_height) &&
(new_height <= w->pos_hints.max_height))
ecore_win32_window_resize(w, new_width, new_height);
}
else
{
if (((w->drag.w + dw) >= w->pos_hints.min_width) &&
((w->drag.w + dw) <= w->pos_hints.max_width) &&
((w->drag.h + dh) >= w->pos_hints.min_height) &&
((w->drag.h + dh) <= w->pos_hints.max_height))
ecore_win32_window_resize(w, w->drag.w + dw, w->drag.h + dh);
}
return EINA_TRUE;
}
return EINA_FALSE;
}
/*============================================================================*
* API *
*============================================================================*/
@ -194,10 +452,10 @@ ecore_win32_window_new(Ecore_Win32_Window *parent,
{
INF("creating window with border");
return ecore_win32_window_internal_new(parent,
x, y,
width, height,
WS_OVERLAPPEDWINDOW | WS_SIZEBOX);
return _ecore_win32_window_internal_new(parent,
x, y,
width, height,
WS_OVERLAPPEDWINDOW | WS_SIZEBOX);
}
/**
@ -222,10 +480,10 @@ ecore_win32_window_override_new(Ecore_Win32_Window *parent,
{
INF("creating window without border");
return ecore_win32_window_internal_new(parent,
x, y,
width, height,
WS_POPUP & ~(WS_CAPTION | WS_THICKFRAME));
return _ecore_win32_window_internal_new(parent,
x, y,
width, height,
WS_POPUP & ~(WS_CAPTION | WS_THICKFRAME));
}
/**
@ -354,21 +612,16 @@ ecore_win32_window_resize(Ecore_Win32_Window *window,
int width,
int height)
{
RECT rect;
DWORD style;
int x;
int y;
int minimal_width;
int minimal_height;
RECT rect;
DWORD style;
int x;
int y;
/* FIXME: on fullscreen, should not resize it */
if (!window) return;
INF("resizing window (%dx%d)", width, height);
minimal_width = MAX(GetSystemMetrics(SM_CXMIN), (int)window->min_width);
minimal_height = MAX(GetSystemMetrics(SM_CYMIN), (int)window->min_height);
if (!GetWindowRect(window->window, &rect))
{
ERR("GetWindowRect() failed");
@ -379,10 +632,10 @@ ecore_win32_window_resize(Ecore_Win32_Window *window,
y = rect.top;
rect.left = 0;
rect.top = 0;
if (width < minimal_width) width = minimal_width;
if (width > (int)window->max_width) width = window->max_width;
if (height < minimal_height) height = minimal_height;
if (height > (int)window->max_height) height = window->max_height;
if (width < window->pos_hints.min_width) width = window->pos_hints.min_width;
if (width > window->pos_hints.max_width) width = window->pos_hints.max_width;
if (height < window->pos_hints.min_height) height = window->pos_hints.min_height;
if (height > window->pos_hints.max_height) height = window->pos_hints.max_height;
rect.right = width;
rect.bottom = height;
if (!(style = GetWindowLong(window->window, GWL_STYLE)))
@ -425,25 +678,20 @@ ecore_win32_window_move_resize(Ecore_Win32_Window *window,
int width,
int height)
{
RECT rect;
DWORD style;
int minimal_width;
int minimal_height;
RECT rect;
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);
minimal_width = MAX(GetSystemMetrics(SM_CXMIN), (int)window->min_width);
minimal_height = MAX(GetSystemMetrics(SM_CYMIN), (int)window->min_height);
rect.left = 0;
rect.top = 0;
if (width < minimal_width) width = minimal_width;
if (width > (int)window->max_width) width = window->max_width;
if (height < minimal_height) height = minimal_height;
if (height > (int)window->max_height) height = window->max_height;
if (width < window->pos_hints.min_width) width = window->pos_hints.min_width;
if (width > window->pos_hints.max_width) width = window->pos_hints.max_width;
if (height < window->pos_hints.min_height) height = window->pos_hints.min_height;
if (height > window->pos_hints.max_height) height = window->pos_hints.max_height;
rect.right = width;
rect.bottom = height;
if (!(style = GetWindowLong(window->window, GWL_STYLE)))
@ -499,8 +747,8 @@ ecore_win32_window_geometry_get(Ecore_Win32_Window *window,
{
if (x) *x = 0;
if (y) *y = 0;
if (width) *width = GetSystemMetrics(SM_CXSCREEN);
if (height) *height = GetSystemMetrics(SM_CYSCREEN);
if (width) *width = 0;
if (height) *height = 0;
return;
}
@ -563,8 +811,8 @@ ecore_win32_window_size_get(Ecore_Win32_Window *window,
if (!window)
{
if (width) *width = GetSystemMetrics(SM_CXSCREEN);
if (height) *height = GetSystemMetrics(SM_CYSCREEN);
if (width) *width = 0;
if (height) *height = 0;
return;
}
@ -594,14 +842,27 @@ ecore_win32_window_size_get(Ecore_Win32_Window *window,
*/
EAPI void
ecore_win32_window_size_min_set(Ecore_Win32_Window *window,
unsigned int min_width,
unsigned int min_height)
int min_width,
int min_height)
{
if (!window) return;
printf ("ecore_win32_window_size_min_set : %p %d %d\n", window, min_width, min_height);
window->min_width = min_width;
window->min_height = min_height;
INF("setting minimum window size to %dx%d", min_width, min_height);
if ((min_width > 0) && (min_height > 0))
{
if (min_width < window->mininal_window_width)
min_width = window->mininal_window_width;
window->pos_hints.flags |= ECORE_WIN32_POS_HINTS_MIN_SIZE;
window->pos_hints.min_width = min_width;
window->pos_hints.min_height = min_height;
if (!(window->pos_hints.flags & ECORE_WIN32_POS_HINTS_BASE_SIZE))
{
window->pos_hints.base_width = min_width;
window->pos_hints.base_height = min_height;
}
}
}
/**
@ -617,14 +878,20 @@ ecore_win32_window_size_min_set(Ecore_Win32_Window *window,
*/
EAPI void
ecore_win32_window_size_min_get(Ecore_Win32_Window *window,
unsigned int *min_width,
unsigned int *min_height)
int *min_width,
int *min_height)
{
if (!window) return;
if (!window || !(window->pos_hints.flags & ECORE_WIN32_POS_HINTS_MIN_SIZE))
{
if (min_width) *min_width = 0;
if (min_height) *min_height = 0;
return;
}
printf ("ecore_win32_window_size_min_get : %p %d %d\n", window, window->min_width, window->min_height);
if (min_width) *min_width = window->min_width;
if (min_height) *min_height = window->min_height;
INF("getting minimum window size: %dx%d", window->pos_hints.min_width, window->pos_hints.min_height);
if (min_width) *min_width = window->pos_hints.min_width;
if (min_height) *min_height = window->pos_hints.min_height;
}
/**
@ -640,14 +907,19 @@ ecore_win32_window_size_min_get(Ecore_Win32_Window *window,
*/
EAPI void
ecore_win32_window_size_max_set(Ecore_Win32_Window *window,
unsigned int max_width,
unsigned int max_height)
int max_width,
int max_height)
{
if (!window) return;
printf ("ecore_win32_window_size_max_set : %p %d %d\n", window, max_width, max_height);
window->max_width = max_width;
window->max_height = max_height;
INF("setting maximum window size to %dx%d", max_width, max_height);
if ((max_width > 0) && (max_height > 0))
{
window->pos_hints.flags |= ECORE_WIN32_POS_HINTS_MAX_SIZE;
window->pos_hints.max_width = max_width;
window->pos_hints.max_height = max_height;
}
}
/**
@ -663,14 +935,20 @@ ecore_win32_window_size_max_set(Ecore_Win32_Window *window,
*/
EAPI void
ecore_win32_window_size_max_get(Ecore_Win32_Window *window,
unsigned int *max_width,
unsigned int *max_height)
int *max_width,
int *max_height)
{
if (!window) return;
if (!window || !(window->pos_hints.flags & ECORE_WIN32_POS_HINTS_MAX_SIZE))
{
if (max_width) *max_width = 0;
if (max_height) *max_height = 0;
return;
}
printf ("ecore_win32_window_size_max_get : %p %d %d\n", window, window->max_width, window->max_height);
if (max_width) *max_width = window->max_width;
if (max_height) *max_height = window->max_height;
INF("getting maximum window size: %dx%d", window->pos_hints.max_width, window->pos_hints.max_height);
if (max_width) *max_width = window->pos_hints.max_width;
if (max_height) *max_height = window->pos_hints.max_height;
}
/**
@ -686,14 +964,19 @@ ecore_win32_window_size_max_get(Ecore_Win32_Window *window,
*/
EAPI void
ecore_win32_window_size_base_set(Ecore_Win32_Window *window,
unsigned int base_width,
unsigned int base_height)
int base_width,
int base_height)
{
printf ("ecore_win32_window_size_base_set : %p %d %d\n", window, base_width, base_height);
if (!window) return;
window->base_width = base_width;
window->base_height = base_height;
INF("setting base window size to %dx%d", base_width, base_height);
if ((base_width > 0) && (base_height > 0))
{
window->pos_hints.flags |= ECORE_WIN32_POS_HINTS_BASE_SIZE;
window->pos_hints.base_width = base_width;
window->pos_hints.base_height = base_height;
}
}
/**
@ -709,14 +992,20 @@ ecore_win32_window_size_base_set(Ecore_Win32_Window *window,
*/
EAPI void
ecore_win32_window_size_base_get(Ecore_Win32_Window *window,
unsigned int *base_width,
unsigned int *base_height)
int *base_width,
int *base_height)
{
if (!window) return;
if (!window || !(window->pos_hints.flags & ECORE_WIN32_POS_HINTS_BASE_SIZE))
{
if (base_width) *base_width = 0;
if (base_height) *base_height = 0;
return;
}
printf ("ecore_win32_window_size_base_get : %p %d %d\n", window, window->base_width, window->base_height);
if (base_width) *base_width = window->base_width;
if (base_height) *base_height = window->base_height;
INF("getting base window size: %dx%d", window->pos_hints.base_width, window->pos_hints.base_height);
if (base_width) *base_width = window->pos_hints.base_width;
if (base_height) *base_height = window->pos_hints.base_height;
}
/**
@ -732,14 +1021,19 @@ ecore_win32_window_size_base_get(Ecore_Win32_Window *window,
*/
EAPI void
ecore_win32_window_size_step_set(Ecore_Win32_Window *window,
unsigned int step_width,
unsigned int step_height)
int step_width,
int step_height)
{
printf ("ecore_win32_window_size_step_set : %p %d %d\n", window, step_width, step_height);
if (!window) return;
window->step_width = step_width;
window->step_height = step_height;
INF("setting step window size to %dx%d", step_width, step_height);
if ((step_width > 0) && (step_height > 0))
{
window->pos_hints.flags |= ECORE_WIN32_POS_HINTS_STEP_SIZE;
window->pos_hints.step_width = step_width;
window->pos_hints.step_height = step_height;
}
}
/**
@ -755,14 +1049,20 @@ ecore_win32_window_size_step_set(Ecore_Win32_Window *window,
*/
EAPI void
ecore_win32_window_size_step_get(Ecore_Win32_Window *window,
unsigned int *step_width,
unsigned int *step_height)
int *step_width,
int *step_height)
{
if (!window) return;
if (!window || !(window->pos_hints.flags & ECORE_WIN32_POS_HINTS_STEP_SIZE))
{
if (step_width) *step_width = 0;
if (step_height) *step_height = 0;
return;
}
printf ("ecore_win32_window_size_step_get : %p %d %d\n", window, window->step_width, window->step_height);
if (step_width) *step_width = window->step_width;
if (step_height) *step_height = window->step_height;
INF("getting step window size: %dx%d", window->pos_hints.step_width, window->pos_hints.step_height);
if (step_width) *step_width = window->pos_hints.step_width;
if (step_height) *step_height = window->pos_hints.step_height;
}
/**