mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
RDCT-1149 '+' are disapearing on hover
Make sure focus events are dispatched, and painting is done with controller's client id in RD setup. Focus events are explicitly dispatched with controller's client id, as it doesn't seem possible to propagate client id via 'requestFocus' requests and such without introducing a dedicated JBR API. As for the painting events, we just make them covered with the existing logic of client id propagation for InvocationEvent-s. GitOrigin-RevId: 52d59e0ffef69dfa4dff7618a8e50551b2a26549
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c0b6cfbfc5
commit
9d8567a5b1
@@ -33,7 +33,7 @@ open class ClientSessionsManager<T : ClientSession> {
|
||||
*/
|
||||
@JvmStatic
|
||||
fun getAppSessions(kind: ClientKind): List<ClientAppSession> {
|
||||
return ApplicationManager.getApplication().service<ClientSessionsManager<ClientAppSession>>().getSessions(kind)
|
||||
return ApplicationManager.getApplication()?.service<ClientSessionsManager<ClientAppSession>>()?.getSessions(kind) ?: emptyList()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.util.ui
|
||||
|
||||
import com.intellij.codeWithMe.ClientId
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.application.EDT
|
||||
@@ -24,7 +25,7 @@ abstract class Animator @JvmOverloads constructor(private val name: @NonNls Stri
|
||||
private var startTime: Long = 0
|
||||
private var startDeltaTime: Long = 0
|
||||
private var initialStep = false
|
||||
private val coroutineScope = coroutineScope ?: CoroutineScope(SupervisorJob() + Dispatchers.Default)
|
||||
private val coroutineScope = coroutineScope ?: CoroutineScope(SupervisorJob() + Dispatchers.Default + ClientId.coroutineContext())
|
||||
|
||||
@Obsolete
|
||||
fun isForward(): Boolean = isForward
|
||||
|
||||
@@ -346,43 +346,45 @@ class IdeEventQueue private constructor() : EventQueue() {
|
||||
val runnable = InvocationUtil.extractRunnable(event)
|
||||
val runnableClass = runnable?.javaClass ?: Runnable::class.java
|
||||
val processEventRunnable = Runnable {
|
||||
val progressManager = ProgressManager.getInstanceOrNull()
|
||||
try {
|
||||
runCustomProcessors(finalEvent, preProcessors)
|
||||
performActivity(finalEvent) {
|
||||
if (progressManager == null) {
|
||||
_dispatchEvent(finalEvent)
|
||||
}
|
||||
else {
|
||||
progressManager.computePrioritized(ThrowableComputable {
|
||||
withAttachedClientId(event).use {
|
||||
val progressManager = ProgressManager.getInstanceOrNull()
|
||||
try {
|
||||
runCustomProcessors(finalEvent, preProcessors)
|
||||
performActivity(finalEvent) {
|
||||
if (progressManager == null) {
|
||||
_dispatchEvent(finalEvent)
|
||||
null
|
||||
})
|
||||
}
|
||||
else {
|
||||
progressManager.computePrioritized(ThrowableComputable {
|
||||
_dispatchEvent(finalEvent)
|
||||
null
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (t: Throwable) {
|
||||
processException(t)
|
||||
}
|
||||
finally {
|
||||
isInInputEvent = wasInputEvent
|
||||
trueCurrentEvent = oldEvent
|
||||
if (currentSequencedEvent === finalEvent) {
|
||||
currentSequencedEvent = null
|
||||
catch (t: Throwable) {
|
||||
processException(t)
|
||||
}
|
||||
runCustomProcessors(finalEvent, postProcessors)
|
||||
if (finalEvent is KeyEvent) {
|
||||
maybeReady()
|
||||
finally {
|
||||
isInInputEvent = wasInputEvent
|
||||
trueCurrentEvent = oldEvent
|
||||
if (currentSequencedEvent === finalEvent) {
|
||||
currentSequencedEvent = null
|
||||
}
|
||||
runCustomProcessors(finalEvent, postProcessors)
|
||||
if (finalEvent is KeyEvent) {
|
||||
maybeReady()
|
||||
}
|
||||
if (eventWatcher != null && runnable != null && !InvocationUtil.isFlushNow(runnable)) {
|
||||
eventWatcher.logTimeMillis(if (runnableClass == Runnable::class.java) finalEvent.toString() else runnableClass.name,
|
||||
startedAt,
|
||||
runnableClass)
|
||||
}
|
||||
}
|
||||
if (eventWatcher != null && runnable != null && !InvocationUtil.isFlushNow(runnable)) {
|
||||
eventWatcher.logTimeMillis(if (runnableClass == Runnable::class.java) finalEvent.toString() else runnableClass.name,
|
||||
startedAt,
|
||||
runnableClass)
|
||||
if (isFocusEvent(finalEvent)) {
|
||||
onFocusEvent(finalEvent)
|
||||
}
|
||||
}
|
||||
if (isFocusEvent(finalEvent)) {
|
||||
onFocusEvent(finalEvent)
|
||||
}
|
||||
}
|
||||
|
||||
if (runnableClass == InvocationUtil.REPAINT_PROCESSING_CLASS) {
|
||||
@@ -390,13 +392,11 @@ class IdeEventQueue private constructor() : EventQueue() {
|
||||
return
|
||||
}
|
||||
|
||||
withAttachedClientId(event).use {
|
||||
if (defaultEventWithWrite) {
|
||||
ApplicationManagerEx.getApplicationEx().runIntendedWriteActionOnCurrentThread(processEventRunnable)
|
||||
}
|
||||
else {
|
||||
processEventRunnable.run()
|
||||
}
|
||||
if (defaultEventWithWrite) {
|
||||
ApplicationManagerEx.getApplicationEx().runIntendedWriteActionOnCurrentThread(processEventRunnable)
|
||||
}
|
||||
else {
|
||||
processEventRunnable.run()
|
||||
}
|
||||
}
|
||||
finally {
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.ide
|
||||
|
||||
import com.intellij.codeWithMe.ClientId.Companion.withClientId
|
||||
import com.intellij.ide.ui.ShowingContainer
|
||||
import com.intellij.openapi.application.AccessToken
|
||||
import com.intellij.openapi.client.ClientKind
|
||||
import com.intellij.openapi.client.ClientSessionsManager
|
||||
import com.intellij.openapi.diagnostic.logger
|
||||
import java.awt.*
|
||||
import java.awt.event.FocusEvent
|
||||
import java.awt.event.HierarchyEvent
|
||||
import java.awt.event.HierarchyEvent.DISPLAYABILITY_CHANGED
|
||||
import java.awt.event.HierarchyEvent.SHOWING_CHANGED
|
||||
import java.awt.event.WindowEvent
|
||||
import java.lang.invoke.MethodHandles
|
||||
import java.lang.invoke.MethodType
|
||||
import javax.swing.DefaultFocusManager
|
||||
@@ -34,16 +40,30 @@ internal class IdeKeyboardFocusManager : DefaultFocusManager() /* see javadoc ab
|
||||
e.component.dispatchEvent(patchedEvent)
|
||||
return true
|
||||
}
|
||||
val dispatch = { getAssociatedClientId(e).use { super.dispatchEvent(e) } }
|
||||
if (EventQueue.isDispatchThread()) {
|
||||
var result = false
|
||||
performActivity(e) { result = super.dispatchEvent(e) }
|
||||
performActivity(e) { result = dispatch() }
|
||||
return result
|
||||
}
|
||||
else {
|
||||
return super.dispatchEvent(e)
|
||||
return dispatch()
|
||||
}
|
||||
}
|
||||
|
||||
private fun getAssociatedClientId(e: AWTEvent) : AccessToken {
|
||||
val id = e.id
|
||||
if (id == WindowEvent.WINDOW_GAINED_FOCUS ||
|
||||
id == WindowEvent.WINDOW_LOST_FOCUS ||
|
||||
id == FocusEvent.FOCUS_GAINED ||
|
||||
id == FocusEvent.FOCUS_LOST) {
|
||||
ClientSessionsManager.getAppSessions(ClientKind.CONTROLLER).firstOrNull()?.let {
|
||||
return withClientId(it.clientId)
|
||||
}
|
||||
}
|
||||
return AccessToken.EMPTY_ACCESS_TOKEN
|
||||
}
|
||||
|
||||
override fun setDefaultFocusTraversalPolicy(defaultPolicy: FocusTraversalPolicy) {
|
||||
if (parentConstructorExecuted) {
|
||||
val log = logger<IdeKeyboardFocusManager>()
|
||||
|
||||
Reference in New Issue
Block a user