Skip to content

Commit

Permalink
Fixed idle event triggering (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
Unthrottled authored Feb 23, 2021
1 parent 49ae67f commit 32cf3d5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

# AMII Changelog

## [0.7.2]

### Fixed

- The issue with the idle notifications not coming up even after not clicking/typing in the project.

## [0.7.1]

### Added
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

pluginGroup = io.unthrottled
pluginName_ = Anime Memes
pluginVersion = 0.7.1
pluginVersion = 0.7.2
pluginSinceBuild = 202.6397.94
pluginUntilBuild = 211.*
# Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import java.awt.AWTEvent
import java.awt.Toolkit
import java.awt.event.AWTEventListener
import java.awt.event.InputEvent
import java.awt.event.MouseEvent
import java.util.concurrent.TimeUnit

class IdleEventListener(private val project: Project) : Runnable, Disposable, AWTEventListener {
Expand Down Expand Up @@ -49,7 +50,6 @@ class IdleEventListener(private val project: Project) : Runnable, Disposable, AW
Toolkit.getDefaultToolkit().addAWTEventListener(
this,
AWTEvent.MOUSE_EVENT_MASK or
AWTEvent.MOUSE_MOTION_EVENT_MASK or
AWTEvent.KEY_EVENT_MASK
)
idleAlarm.addRequest(this, idleTimeout)
Expand Down Expand Up @@ -81,10 +81,17 @@ class IdleEventListener(private val project: Project) : Runnable, Disposable, AW
idleAlarm.addRequest(this, idleTimeout)
}

private val allowedMouseEvents = setOf(
MouseEvent.MOUSE_PRESSED,
MouseEvent.MOUSE_CLICKED,

)
override fun eventDispatched(e: AWTEvent) {
if (e !is InputEvent || !UIUtil.isDescendingFrom(e.component, rootPane)) return

idleAlarm.cancelAllRequests()
if (e is MouseEvent && allowedMouseEvents.contains(e.id).not()) return

idleAlarm.cancelRequest(this)
idleAlarm.addRequest(this, idleTimeout)
}
}

0 comments on commit 32cf3d5

Please sign in to comment.