summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Cohen <benjamin.cohen@intel.com>2011-05-12 13:16:28 +0300
committerBenjamin Cohen <benjamin.cohen@intel.com>2011-05-12 13:16:28 +0300
commit67b230125051750e63c07a2c9910f9daa0295703 (patch)
tree5008c1bc53b917e344bf93f5b70f31ed570edb8d
parentf6bb651a8c975535a2ad2830763e29323ff3a78f (diff)
Prevent window in only one desktop for being removed (and "lost")
-rw-r--r--winii.ahk34
1 files changed, 23 insertions, 11 deletions
diff --git a/winii.ahk b/winii.ahk
index 5af1273..38e82a0 100644
--- a/winii.ahk
+++ b/winii.ahk
@@ -86,11 +86,14 @@ SendToDesktop(windowID, newDesktop, remove)
windows%newDesktop%%i% := windowID
+ if ! (windowTagsCount%windowID% > 0)
+ windowTagsCount%windowID% := 1
+
+ windowTagsCount%windowID% += 1
if (remove)
{
RemoveWindowID(curDesktop, windowID)
- Send, {ALT DOWN}{TAB}{ALT UP} ; activate the right window
}
}
@@ -135,7 +138,6 @@ RemoveCurrentWindow()
WinGet, id, ID, A
RemoveWindowID(curDesktop, id)
- Send, {ALT DOWN}{TAB}{ALT UP}
}
; removes the given window id from the desktop <desktopIdx>
@@ -143,19 +145,29 @@ RemoveWindowID(desktopIdx, ID)
{
global
- removed := 0
- Loop, % windows%desktopIdx%
+ if ! (windowTagsCount%ID% > 0)
+ windowTagsCount%ID% := 1
+
+ if ( windowTagsCount%ID% > 1)
{
- if (windows%desktopIdx%%A_Index% = ID)
+ windowTagsCount%ID% -= 1
+
+ removed := 0
+ Loop, % windows%desktopIdx%
{
- RemoveWindowID_byIndex(desktopIdx, A_Index)
- WinHide ahk_id %ID%
- removed := 1
- Break
+ if (windows%desktopIdx%%A_Index% = ID)
+ {
+ RemoveWindowID_byIndex(desktopIdx, A_Index)
+ WinHide ahk_id %ID%
+ removed := 1
+ Break
+ }
}
+ if (removed = 0)
+ WinHide ahk_id %ID%
+
+ Send, {ALT DOWN}{TAB}{ALT UP} ; activate the right window
}
- if (removed = 0)
- WinHide ahk_id %ID%
}
; this removes the window id at index <ID_idx> from desktop number <desktopIdx>