Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mouse handling when moving/resizing windows #13

Merged
merged 6 commits into from
May 26, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 31 additions & 0 deletions WPXA.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,32 @@ wp_WinTraymin(hWnd = "", nFlags = "")
hWnd_%A_Index% ? (DllCall("shell32\Shell_NotifyIcon","Uint",2,"Uint",NumPut(A_Index,NumPut(hAHK,NumPut(VarSetCapacity(ni,152),ni)))-12),DllCall("ShowWindow","Uint",hWnd_%A_Index%,"int",5),hWnd_%A_Index%:="") : ""
}

/*
===============================================================================
Function: wp_RecenterMouse
Move cursor to the center of the active window

Author(s):
Original - artemisart
===============================================================================
*/
wp_RecenterMouse()
{
global RecenterMouse, RecenterOnlyIfOutside

if (RecenterMouse=0)
return

MouseGetPos, , , mID
WinGet, wID, ID
if (RecenterOnlyIfOutside and mID=wID)
return

CoordMode, Mouse, Window
WinGetPos, , , w, h
MouseMove, w / 2, h / 2
}

/*
===============================================================================
Function: WPXA_ClipCursorToMonitor
Expand Down Expand Up @@ -961,6 +987,7 @@ WPXA_MaximizeToggle(winTitle)
WinMaximize

wp_RememberPos(hwnd)
wp_RecenterMouse()
}
}

Expand Down Expand Up @@ -1155,6 +1182,8 @@ WPXA_Move(sideX, sideY, widthFactor, heightFactor, winTitle)
; in order to save the position for next time. May also be used by other apps.
PostMessage, 0x232

wp_RecenterMouse()

SetWinDelay, WinDelay

wp_RememberPos(hwnd)
Expand Down Expand Up @@ -1279,6 +1308,8 @@ WPXA_MoveWindowToMonitor(md, winTitle)

if state = 1
WinMaximize

wp_RecenterMouse()
}

/*
Expand Down
5 changes: 5 additions & 0 deletions WindowPadX.Default.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
[Options]
TitleMatchMode=2

RecenterMouse=0
; when the window is moved
RecenterOnlyIfOutside=0
; recenter only if the mouse is outside the window new position

;
; [Hotkeys]: Hotkeys which are active by default.
; Hotkey sets using standard modifier keys such as
Expand Down
7 changes: 7 additions & 0 deletions WindowPadX.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ WindowPadX_LoadSettings(ininame)
; Misc Options
IniRead, v, %ininame%, Options, TitleMatchMode, %A_TitleMatchMode%
SetTitleMatchMode, %v%
; allow generic options
IniRead, opts, %ininame%, Options
Loop, Parse, opts, `n, `r
{
StringSplit v, A_LoopField, =
%v1% := v2
}

; Hotkeys: Exclude Windows
v := wp_INI_GetList(ininame, "Exclude Windows", "Window")
Expand Down
5 changes: 5 additions & 0 deletions WindowPadX.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
[Options]
TitleMatchMode=2

RecenterMouse=1
; when the window is moved
RecenterOnlyIfOutside=1
; recenter only if the mouse is outside the window new position

;
; [Hotkeys]: Hotkeys which are active by default.
; Hotkey sets using standard modifier keys such as
Expand Down