From d37269a23b1bec33be41fdd4cd466943c78f00e3 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Thu, 31 Dec 2015 10:39:51 +0000 Subject: The changes introduced at r.10921 destroyed program-controlled window resizing. This change hopefully repairs that. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10987 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_win32.cxx | 53 ++++++++++++++++++++++++----------------------------- 1 file changed, 24 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx index d1927e7a3..2ae1e6145 100644 --- a/src/Fl_win32.cxx +++ b/src/Fl_win32.cxx @@ -104,10 +104,6 @@ typedef int (WINAPI* fl_wsk_select_f)(int, fd_set*, fd_set*, fd_set*, const stru typedef int (WINAPI* fl_wsk_fd_is_set_f)(SOCKET, fd_set *); static HMODULE s_wsock_mod = 0; -static HMODULE dwmapi_dll = LoadLibrary("dwmapi.dll"); -typedef HRESULT (WINAPI* DwmGetWindowAttribute_type)(HWND hwnd, DWORD dwAttribute, PVOID pvAttribute, DWORD cbAttribute); -static DwmGetWindowAttribute_type DwmGetWindowAttribute = 0; -static const DWORD DWMA_EXTENDED_FRAME_BOUNDS = 9; static fl_wsk_select_f s_wsock_select = 0; static fl_wsk_fd_is_set_f fl_wsk_fd_is_set = 0; @@ -1622,19 +1618,7 @@ static int fake_X_wm_style(const Fl_Window* w,int &X,int &Y, int &bt,int &bx, in } int Fl_X::fake_X_wm(const Fl_Window* w,int &X,int &Y, int &bt,int &bx, int &by) { - int val = fake_X_wm_style(w, X, Y, bt, bx, by, 0, 0, w->maxw, w->minw, w->maxh, w->minh, w->size_range_set); - if (dwmapi_dll) { - RECT r; - if (!DwmGetWindowAttribute) DwmGetWindowAttribute = (DwmGetWindowAttribute_type)GetProcAddress(dwmapi_dll, "DwmGetWindowAttribute"); - if (DwmGetWindowAttribute) { - if ( DwmGetWindowAttribute(fl_xid(w), DWMA_EXTENDED_FRAME_BOUNDS, &r, sizeof(RECT)) == S_OK ) { - bx = (r.right - r.left - w->w())/2; - by = bx; - bt = r.bottom - r.top - w->h() - 2*by; - } - } - } - return val; + return fake_X_wm_style(w, X, Y, bt, bx, by, 0, 0, w->maxw, w->minw, w->maxh, w->minh, w->size_range_set); } //////////////////////////////////////////////////////////////// @@ -2739,10 +2723,29 @@ void Fl_Paged_Device::print_window(Fl_Window *win, int x_offset, int y_offset) void Fl_Paged_Device::draw_decorated_window(Fl_Window *win, int x_offset, int y_offset, Fl_Surface_Device *toset) { - int X, Y, bt, bx, by, ww, wh; // compute the window border sizes - Fl_X::fake_X_wm(win, X, Y, bt, bx, by); - ww = win->w() + 2 * bx; - wh = win->h() + bt + 2 * by; + static HMODULE dwmapi_dll = LoadLibrary("dwmapi.dll"); + typedef HRESULT (WINAPI* DwmGetWindowAttribute_type)(HWND hwnd, DWORD dwAttribute, PVOID pvAttribute, DWORD cbAttribute); + static DwmGetWindowAttribute_type DwmGetWindowAttribute = 0; + static const DWORD DWMWA_EXTENDED_FRAME_BOUNDS = 9; + int bt, bx, by; // compute the window border sizes + RECT r; + int need_r = 1; + if (dwmapi_dll) { + if (!DwmGetWindowAttribute) DwmGetWindowAttribute = (DwmGetWindowAttribute_type)GetProcAddress(dwmapi_dll, "DwmGetWindowAttribute"); + if (DwmGetWindowAttribute) { + if ( DwmGetWindowAttribute(fl_xid(win), DWMWA_EXTENDED_FRAME_BOUNDS, &r, sizeof(RECT)) == S_OK ) { + need_r = 0; + } + } + } + if (need_r) { + GetWindowRect(fl_xid(win), &r); + } + bx = (r.right - r.left - win->w())/2; + by = bx; + bt = r.bottom - r.top - win->h() - 2*by; + int ww = win->w() + 2 * bx; + int wh = win->h() + bt + 2 * by; Fl_Display_Device::display_device()->set_current(); // make window current win->show(); Fl::check(); @@ -2750,14 +2753,6 @@ void Fl_Paged_Device::draw_decorated_window(Fl_Window *win, int x_offset, int y_ HDC save_gc = fl_gc; fl_gc = GetDC(NULL); // get the screen device context // capture the 4 window sides from screen - RECT r; - HRESULT res = S_OK + 1; - if (DwmGetWindowAttribute) { - res = DwmGetWindowAttribute(fl_window, DWMA_EXTENDED_FRAME_BOUNDS, &r, sizeof(RECT)); - } - if (res != S_OK) { - GetWindowRect(fl_window, &r); - } Window save_win = fl_window; fl_window = NULL; // force use of read_win_rectangle() by fl_read_image() uchar *top_image = fl_read_image(NULL, r.left, r.top, ww, bt + by); -- cgit v1.2.3