Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

42
LINES

< > BotCompany Repo | #1026809 // Minimize OS To Tray v2 [with better fullscreen handling, dev.]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 911K of libraries. Click here for Pure Java version (7140L/37K).

1  
!7
2  
3  
cmodule MinimizeToTray > DynPrintLogAndEnabled {
4  
  transient bool activating;
5  
  bool fullScreen;
6  
  
7  
  start {
8  
    checkIfFullScreen();
9  
    JFrame f = getFrame(dm_desktopPane());
10  
    if (f == null) print("No frame found");
11  
    else {
12  
      ownResource(tempOnFrameIconified(f, r {
13  
        if (!activating)
14  
          f.setVisible(false) }));
15  
      ownResource(tempOnWindowStateChanged(f, r checkIfFullScreen));
16  
      print("Minimize to tray installed");
17  
    }
18  
19  
    Runnable rShow = r {
20  
      activating = true;
21  
      try {
22  
        activateFrame(dm_desktopPane(), windowsHack := false, maximize := fullScreen);
23  
      } finally {
24  
        activating = false;
25  
      }
26  
    };
27  
    S name = dm_osName();
28  
    dm_systemTrayIcon(dm_osIconID(), name, rShow, "Show " + name, rShow);
29  
  }
30  
31  
  void checkIfFullScreen {
32  
    JFrame f = getFrame(dm_desktopPane());
33  
    if (f == null) ret;
34  
    int state = f.getState();
35  
    if (state == JFrame.MAXIMIZED_BOTH)
36  
      setField(fullScreen := true);
37  
    else if (state == JFrame.NORMAL)
38  
      setField(fullScreen := false);
39  
  }
40  
  
41  
  bool warnOnDelete() { true; }
42  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1026809
Snippet name: Minimize OS To Tray v2 [with better fullscreen handling, dev.]
Eternal ID of this version: #1026809/4
Text MD5: eb33995f830e69301c0484bd2f560ce0
Transpilation MD5: 859af3a07f5741f92181f8d0c5559c9b
Author: stefan
Category:
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-01-23 19:44:40
Source code size: 1119 bytes / 42 lines
Pitched / IR pitched: No / No
Views / Downloads: 137 / 12365
Version history: 3 change(s)
Referenced in: [show references]