sgl
changeset 26:e4c79d2c7f78
finishing win32 module
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 27 Jun 2011 12:19:14 +0300 |
parents | 0eb6abc43ac6 |
children | 25de96fb1526 |
files | src/wsys_w32.c |
diffstat | 1 files changed, 51 insertions(+), 1 deletions(-) [+] |
line diff
1.1 --- a/src/wsys_w32.c Mon Jun 27 12:05:51 2011 +0300 1.2 +++ b/src/wsys_w32.c Mon Jun 27 12:19:14 2011 +0300 1.3 @@ -34,6 +34,7 @@ 1.4 /* window management */ 1.5 static int set_active(int id); 1.6 static struct window *find_window(int id); 1.7 +static struct window *find_window_handle(HWND wh); 1.8 static int activate_window(struct window *win); 1.9 static int set_title(const char *str); 1.10 static void redisplay(void); 1.11 @@ -49,6 +50,7 @@ 1.12 1.13 static LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam); 1.14 static int mouse_button(unsigned int msg); 1.15 +static void calc_win_size(int w, int h, int *width, int *height, int *posx, int *posy); 1.16 1.17 1.18 static struct wsys_module ws = { 1.19 @@ -258,7 +260,20 @@ 1.20 struct window *win = winlist; 1.21 1.22 while(win) { 1.23 - if(win->win == id) { 1.24 + if(win->id == id) { 1.25 + return win; 1.26 + } 1.27 + win = win->next; 1.28 + } 1.29 + return 0; 1.30 +} 1.31 + 1.32 +static struct window *find_window_handle(HWND wh) 1.33 +{ 1.34 + struct window *win = winlist; 1.35 + 1.36 + while(win) { 1.37 + if(win->win == wh) { 1.38 return win; 1.39 } 1.40 win = win->next; 1.41 @@ -423,6 +438,41 @@ 1.42 return -1; 1.43 } 1.44 1.45 +static void calc_win_size(int w, int h, int *width, int *height, int *posx, int *posy) 1.46 +{ 1.47 + RECT rect; 1.48 + DEVMODE dmode; 1.49 + unsigned int style = WS_BORDER | WS_CAPTION | WS_MINIMIZEBOX | WS_POPUP | WS_SYSMENU | WS_VISIBLE; 1.50 + 1.51 + rect.left = rect.top = 0; 1.52 + rect.right = w; 1.53 + rect.bottom = h; 1.54 + 1.55 + AdjustWindowRect(&rect, style, 0); 1.56 + 1.57 + *width = rect.right - rect.left; 1.58 + *height = rect.bottom - rect.top; 1.59 + 1.60 + *posx = *posy = 0; 1.61 + 1.62 + memset(&dmode, 0, sizeof dmode); 1.63 + dmode.dmSize = sizeof dmode; 1.64 + 1.65 + if(EnumDisplaySettings(0, ENUM_CURRENT_SETTINGS, &dmode)) { 1.66 + int x, y; 1.67 + 1.68 + x = (dmode.dmPelsWidth - *width) / 2; 1.69 + if(x > 0) { 1.70 + *posx = x; 1.71 + } 1.72 + 1.73 + y = (dmode.dmPelsHeight - *height) / 2; 1.74 + if(y > 0) { 1.75 + *posy = y; 1.76 + } 1.77 + } 1.78 +} 1.79 + 1.80 #else 1.81 int sgl_wsys_w32_silence_the_fucking_empty_file_warnings; 1.82 #endif