Skip to content

Commit

Permalink
[EXPERIMENTAL] Display: Rework setCurrent() logic.
Browse files Browse the repository at this point in the history
Not all of this has to be serialized, and saving the previous
displayable temporarily shouldn't be needed either, however,
problematic jars such as Harry Potter: Find Scabbers,  Racing
Fever 2 and SpongeBob Movie all seem to like this setup better,
and there are no regressions that i could find yet.
  • Loading branch information
AShiningRay committed Feb 21, 2025
1 parent e1103f8 commit cf2fee7
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/javax/microedition/lcdui/Display.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ public int getColor(int colorSpecifier)

public void setCurrent(Displayable next)
{
Displayable prev;
if (next == null) { return; }

try
Expand All @@ -165,16 +166,21 @@ public void setCurrent(Displayable next)
isSettingCurrent = true;
try
{
if (current != null) { callSerially(() -> { current.hideNotify(); }); }
prev = current;
if(next instanceof Alert) { ((Alert) next).setNextScreen(current); }
current = next;
if (prev != null) { callSerially(() -> { prev.hideNotify(); }); }
Mobile.getPlatform().keyState = 0; // reset keystate
callSerially(() -> { next.showNotify(); });
callSerially(() ->
{
current.showNotify();
current.notifySetCurrent();
Mobile.getPlatform().flushGraphics(current.platformImage, 0,0, current.width, current.height);
Mobile.log(Mobile.LOG_DEBUG, Display.class.getPackage().getName() + "." + Display.class.getSimpleName() + ": " + "Set Current "+current.width+", "+current.height);
});

}
finally { isSettingCurrent = false; }
if(next instanceof Alert) { ((Alert) next).setNextScreen(current); }
current = next;
current.notifySetCurrent();
Mobile.getPlatform().flushGraphics(current.platformImage, 0,0, current.width, current.height);
Mobile.log(Mobile.LOG_DEBUG, Display.class.getPackage().getName() + "." + Display.class.getSimpleName() + ": " + "Set Current "+current.width+", "+current.height);
}
catch (Exception e)
{
Expand Down

0 comments on commit cf2fee7

Please sign in to comment.