Create X11 Window with a fixed size - c++

For a C++ Vulkan application with X11, I need to create a window with a fixed size that cannot be maximized or scaled by the user. Reason is that the application is written for that size and just doesn't scale.
Is there an easy way to achieve this? A parameter to XCreateWindow maybe?
Regards

Related

How do I make a VTK program launch in a maximized window?

In VTK, I'm aware of making a "full-screen" window as well as adjusting the window size:
renderWindow->SetSize(1200,800);
renderWindow->SetFullScreen(true);
However, I want to get the application to start in a maximized window. I've searched high and low but cannot find any information on how to do this. Any suggestions?
This will do the trick:
renderWindow->SetSize(renderWindow->GetScreenSize());

disable window resize in opengl c++

Is it possible to disable a window resize created with opengl using c++? I'm looking for this because I'm trying to draw a graph and the letters in the scale (or title) will have their position changed after a resize.
That can't be done in OpenGL without a windowing API. Using GLUT, you can call glutReshapeWindow in the reshape callback to reset the size when the user tries to change it. Alternatively, if you don't need it windowed, go fullscreen via glutFullScreen to stop the user from reshaping the window.
As far as I know that's the only portable way to do it.
Hope this helps.

OpenGL with dual monitors

I want to develop one OpenGL application that is using the two monitors for display. However, if I specify the window size in glutInitWindowSize() to be the size which is the sum of the two monitors, then the result window is still always in one monitor, even though I can drag the window to another monitor or reshape.
Does OpenGL automatically detect another monitor and use the total size of the two monitors?
It's not OpenGL that is limiting the size of the window, it's GLUT.
You have to figure out a way to change the way GLUT sets up and creates a window. On Windows, it seems you can use win32 API to change these settings during runtime.

Handling maximized windows using SDL

We recently ported Bitfighter from GLUT to SDL. There were numerous benefits to doing this, but a few drawbacks as well, especially in the area of window management.
Bitfighter runs in a fixed-aspect-ratio window (800x600 pixels). Users can make their window any size they want, but we capture the resize event and make adjustments to the requested size to ensure the window keeps the correct proportions (using SDL_SetVideoMode).
(The following problem applies to Windows, but has not yet been tested on other platforms. What I describe below refers specifically to Windows, though I am looking for a platform-independent solution.)
Ordinarily, this works great, except when users maximze their window by double clicking on the title bar or using the maximize button. In that case, the window resize event is called with the a window size approximating the screen size (minus some pixels for window ornamentation). Unfortunately, when the window is maximized, SDL_SetVideoMode has no effect (unlike GLUT which was able to resize a maximized window). Furthermore, subsequent calls to SDL_GetVideoInfo report the size we requested, not the actual current size of the window, so it is hard to tell if the attempted resizing worked.
I am looking for a platform independent way to do any of the following (in descending order of preference):
Resize a window after it's been maximized
Detect when a window has been maximized so that, knowing I can't resize it, I can at least adjust the video to be centered
Prevent a window from being maximized (block double clicks on window title bar, use of the maximize button, and dragging the window to the top of the screen)
Bitfighter is written in C++, and we're using the latest official release of SDL.
Migrate to SDL 2.0 (which it seems you already have)
SDL 2.0 provides a better API to window management (it actually provides one). While there are still many bugs in Windows management in SDL 2.0 (especially on the Linux side), it has vastly improved since the 1.2 days.
I assume, that you use OpenGL with SDL, because you used GLUT before. I don't know any solutions for that problem, exept point 2. If you want the Video to have a specific size, just leave the SDL-Window like it is, and call
glViewport(0, 0, width, height);
with the right size with the right proportions.
With that solutions you will still have a black border in your window, but It only shows as much, as you want. (with the first 2 arguments you can also set the position of the Viewport in the window ;) )

Best Method for Minimizable Fullscreen Window

I'm coding a short game in C++ and Win32, and I want to be able to make it in fullscreen with a fixed size. I also want the user to be able to switch focus between the game window and other windows as much as he/she wants without any weird screen glitches.
So far I know of the ChangeDisplaySettings function and creating the window with the WS_POPUP style at initialization to make it fullscreen. To detect the user switching focus to other windows by way of alt+tab or otherwise, what messages should I be handling on the window's WndProc or should I be using another function? When loss of focus is detected should I only call ChangeDisplaySettings(NULL, 0); or are there other functions I should call as well? And what method should I use to handle focus back into the window?
Also can anyone give me some info on how to make it work smoothly for different screen sizes?
Thanks for any help.
If you want an exclusive full screen window, use DirectX.
But I don't recommend it. Changing the display mode causes glitches, rearranges the users icons and so on. Whether done by you, or Direct X.
Rather create a normal window at your native res, and let the user maximize it if wanted.
You could also use the GDI+ library of Windows XP (and newer) to use hardware-accelerated stretching (draw in 640x480, let GDI+ resize it to the native resolution). Then you don't need exclusive mode of DirectDraw nor ChangeDisplaySettings.
Also drawing into a 640x480 big background buffer and bit blitting it on the drawing surface via StretchBlt can be a performant solution.