Jump to content

Solved - [LINUX] SetLayout not working


Recommended Posts

I am pplaying with changing the resolution in my game. My idea was to start simple ... Hit L and the resolution is changed. So when So when I call window->SetLayout(0, 0, 1600, 1200) the resolution is not changed from the default 1024x768.Codes:

#include "App.h"#include "game/BranchLoop.h"using namespace Leadwerks;App::App() : window(NULL), context(NULL), world(NULL), camera(NULL), loop(NULL){}App::~App() { if (NULL != loop) { delete loop; } if (NULL != world) { delete world; } if (NULL != window) { delete window; }}bool App::Start(){ //Initialize Steamworks (optional) /*if (!Steamworks::Initialize()) { System::Print("Error: Failed to initialize Steam."); return false; }*/ //Create a window window = Leadwerks::Window::Create("branch"); //Create a context context = Context::Create(window); //Create a world world = World::Create(); //Create a camera camera = Camera::Create(); camera->Move(0,2,-5); loop = new Branch::BranchLoop(context, window, camera); //Hide the mouse cursor window->HideMouse(); std::string mapname = System::GetProperty("map","Maps/start.map"); Map::Load(mapname); //Move the mouse to the center of the screen window->SetMousePosition(context->GetWidth()/2,context->GetHeight()/2); return true;}bool App::Loop(){ //Close the window to end the program if (window->Closed()) return false; //Press escape to end freelook mode if (window->KeyHit(Key::Escape)) { window->ShowMouse(); return false; } if (window->KeyHit(Key::L)) { System::Print("Change layout"); window->SetLayout(0, 0, 1600, 1200); } loop->preRenderUpdate(); Leadwerks::Time::Update(); world->Update(); world->Render(); loop->postRenderUpdate(); context->Sync(false); return true;}

And yeha, I get the output "Change layout" but nothing happens.

Link to comment
Share on other sites

I haven't specifically tried that yet but it was already clear that basically none of the windowing features work under Linux. Just take a look at the full screen situation that still doesn't fully work let alone all the other window flags.

Link to comment
Share on other sites

I haven't specifically tried that yet but it was already clear that basically none of the windowing features work under Linux. Just takea look at the full screen situation that still doesn't fully work let alone all the other window flags.

Mmmmm True.

 

I forgot my specs.

 

Linux dist:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.2 LTS
Release:	 14.04
Codename:	 trusty

 

Graphics card:

fglrxinfo
display: :0 screen: 0
OpenGL vendor string: Advanced Micro Devices, Inc.
OpenGL renderer string: AMD Radeon HD 5700 Series
OpenGL version string: 4.3.12798 Compatibility Profile Context 13.35.1005

 

A question. Will this bug be fixed soon or something that will be included when you get in to fixing the Uniform buffers and FBOs mentioned in this blog post: http://www.leadwerks.com/werkspace/blog/1/entry-1427-34-recap-and-beyond/

Link to comment
Share on other sites

This is the actual code for SetLayout:

    void Window::SetLayout(const int x, const int y, const int width, const int height)
   {
    XMoveResizeWindow(this->display,this->window,x,y,width,height);
   }

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

This is the actual code for SetLayout:

 void Window::SetLayout(const int x, const int y, const int width, const int height)
{
 XMoveResizeWindow(this->display,this->window,x,y,width,height);
}

 

Ok, so you probably need to call XSetWMNormalHints before you call XMoveResizewindow. This is because some window managers may redirect window configuration requests, but ignore the resulting events and pay property changes instead.

 

Some more info ...

Page 623 in this book: https://books.google.se/books?id=2uVfJj_4AZgC&printsec=frontcover&source=gbs_ge_summary_r&cad=0#v=onepage&q&f=false

This man page: http://manpages.ubuntu.com/manpages/saucy/man3/XAllocSizeHints.3.html

  • Upvote 1
Link to comment
Share on other sites

Ok I have done some more research.

 

