ApoorvaJ / Papaya

A GPU-powered image editor (in the making)
MIT License
373 stars 33 forks source link

Aero snap on Windows #11

Open ApoorvaJ opened 8 years ago

ApoorvaJ commented 8 years ago

Aero snap is the thing introduced in Windows Vista where if you drag the window to the left or right edges of the screen, it resizes and fits into that half of the screen. Similarly, if you drag it to the top of the screen, it maximizes.

Early on in development, I tried a number of things to get Aero Snap working in Windows, but failed. In Papaya, we want a borderless, captionless window that has proper minimization, maximization and restore functionality, and that does not cover the task bar. This turned out to be remarkably difficult, as one window style would break some essential feature. And so Papaya currently doesn't currently snap to screen edges as it should.

If you are familiar with the Windows API, please have a look at this if you can. The relevant code is located in the src/papaya_platform_win32.cpp file in the WinMain() function, in the // Create Window scope.

GreenLightning commented 8 years ago

I found this question on stackoverflow very helpful (especially the edits and comments to the question itself).

Essentially, the WS_THICKFRAME window style enables Aero Snap, but you can respond to WM_NCCALCSIZE to hide the borders.

EDIT: Apparently this does not work everywhere. See pull request #13.