Screen restoration after ALT+TAB

Hi,
I'm writting an application with 2D graphics in the full-screen mode. If I press ALT+TAB to switch to another window and then another ALT+TAB to go back to my application, I can see only a white screen. I have no idea what is wrong. Here is my code.
GraphicsDevice graphicsDevice = GraphicsEnvironment
          .getLocalGraphicsEnvironment().getDefaultScreenDevice();
JFrame screen = new JFrame();
screen.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
screen.setIgnoreRepaint(true);
screen.setUndecorated(true);
screen.setResizable(false);
graphicsDevice.setFullScreenWindow(screen);
graphicsDevice.setDisplayMode(new DisplayMode(
          800, 600, 16, DisplayMode.REFRESH_RATE_UNKNOWN));
screen.createBufferStrategy(2);
BufferStrategy bufferStrategy = screen.getBufferStrategy();
while (!done) {
     if (bufferStrategy.contentsLost() && !bufferStrategy.contentsRestored()) {
          System.out.println("skip");
          continue;
     System.out.println("draw");
     Graphics graphics = bufferStrategy.getDrawGraphics();
     try {
          //render the screen
     } finally {
          graphics.dispose();
     bufferStrategy.show();
}After the second ALT+TAB bufferStrategy.contentsLost() is always true and bufferStrategy.contentsRestored() is always false. (i.e. I get only the "skip" debug message so the rendering commands are executed no more.)
Thanks for any help.

Hi,
Why do you have the whole '!bufferStrategy.contentsRestored()' part in 'if (bufferStrategy.contentsLost() && !bufferStrategy.contentsRestored())' at all? Wouldn't your code work without it and the screen would paint? I can't see why you would skip the paint if contentsRestored() is false.
Anyway, I use a VolatileImage to do the same thing as a BufferStrategy and it works in full screen mode or normal window mode. This is the code and it sits in a Canvas class:
     int currentWidth = 0;
     int currentHeight = 0;
     Graphics2D g2D = null;
    VolatileImage vImg = null;
    boolean hasBeenResized = false;
     public void reDisplay(Scenario scenario){
          if (hasBeenResized || vImg == null){
               System.out.println("hasBeenResized == true");
               currentWidth = getWidth();
               currentHeight = getHeight();
               vImg = createVolatileImage(currentWidth, currentHeight);
               hasBeenResized = false;
          g2D = (Graphics2D)getGraphics();
          do {
               renderOffscreen(scenario);
               int returnCode = vImg.validate(getGraphicsConfiguration());
               if (returnCode == VolatileImage.IMAGE_RESTORED) {
                    // Contents need to be restored
                    renderOffscreen(scenario);      // restore contents
               else if (returnCode == VolatileImage.IMAGE_INCOMPATIBLE) {
                    // old vImg doesn't work with new GraphicsConfig; re-create it
                    vImg = createVolatileImage(getWidth(), getHeight());
                    renderOffscreen(scenario);
               g2D.drawImage(vImg,0,0,this);
          } while (vImg.contentsLost());
          g2D.dispose();
     void renderOffscreen(Scenario scenario){
          do {
               if (vImg.validate(getGraphicsConfiguration()) == VolatileImage.IMAGE_INCOMPATIBLE){
                    // old vImg doesn't work with new GraphicsConfig; re-create it
                    vImg = createVolatileImage(currentWidth, currentHeight);
               Graphics2D g2D = vImg.createGraphics();
               render(scenario, g2D);
               g2D.dispose();
          } while (vImg.contentsLost());
     void render(Scenario scenario, Graphics2D g2D){
          // painting code here
     }I hope it helps,
Keith

Similar Messages

  • Can't go back to a full-screen game after alt-tab switch

    Hi,
    A small problem suddenly appears.
    I always could switch to desktop from games with Alt-Tab and go back in-game by clicking on the icons in the taskbar.
    But since the last update, this make the game crash and I have to kill the process with powershell to relauch it.
    Anyone have an idea of what's going wrong ?

    I'm also having this problem for full screen games. Hope they fix this soon, it's very aggravating.

  • Windows 7 Blue Screen Issues With Alt-tabbing From WoW

    As the title says, lately I've been having blue screens which are mostly caused by wow.
    Previously I've had the occasional bsod (once a month or so) when alt tabbing, but it was pretty rare. However recently, I've had something more like 1 a day, usually caused by alt tabbing out of wow. It seems the longer I'm alt tabbed the more likely it
    is to happen. I haven't experienced the same problem with any other game, although the occasional monthly ones usually happen when I'm changing my music as I alt tab out of League of Legends.
    I downloaded bluescreenview and it appears the cause is some combination of win32k.sys as well as ntoskrnl.exe             Based off the fact that it is happening more with a more demanding game, I'm guessing the problem is
    most likely due to a bad stick of ram, but I'd like a second opinion.
    I'll attach a few of the most recent dump files (the one today is slightly different than the ones last week which seems slightly odd).
    http://puu.sh/8lVuH     http://puu.sh/8lVtT      http://puu.sh/8lVse
    Thanks in advance for any help, and I hope image files are okay :)

    Thanks, and it's not, no. You can't exactly debug pictures :')
    We have two consistent bug checks:
    SYSTEM_SERVICE_EXCEPTION (3b)
    This indicates that an exception happened while executing a routine that transitions from non-privileged code to privileged code.
    This error has been linked to excessive paged pool usage and may occur due to user-mode graphics drivers crossing over and passing bad data to the kernel code.
    BugCheck 3B, {c0000005, fffff80002e5301e, fffff88008945c70, 0}
    0: kd> ln fffff80002e5301e
    (fffff800`02e52ff8) nt!ExEnterCriticalRegionAndAcquireFastMutexUnsafe+0x26 | (fffff800`02e53040) nt!PsIsProtectedProcess
    ^^ The exception occurred in nt!ExEnterCriticalRegionAndAcquireFastMutexUnsafe. This is a routine that first enters a critical region, and then acquires the specified fast mutex for the calling thread.
    PAGE_FAULT_IN_NONPAGED_AREA (50)
    This indicates that invalid system memory has been referenced.
    Bug check 0x50 usually occurs after the installation of faulty hardware or in the event of failure of installed hardware (usually related to defective RAM, be it main memory, L2 RAM cache, or video RAM).
    Another common cause is the installation of a faulty system service.
    Antivirus software can also trigger this error, as can a corrupted NTFS volume.
    BugCheck 50, {fffff900c25efcf0, 0, fffff9600032c69d, 0}
    ^^ Address fffff900c25efcf0 was written to by the instruction at address
    fffff9600032c69d.
    1: kd> r cr2
    Last set context:
    cr2=fffff900c25efcf0
    ^^ The 1st parameter address was stored in cr2 prior to calling the page fault handler.
    1: kd> !pte fffff900c25efcf0
    VA fffff900c25efcf0
    PXE at FFFFF6FB7DBEDF90 PPE at FFFFF6FB7DBF2018 PDE at FFFFF6FB7E403090 PTE at FFFFF6FC80612F78
    Unable to get PXE FFFFF6FB7DBEDF90
    ^^ Can't see whether or not it's valid/non-valid.
    1: kd> .trap fffff880`073858e0
    NOTE: The trap frame does not contain all registers.
    Some register values may be zeroed or incorrect.
    rax=0000000000000011 rbx=0000000000000000 rcx=fffff900c376ae40
    rdx=00000000701215e6 rsi=0000000000000000 rdi=0000000000000000
    rip=fffff9600032c69d rsp=fffff88007385a70 rbp=0000000000000001
    r8=0000000000000000 r9=0000000000000410 r10=fffff80002e4e000
    r11=0000000000000022 r12=0000000000000000 r13=0000000000000000
    r14=0000000000000000 r15=0000000000000000
    iopl=0 nv up ei pl zr na po nc
    win32k!SFMLOGICALSURFACE::OwnsSurfaceCleanup+0x2d:
    fffff960`0032c69d 488b4f20 mov rcx,qword ptr [rdi+20h] ds:00000000`00000020=??????????
    ^^ On the instruction we failed on, address fffff960`0032c69d deferenced
    rdi+20h where rdi is 0000000000000000. All of this would result in a memory write to the address
    00000000`00000020.
    1: kd> dd 00000000`00000020
    00000000`00000020 ???????? ???????? ???????? ????????
    00000000`00000030 ???????? ???????? ???????? ????????
    00000000`00000040 ???????? ???????? ???????? ????????
    00000000`00000050 ???????? ???????? ???????? ????????
    00000000`00000060 ???????? ???????? ???????? ????????
    00000000`00000070 ???????? ???????? ???????? ????????
    00000000`00000080 ???????? ???????? ???????? ????????
    00000000`00000090 ???????? ???????? ???????? ????????
    Right, so the code wanted to write to 00000000`00000020 which as we can see above is a completely invalid address. The 1st parameter and cr2 however note we failed writing to address
    fffff900c25efcf0. This does not make sense, and is essentially not logically possible.
    The hardware was told to write to 00000000`00000020, and the hardware came back and said 'I cannot write to
    fffff900c25efcf0'. Another way to think about it is if you kindly asked the waiter of your table for more water, he writes it down, but comes back and says 'I'm sorry, but we're all out of coffee'.
    1. Uninstall any/all installed Asus bloatware, I for example see Asus PC Probe, and AI Suite.
    2. Remove and replace avast! with Microsoft Security Essentials for temporary troubleshooting purposes as it may be causing conflicts:
    avast! removal -
    http://www.avast.com/uninstall-utility
    MSE - 
    http://windows.microsoft.com/en-us/windows/security-essentials-download
    3. If the above fails, you have faulty RAM.
    Regards,
    Patrick
    “Be kind whenever possible. It is always possible.” - Dalai Lama

  • MSI GX60 crasht after alt+tab into game 0xa0000001

    Today i switched windows from a Google chrome to world of tanks and my msi crashed with the error code 0xa0000001
    What does this code mean and how can i fix it, does anyone know, i really appreciate the support :)

    I googled where to find the log file, i got this log file from event viewer I think this is what you mean
    - System
      - Provider
       [ Name]  Microsoft-Windows-Kernel-Power
       [ Guid]  {331C3B3A-2005-44C2-AC5E-77220C37D6B4}
       EventID 41
       Version 3
       Level 1
       Task 63
       Opcode 0
       Keywords 0x8000000000000002
      - TimeCreated
       [ SystemTime]  2014-08-01T19:16:51.119043700Z
       EventRecordID 56795
       Correlation
      - Execution
       [ ProcessID]  4
       [ ThreadID]  8
       Channel System
       Computer Luke
      - Security
       [ UserID]  S-1-5-18
    - EventData
      BugcheckCode 2684354561
      BugcheckParameter1 0x5
      BugcheckParameter2 0x0
      BugcheckParameter3 0x0
      BugcheckParameter4 0x0
      SleepInProgress 0
      PowerButtonTimestamp 0
      BootAppStatus 0
    in the general tab it says:
    Het systeem is opnieuw opgestart zonder eerst correct te zijn afgesloten. Deze fout is mogelijk veroorzaakt doordat het systeem niet meer reageert of is vastgelopen of doordat de stroom is uitgevallen.
    translated to:
    The system has rebooted without first being properly shutdown. This error may be caused by the system not responding or is jammed or because the power is out.

  • When alt + tab between applications firefox freezes to a black blank screen and will not move. The only response it will allow is the close option after right clicking on the task bar in English

    I normally have several applications running at the same time, some of them are running 24/7/365.
    When accessing the applications its easier to alt+tab between them. On the occasions that I can actually get Firefox to open and stay open it always freezes and remains immovable on the screen after switching to another program.
    Firefox goes black except for the border and the close button at the top right. The other buttons disappear. Even after waiting for a period of time it does not clear.
    The freeze can occur either on the first switch or second switch. However, it always happens.

    Have also since found out that to start FF4 in safe mode you just hold shift whilst double-clicking the icon. We only find these things out after the event, murphy's law!

  • App is activated just after it is hidden with Alt+tab

    Hi
    I have following problem under Mac
    My application changes screen resolution to the size of
    application on the
    startup
    And when the user wants to jump to another application
    without closing
    director app(through ALT+TAB), I should restore original
    screen resolution.
    Under Windows I've realised it using on activateWindow and on
    deactivateWindow handlers
    on deactivateWindow
    gResolutionXtra.reset_resolution()
    end
    on activateWindow
    gResolutionXtra.set_resolution(1024,768,32)
    end
    But on MAC it works very strange
    Just after application window disappears(after pressing
    ALT+TAB), it appears
    again; using put-functions I see, that activateWindow handler
    is called. The
    reason of this is reset_resolution function, which is called
    in on
    deactivateWindow function. When it is commented - window
    disappears and is
    activated just on next ALT+TAB or click on application Icon
    on taskbar -
    directly as I need it and as it works under windows
    Does any one have some workaround, how can I restore the
    resolution on
    changing to another application but without activating the
    window again?
    Any help will be appreciated
    game_dev
    P.S. Sorry for Windows terminology for mac problem, but I'm
    realy new to MAC

    If I do not use reset_resolution function everything works
    fine
    But at the moment I want to resen resolution in on
    deactivateWindow
    handler - this strange thing happens - onactivateWindow is
    called
    authomatically
    How can i prevent it?
    any help will be appreciated
    game_dev
    "McFazstp" <[email protected]> wrote in
    message
    news:g0l0tu$34n$[email protected]..
    >I just tried this ( not the resolution thing, just the
    focus ).
    >
    > When I deactivate using ALT-TAB it seems to call
    >
    > deactivateWindow - deactivateWindow
    >
    > when reactivated it calls
    >
    > activateWindow
    >
    >
    > However the window does disappear. Do you have
    animateInBackground set?
    > Maybe
    > the deactivateWindow handler returns focus to the
    window.
    >
    > Is it running in a window or full-screen? If full-screen
    you could try
    > running
    > in a window and using baHideTaskBar( 2 ) to make it look
    full-screen.
    >
    >

  • Firefox freezes the computer for about 20-30 seconds (not even Alt+Tab works), the screen blinks black and then it shows the desired page. Does that several times at the beginning, then sort of stabilizes.

    Firefox freezes the computer for about 20-30 seconds (not even Alt+Tab works), the screen blinks black and then it shows the desired page. Does that several times at the beginning, then sort of stabilizes.
    This happens even if I simply hover the mouse over bookmarks, not even opening a page.
    And waiting for this to happen some times or closing and re-opening seems to make it work ok again.
    I've already disabled almost all add-ons (I'm using only one for Flash and NoScript right now), reinstalled Firefox (8.0.1), restoring only the bookmarks from an older version.

    '''Try the Firefox Safe Mode''' to see how it works there. The Safe Mode is a troubleshooting mode, which disables most add-ons.''
    ''(If you're not using it, switch to the Default theme.)''
    * You can open the Firefox 4.0+ Safe Mode by holding the '''Shift''' key when you use the Firefox desktop or Start menu shortcut.
    * Or use the Help menu item and click on the '''Restart with Add-ons Disabled...''' menu item while Firefox is running.
    ''Don't select anything right now, just use "'Start in Safe Mode"''
    ''To exit the Firefox Safe Mode, just close Firefox and wait a few seconds before using the Firefox shortcut (without the Shift key) to open it again.''
    '''''If it is good in the Firefox Safe Mode''''', your problem is probably caused by an extension, and you need to figure out which one.
    Please follow the [[Troubleshooting extensions and themes]] article for that.
    ''When you figure out what's causing your issues, please let us know. It might help other users who have the same problem.''

  • Alt+Tab broken in full screen mode

    Hi,
    I generally use lightroom in full screen mode where the title and menu bar are both hidden. However, when in this mode I find using Alt+Tab is broken. For example, say I have LR as the foreground application. I press Alt+Tab and switch to another app. Then press Alt+Tab once expecting to get back to LR. But somehow LR has gone to the end of the list and instead I get another application.
    Is anyone else seeing this? I use WinXP+SP2+latest updates.
    Thanks,
    Nick

    There are different types of full-screen mode. If in the other applications, you see the Minimize/Restore/Close buttons in the top right-hand corner, then that is not the full screen mode being used by Lightroom, which you'll notice, does not have those buttons available.
    The other applications are actually maximized, and not in full-screen mode.
    John Gregson

  • JSE 8 very slow after 3 alt-tab's on XP SP2

    Sun Java Studio Enterprise 8 Build 051011_2
    IDE/1 spec=5.9.1 impl=200507031930
    Windows XP 5.1
    Intel Pentium 4 running at 3 GHz with 1.5 GB of ram
    I have been doing a lot JNI work lately and find myself switching via
    Alt-tab between the MS VS 2005.NET object browser and the Java
    class into which I am projecting some COM methods... blah, blah
    Anyway, after I've Alt-tab'd about 3 times, JSE 8 starts slowing down
    incredibly for no apparent reason and the redraw takes longer and
    longer.
    Saving the file I'm editing and forcing a GC improves things for a
    short time.
    Another clue could be that in the files I'm editing, I am often moving
    lines around that contain native method signature declarations.
    Looking at the Task Manager in Windoze shows Java taking up
    ~55% of the CPU during these JSE introspectives.
    Any ideas?
    TIA,
    Mike Fidler

    Ok, I've installed 8.1 and it still happens.
    As I mentioned earlier, I do a lot of JNI work, and I constantly alt-tab between JSE 8.1 and MS VS 2005.
    This morning the JSE was working fine until I started VS 2005 and as soon as I alt-tab'd between the two, the JSE refused to refresh and it is now sitting there unusable with nothing but a window frame; the client area is blank. :-(
    Looking at the Task Manager, java.exe is not using any cpu. At all.
    Minimizing and restoring is not doing anything. I tried to close JSE and restart it, but JSE won't close... it's like the message pump has siezed - except that minimize and restore work.
    AFAIK, no other windows apps other than VS 2005 causes this peculiar behavior in JSE.
    I recently installed SP1 for VS 2005. I can't say for certain, but it seems as though SP1 made the situation worse.
    So, for posterity, here are the product versions I am using:
    Sun JSE 8.1 Build: 2006.12.01
    Java 1.5.0_09
    VM: Hotspot(tm) Client VM 1.5.0_09-b03
    Microsoft Visual Studio 2005 - ENU Service Pack 1 (KB926601)
    Version 8.0.50727.762 (SP.050727-7600)
    Microsoft .NET Framework
    Version 2.0.50727
    Installed Edition: Professional
    Cheers,
    Mike Fidler

  • [Solved] Alt-Tab window switching no longer working after update (JWM)

    The next issue I am trying to straighten out after a recent, long-overdue pacman -Syu, is the loss of window-switching functionality using the alt-tab key combination. This is under the JWM window manager, by the way. The alt key seems to work as expected when, for example, firefox has focus: if I hit alt left arrow, the browser goes back to the preceding page. But if I hit alt and tab together, say, in the browser or when a terminal has focus, it seems to be read as though I were pressing only the tab key. So, with two windows maximized on the desktop, the alt-tab combination does not toggle between them. If the terminal has focus I can see the cursor jumping over a tab space each time I press the key combination.
    Can anyone offers pointers on how I might resolve or begin diagnosing this issue? I should mention that another change I did in the wake of the update was to make the system log me in and start the GUI each time I boot the machine (as discussed at https://wiki.archlinux.org/index.php/St … h_profile). I'm not sure why that would have any effect but I thought I should mention it. I think this is just a pretty standard pc105 keyboard by the way.
    Input will be appreciated.
    Thanks,
    James
    Last edited by jamtat (2013-02-01 17:07:32)

    Thank you for your input, anonymous_user. I decided, on reading it, to compare my .jwmrc with the /etc/system.jwmrc file. I noted that, in my .jwmrc, the keybindings section was empty, while that section in the /etc/system.jwmrc had several entries--and even one that seemed to refer to the alt-tab key combination. So I copied that section into my .jwmrc, restarted JWM, and the key combination now seems to be working as it should. Granted, it's a bit strange in that it doesn't open some kind of dialog box with the names of open windows, showing you in list form the windows you're scrolling through. But it does take you to other open windows when, after you've hit the tab key one or more times, you release the alt key. So the issue is resolved and was pretty simple.
    James

  • I have an iphone 5s and my phone was working perfectly fine then it turn into a blue screen and after that i tried to restore it but when i do the phone does half of the steps and then it turns into a blue screen and it doesnt work again what can i do?

    i have an iphone 5s and my phone was working perfectly fine then it turn into a blue screen and after that i tried to restore it but when i do the phone does half of the steps and then it turns into a blue screen and it doesnt work again what can i do?

    The Basic Troubleshooting Steps are:
    Restart... Reset... Restore from Backup...  Restore as New...
    Malvinfromny wrote:
    ... i tried to restore it but when i do the phone does half of the steps and then it turns into a blue screen and it doesnt work again what can i do?
    If you try all these Steps and you still have issues... Then a Visit to an Apple Store or AASP (Authorized Apple Service Provider) is the Next Step... Be sure to make an appointment first...

  • How can i restore all my tabs of mozilla after profile movement ?

    I am working in call center here users open so many tabs and when we they moved to new system they want to restore all the tabs at new location. So , how i can restore all the tabs after profile movement like i can restore their pst

    You can make a backup copy of the sessionstore.js file that stores session data.
    *http://kb.mozillazine.org/sessionstore.js
    You can use this button to go to the currently used Firefox profile folder:
    *Help > Troubleshooting Information > Profile Directory: Show Folder (Linux: Open Directory; Mac: Show in Finder)

  • Alt tabbing with full screen games in Gnome Shell

    I'm using gnome shell 3.6.2 and whenever I launch a full screen game (like heroes of newerth) I can't alt-tab out of it or change to a different work space. I can do this in XFCE, KDE (with compositing disabled) and unity (have a press it a few times) but I can't do this in gnome shell. Is there a workaround I can use (besides starting it in a different X server).
    EDIT: I tried the package sdl-nokeyboardgrab and the libx11-nokeyboard grab and tried running hon as:
    LD_PRELOAD=libX11-nokeynomouse.so HoN/hon.sh
    but it still doesn't work. When I alt-tab/change workspace it shows the adwaita cursor (instead of the HoN one) and kinda blinks the gnome shell desktop.
    Last edited by Draucia (2012-11-22 13:25:46)

    Hello bferretti...sorry to hear you're having issues with the hot corners.
    I was playing WOW last night and started playing around with the video options. I noticed there are two full screen options now - Fullscreen and Windowed Fullscreen. If in Fullscreen the hot corners are disabled for me. If I use Windowed Fullscreen then the hot corners are still active.
    Not sure if you've taken a look at that...but just thought I'd pass along that info.
    Thanks!

  • What is that screen u get when u press alt+tab?

    just curious..... when I press alt - tab the whole screen dimms and an image of 2 cogs appear.... what's that about?

    Do you mean command+tab? If so, the window that comes up is the application switcher window. Continue holding down command, while pressing tab to switch between applications (release tab when the application that you want to activate is highlighted).
    Option (Alt) + Tab is not a standard OS X shortcut.

  • Firefox crashed and after restarting, tabs i had open were gone and weren't in the history either. Didn't give me the option of restoring, how do i get them ba

    Firefox crashed and after restarting, tabs i had open were gone and weren't in the history either. It didn't give me the option of restoring, how do i get them back?

    Sorry , you probably can not get them back.
    You may have bookmarked them, or have them as part of the History previously stored and still searchable, but unfortunately otherwise you are unlikely to get them back. Firefox does to a certain extent back up bookmarks automatically but not the history.
    If you get problems with crashes see [[firefox crashes]]

Maybe you are looking for