Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Queue refresh after drawing (required for wayland) #68

Closed
wants to merge 21 commits into from

Conversation

Mystro256
Copy link
Contributor

I noticed that compiling and running on Wayland (an alternative to XOrg/X11 for BSD and Linux), the screen would never refresh automatically unless the window is resized. Requesting a Refresh() following DrawArea() and DrawOSD() does the trick.

Although with that said, Wayland seems to requires drawing with Cairo, as the GUI will segfault without it, so I've wrapped this in #ifndef NO_CAIRO to avoid any unintended issues with other systems.

Side note, I noticed a comment in CairoDrawingPanel::DrawArea() about drawing with cairo being very slow for WXMSW. Perhaps this is also fixes that issue, which could be required for cairo to work correctly, but I'm not sure.

Mystro256 and others added 6 commits January 30, 2017 00:57
The last commit removed generator expressions from ADD_COMPILE_OPTIONS()
which made C/C++ flags apply to nasm as well.

Fix this by removing <FLAGS> from CMAKE_ASM_NASM_COMPILE_OBJECT and
replacing it with the flags we want.
cmake automatically passes -std=gnu++11 in some cases, while we were
passing -std=c++11, and this was causing incompatibilites in name
mangling between different objects.

Fix this by using -std=gnu++11 for gcc.
As suggested by @Mystro256, try:

wxDynamicLibrary::CanonicalizeName(wxT("openal"))+wxT(".1")

before just the canonical name for "openal" when trying to load the
library.

Also add a utility method to quietly try loading the library, because on
wx 2.8 wxDL_QUIET does not work.
Apparently in some configurations, holding a key on the keyboard makes
Wx stop processing Idle events, so the emulator does not run until the
key is released, freezing the game and ignoring the key.

Hopefully fix this by calling wxWakeUpIdle() from OnKeyDown() and
OnKeyUp().

Other Misc. Improvements:

- refactor process_key_press() to only return true if the system is in a
  pressed key state on key presses or a game key was released on
  releases and always true on double releases.

- call ev.StopPropagation() from OnKey* events for game keys, this may
  not actually do anything, but just in case.

- remove static OnKeyUp and OnKeyDown events from GameArea, these are
  connected to the DrawingPanel dynamically now.

- remove the dynamic_cast<>s from PaintEv/EraseBackground/OnSize event
  forwarders, since there is already a panel member to use.

TODO:

The state returned by process_key_press() is still not entirely correct,
if a joystick button is pressed, it will return true for a non-game
keyboard press, and it needs to return the correct state for double
releases.
XCode 4.2 generates a broken binary if -fomit-frame-pointer and/or -flto
is used for compile and link flags.

Check for Clang version less than 4.3 on APPLE and remove these flags in
the compile options setting cmake code.
@rkitover
Copy link
Collaborator

rkitover commented Feb 4, 2017

@Mystro256 @doctorwho11

So according to the docs here:

http://docs.wxwidgets.org/2.8/wx_wxwindow.html#wxwindowrefresh

this queues a repaint event for the window, so what your change does is, in effect, make a loop that sends another paint event after every paint event. This may be OK if we can't find a more elegant solution.

What we would ideally like to do is check in OnIdle() if the emulator system has a frame ready to be drawn that is different from the previous frame, and only then send a Refresh() to the panel.

@Mystro256
Copy link
Contributor Author

I agree; this should work as an interim solution, but doing a check in OnIdle() seems like the more sane solution.

rkitover and others added 15 commits February 9, 2017 07:30
Call GameArea::Pause and ::Resume in MainFrame::OnActivate based on
focus state if the pauseWhenInactive config option is set.

Also stop/play the primary dsound buffer in pause()/resume() in
dsound.cpp, not onlyu the secondary, this may not be necessary but it
doesn't hurt.
Use an explicit list of Wx XRC sources instead of a GLOB so that cmake
generators for other build systems such as Ninja work.
Add -std=gnu+11 to CMAKE_CXX_COMPILE_OBJECT in the main CMakeLists.txt
to force the option for all C++ sources.

The right way to do this is to use a generator expression with
ADD_COMPILE_OPTIONS, but this is only available in cmake 3.3 and we must
maintain 2.8.12 compatibility to support Ubuntu 14.

This fixes the mac build (clang.)
Also quote LOCALEDIR with as \\\""${LOCALEDIR}"\\\", just like the other
defs are quoted.

This fixes the build on msys2.
Move the check for dependencies/msvc into the previous IF(WIN32) block
adding an IF(MSVC) level.

Remove duplicate call to INCLUDE_DIRECTORIES(dependencies/msvc) from
later on in the main CMakeLists.txt.
Add a hack to the root CMakeLists.txt to SET(MSYS ON) for the Ninja
generator when running under msys2, otherwise it cannot find libs.

The quoting fixes from visualboyadvance-m#70 allow all of this to work.
@Mystro256
Copy link
Contributor Author

Hold on, I'm going to recreate this pull request on a branch...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants