Re: [Plib-devel] [PATCH] PW window size on Win32
Brought to you by:
sjbaker
From: Jan R. <slo...@gm...> - 2005-09-03 12:13:32
|
Am Fri, 02 Sep 2005 18:40:44 -0700 schrieb Steve Baker <sjb...@ai...>: > Jan Reucker wrote: > > Hello! > > > > The current PLIB CVS version has a bug regarding window sizes on > > Win32: When resizing a window, the new size will be the size of > > the window including the borders. This is wrong, the size parameters > > should describe the size of the window's client area. The attached > > patch fixes this by recalculating the window size from the client > > area size and the window style each time the window is resized. > > We've been through this problem at least a couple times before. > > How can it not be fixed by now? > > Are we sure this isn't the way it is for some very good reason? I think there's some confusion regarding window size vs. client area size. The Windows API itself is very confusing when it comes to these parameters. There are two things to be defined and maybe explicitely stated in the PW documentation: - Size parameters shall always specify the size of the *client area* regardless of the window decorations - Origin parameters shall always specify the top left corner of the *window*, including decorations. The X11 implementation works exactly this way, so I was confused when I first ran pw_demo on Windows. Only the initial size was o.k., but when calling pwSetSize, the new size actually was the window size, not the client area size. Looking at pwWindows.cxx: - CreateWindow() takes the window size including decorations, so you need to convert the client rect to the proper window rect using AdjustWindowRect(). This is already done in 1.8.4, so the initial size is o.k. - SetWindowPos() also takes the full window size, but pwSetSize() is called with the desired client area size. All you have to do is convert this to the window size by calling AdjustWindowRect() just like in pwInit(). - The WM_SIZE message has the client area size as parameters, so using this as the new size[] values is o.k. So how can we be sure if now everything is correct? First, please add the above definitions to the documentation so that we have a specification of how the pw... functions *shall* work. As I said before, this is the way it works on X11 and I think it makes sense to specify the size as the client area size and the origin on window manager level as the origin of the decorated window. Second, maybe we should extend the pw_demo by some keys to call pwSetSizeOrigin() and pwSetOrigin() with some test parameters to verify that all implementations of PW work as specified. BTW, there's a problem with the '<' key on Windows: It shall resize the window to 100x100, but for some unknown reason the window will always be at least 104x104 pixels. Tested on WinXP and Win98. So maybe we should change this key to 200x200 to avoid confusion. Kind regards, Jan R. -- Jan Reucker email: jan dot reucker at web dot de web: http://www.reucker-online.de |