A god idea is to read this: http://www.hpc.unimelb.edu.au/nec/g1ae02e/appd.html, and clean out all obsolete stuff like XSetStandardProperties (Pre X11 legacy stuff).

 

Also XMoveResizeWindow can sometimes be ignored and we end up with no-op: http://tronche.com/gui/x/xlib/window/XMoveResizewindow.html

 

I think this is some good hints from SDL that can interpreted like this:

// Apparently, if the X11 Window is set to a 'non-resizable' window, you cannot resize it using the
// XResizeWindow, thus we must set the size hints to adjust the window size.
XSizeHints *sizehints = XAllocSizeHints();
long userhints;
XGetWMNormalHints(display, data->xwindow, sizehints, &userhints);
sizehints->min_width = sizehints->max_width = window->w;
sizehints->min_height = sizehints->max_height = window->h;
sizehints->flags |= PMinSize | PMaxSize;
XSetWMNormalHints(display, data->xwindow, sizehints);
XFree(sizehints);
// WMs each have their little quirks with that. When you change the
// size hints, they get a ConfigureNotify event with the
// WM_NORMAL_SIZE_HINTS Atom. They all save the hints then, but they
// dont all resize the window right away to enforce the new hints.
// Some of them resize only after:
// - A user-initiated move or resize
// - A code-initiated move or resize
// - Hiding & showing window (Unmap & map)
// The following move & resize seems to help a lot of WMs that didn't
// properly update after the hints were changed. We don't do a
// hide/show, because there are supposedly subtle problems with doing so
// and transitioning from windowed to fullscreen in Unity.
XResizeWindow(display, data->xwindow, window->w, window->h);
XMoveWindow(display, data->xwindow, window->x, window->y);
XRaiseWindow(display, data->xwindow);

 

Inspired by X11_SetWindowSize (https://hg.libsdl.org/SDL/file/3331d2f57704/src/video/x11/SDL_x11window.c#l831)

The comments about Unity in that file is very interesting also since that is the only WM that Leadwerks support.

Edited by codeape
Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...

It's low priority because the information needed to fix this is not readily available, and full-screen mode in Linux only presently supports the native monitor resolution. So it's not like not being able to change the size of a windowed game on Linux is holding anyone back right now.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

I solved it with this little code change:

 

window = Leadwerks::Window::Create("test", 0, 0, 1024, 768, Leadwerks::Window::Resizable);

 

The key was setting the style argument of Window::Create() to Leadwerks::Window::Resizable. The Leadwerks C++ template code looks like this:

 

Leadwerks::Window::Create("branch");

 

The style argument defaults to Leadwerks::Window::Titlebar and that does apparently not play nice with SetLayout in Linux but works well in Windows.

Link to comment
Share on other sites

Interesting. This is the code in Linux that handles the resize creation flag:

	 if (Window::Resizable & style)
 {
	 XSetStandardProperties(display, window->window, name, name, 0L, NULL, 0, NULL);
 }
 else
 {
	 sizehints.flags = PMinSize | PMaxSize;
	 sizehints.min_width = width;
	 sizehints.min_height = height;
	 sizehints.max_width = width;
	 sizehints.max_height = height;
	 XSetStandardProperties(display, window->window, name, name, 0L, NULL, 0, &sizehints);
 }

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Interesting. This is the code in Linux that handles the resize creation flag:

	 if (Window::Resizable & style)
 {
	 XSetStandardProperties(display, window->window, name, name, 0L, NULL, 0, NULL);
 }
 else
 {
	 sizehints.flags = PMinSize | PMaxSize;
	 sizehints.min_width = width;
	 sizehints.min_height = height;
	 sizehints.max_width = width;
	 sizehints.max_height = height;
	 XSetStandardProperties(display, window->window, name, name, 0L, NULL, 0, &sizehints);
 }

 

The XSetStandardProperties function has been superseded by XSetWMProperties.

Link to comment
Share on other sites

The XSetStandardProperties function has been superseded by XSetWMProperties.

 

I think that was pointed out somewhere else before. Or it was another function where X used to do things solo and is now asking the WM for "permission".

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...