odd behavior with Terraria windowed in TOPMOST mode

quixilver87

Terrarian
Steam or GOG
Steam
Single Player/Multiplayer
Both
Operating System
Windows 10
Terraria Version
1.4.0.5
Controls Used
Keyboard/Mouse
was playing around with window order today, and wrote a quick little program to lock the window position and size because I'd regularly clicked off the window or clicked to resize the window accidentally while fighting or general derpyness.
when the window is resized manually, the field of view narrows to match the screen ratio. This I think is normal. but that means I need to get the window to match 1080p Ratio exactly to get the widest field of view (and switching to it by the menu was a somewhat tedious process for how often I was accidentally changing the window size because I prefer ~2338x1460 resolution on my 4k screen). Just a short story on my motives for making the size locking program.

one of the obvious options while making this was to have it set the window to TOPMOST via a HWND handle.

With the window in TOPMOST mode, if it is the only TOPMOST window, it does not pass inputs properly if it is not Active (if you click into another window). It will process all mouse clicks on any screen (making rod of discord and zenith etc extremely powerful) and these are properly forwarded to their destination process. Key-presses are somewhat more problematic. Terraria seems to eat every 3rd keypress in this condition.

when quickly, dynamically resized (by hand then by the locker program) occasionally the window will assume a strange stretched state where most of the menus are not 'on screen' and everything is highly zoomed in. I've once gotten it to expand the field of view when dynamically resizing aswell, putting the 'settings' menu option about 1/3 of the way to the middle of the screen, but this reverted itself after moving ingame whereas zoomed in version stayed that way untill another dynamic resize.
I mention this specifically because I've made sure to pass the ASYNC flag to ensure that the terraria process is the one that recieves the resize command and it's thread will handle the resize and redraw. (SetWindowPos(_,HWND_TOPMOST,_,_,_,SWP_ASYNCWINDOWPOS)

I know this is not really a 'bug' in the literal sense.. I am doing some weird stuff... but it'd be really cool if the window processed inputs properly in this state as there are commercially available programs that do exactly what I'm doing and this kind of tool could be very useful for streamers.

if anyone wants the C++ code I used to create this, it's only ~100 lines compiled on the free BloodShed Dev-CPP IDE. If anyone wants the program, I can make that available aswell though I'm quite sure it's not kosher to share a link to an executable on here.
 
Last edited:
Back
Top Bottom