Closed d10sfan closed 4 years ago
recommended way to log
#include <Tempest/Log> // functions: Log::i - info Log::d - debug Log::e - error // usage example Log::d("x = ", npc->position().x," y = ",npc->position().y);
Could there be an issue with my implementation of looking for the full screen flag?
Normally it not suppose to work like that. The idea is:
implCreateWindow(Tempest::Window*,SystemApi::ShowMode)
- creates a windows with default size, and specified show-mode.
Possible usage - implCreateWindow(nullptr,SystemApi::Maximized)
implCreateWindow(Tempest::Window *owner, uint32_t w, uint32_t h)
- creates a window with specified size and ShowMode = Normal.
Workflow for opengothic:
if(!gothic.isWindowMode())
setFullscreen(true);
When is this function usually called?
There is only one place:
void MainWindow::mouseMoveEvent(MouseEvent &event) {
const bool fs = SystemApi::isFullscreen(hwnd());
if(fs) {
if(auto camera = gothic.gameCamera())
spin = camera->getSpin();
processMouse(event,true);
mpos = Point(w()/2,h()/2);
SystemApi::setCursorPosition(mpos.x,mpos.y);
}
}
Idea is similar to behavior of original game: read mouse position change in mouseMoveEvent
and then return cursor to center of game window.
I've pushed some improvements to this:
Remaining issues:
if(!gothic.isWindowMode()) setFullscreen(true);
), is there possibly a piece missing for that to work? I tried without the explicit call to set it fullscreen in the implCreateWindow function, but then it is only in maximized mode, instead of fullscreen. If I understand it correctly, that setFullScreen is supposed to be called if the windowed flag isn't passed in.Other than that, the graphics side of things seem to be working ok from a quick glance.
I've tried to setup window creation on VirtualMachine: have a similar result: for simple X11 app XChangeProperty doesn't take any effect on already created window, meanwhile XSenEvent works:
bool X11Api::implSetAsFullscreen(SystemApi::Window *w, bool fullScreen) {
XEvent e = {};
e.xclient.type = ClientMessage;
e.xclient.window = HWND(w);
e.xclient.message_type = _NET_WM_STATE();
e.xclient.format = 32;
e.xclient.data.l[0] = 2; // _NET_WM_STATE_TOGGLE
e.xclient.data.l[1] = _NET_WM_STATE_FULLSCREEN();
e.xclient.data.l[2] = 0; // no second property to toggle
e.xclient.data.l[3] = 1;
XSendEvent(dpy, DefaultRootWindow(dpy), False, SubstructureRedirectMask | SubstructureNotifyMask, &e);
return true;
}
Unfortunately, still can't figure-out what is wrong about XChangeProperty
Thanks, I tried XSendEvent and that seemed to work, as the extra call for setFullScreen was no longer needed. I went ahead and pushed that change up.
I updated implSetCursorPosition to use the root window instead of the windows->first. I tried doing the same to implShowCursor but that resulted in the cursor still being visible.
Hi, @d10sfan !
Your PR look good to me, since it still marked as WIP, just want to ask: Are you ok to merge now, and create a followup tickets for known linux issues:
Yeah I think this one is good to merge. I'll see what I can find out above the left and right issue. I believe it may have been introduced in a recent game update. I'll try to narrow it down which commit may have done it, or if it's something in my code.
I created a ticket for the mouse movement issue (https://github.com/Try/MoltenTempest/issues/12). Figured you could assign that to me if you want and I'll research into it what could be happening.
This is a work in progress implementation for a few of the missing X11 graphics features, mainly full screen and cursor support.
The X11 fullscreen and isFullScreen should now work, along with the cursor hiding.
I had some questions regarding the rest: