From: Kevin Lamonte Date: Thu, 22 Aug 2019 13:05:16 +0000 (-0500) Subject: hide mouse for desktop X-Git-Tag: fanfix-swing-0.0.1~12^2~13^2~48 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=9ad2ce4f566e1d811ac0fd205efe8865a77ae1de;p=fanfix-swing.git hide mouse for desktop --- diff --git a/README.md b/README.md index 68b1ab7e..23132523 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,10 @@ The examples/ folder currently contains: manager](/examples/JexerTilingWindowManager.java) in less than 250 lines of code. + * A much slicker [prototype tiling window + manager](/examples/JexerTilingWindowManager2.java) in less than 200 + lines of code. + * A [prototype image thumbnail viewer](/examples/JexerImageViewer.java) in less than 350 lines of code. diff --git a/examples/JexerTilingWindowManager2.java b/examples/JexerTilingWindowManager2.java index e06119b2..db75c835 100644 --- a/examples/JexerTilingWindowManager2.java +++ b/examples/JexerTilingWindowManager2.java @@ -59,7 +59,7 @@ public class JexerTilingWindowManager2 extends TApplication { * Public constructor chooses the ECMA-48 / Xterm backend. */ public JexerTilingWindowManager2() throws Exception { - super(BackendType.SWING); + super(BackendType.XTERM); // The stock tool menu has items for redrawing the screen, opening // images, and (when using the Swing backend) setting the font. @@ -73,16 +73,28 @@ public class JexerTilingWindowManager2 extends TApplication { tileMenu.addItem(MENU_SPLIT_HORIZONTAL, "&Horizontal Split"); tileMenu.addItem(MENU_RESPAWN_ROOT, "&Respawn Root Terminal"); - // Stock commands: a new shell with resizable window, previous, next, - // close, and exit program. - tileMenu.addItem(TMenu.MID_SHELL, "&Floating"); + // Stock commands: a new shell with resizable window, and exit + // program. tileMenu.addSeparator(); - tileMenu.addDefaultItem(TMenu.MID_WINDOW_PREVIOUS); - tileMenu.addDefaultItem(TMenu.MID_WINDOW_NEXT); - tileMenu.addDefaultItem(TMenu.MID_WINDOW_CLOSE); + tileMenu.addItem(TMenu.MID_SHELL, "&New Windowed Terminal"); tileMenu.addSeparator(); tileMenu.addDefaultItem(TMenu.MID_EXIT); + // TTerminalWidget can request the text-block mouse pointer be + // suppressed, but the default TDesktop will ignore it. Let's set a + // new TDesktop to pass that mouse pointer visibility option to + // TApplication. + setDesktop(new TDesktop(this) { + @Override + public boolean hasHiddenMouse() { + TWidget active = getActiveChild(); + if (active instanceof TTerminalWidget) { + return ((TTerminalWidget) active).hasHiddenMouse(); + } + return false; + } + }); + // Spin up the root terminal createRootTerminal(); } diff --git a/src/jexer/TApplication.java b/src/jexer/TApplication.java index affc6ce4..fe90e5d1 100644 --- a/src/jexer/TApplication.java +++ b/src/jexer/TApplication.java @@ -1766,6 +1766,19 @@ public class TApplication implements Runnable { } } + // If this cell is on top of the desktop, and the desktop has + // requested a hidden mouse, bail out. + if ((desktop != null) && (activeWindow == null) && (activeMenu == null)) { + if ((desktop.hasHiddenMouse() == true) + && (x > desktop.getX()) + && (x < desktop.getX() + desktop.getWidth() - 1) + && (y > desktop.getY()) + && (y < desktop.getY() + desktop.getHeight() - 1) + ) { + return; + } + } + Cell cell = getScreen().getCharXY(x, y); if (cell.isImage()) { cell.invertImage();