move User32Ex and WinFocusStealer to ide.ui module

GitOrigin-RevId: e5c3a0d406454c1d9d23c3c5d3ec2bebe0d1d38e
This commit is contained in:
Vladimir Krivosheev
2024-10-14 07:37:25 +02:00
committed by intellij-monorepo-bot
parent 9855b392a8
commit e96b491141
12 changed files with 22 additions and 17 deletions

View File

@@ -14876,10 +14876,6 @@ c:com.intellij.ui.TreeTableSpeedSearch
- p:isSpeedSearchEnabled():Z
- p:selectElement(java.lang.Object,java.lang.String):V
- setCanExpand(Z):V
f:com.intellij.ui.WinFocusStealer
- java.awt.event.AWTEventListener
- eventDispatched(java.awt.AWTEvent):V
- s:setFocusStealingEnabled(Z):V
c:com.intellij.ui.WindowMoveListener
- java.awt.event.MouseAdapter
- javax.swing.event.MouseInputListener

View File

@@ -26,6 +26,7 @@
<orderEntry type="module" module-name="intellij.platform.lvcs" />
<orderEntry type="module" module-name="intellij.platform.util.coroutines" />
<orderEntry type="module" module-name="intellij.platform.indexing" />
<orderEntry type="module" module-name="intellij.platform.ide.ui" />
<orderEntry type="library" name="jna" level="project" />
<orderEntry type="library" name="hash4j" level="project" />
<orderEntry type="library" name="jbr-api" level="project" />

View File

@@ -13,8 +13,8 @@ import com.intellij.openapi.diagnostic.LogLevel;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.SystemInfoRt;
import com.intellij.openapi.util.io.NioFiles;
import com.intellij.ui.User32Ex;
import com.intellij.util.Suppressions;
import com.intellij.util.User32Ex;
import com.sun.jna.platform.win32.WinDef;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
@@ -39,7 +39,7 @@ import static java.util.Objects.requireNonNullElseGet;
/**
* The class ensures that only one IDE instance is running on the given pair of configuration/cache directories
* and participates in the CLI by passing arguments and relaying back exit codes and error messages.
* and participates in the CLI bypassing arguments and relaying back exit codes and error messages.
*/
final class DirectoryLock {
static final class CannotActivateException extends Exception {

View File

@@ -11,10 +11,10 @@ import com.intellij.openapi.components.serviceAsync
import com.intellij.openapi.ui.MessageDialogBuilder
import com.intellij.openapi.ui.Messages
import com.intellij.openapi.util.SystemInfoRt
import com.intellij.ui.User32Ex
import com.intellij.ui.mac.foundation.Foundation
import com.intellij.ui.mac.foundation.Foundation.NSAutoreleasePool
import com.intellij.ui.mac.foundation.ID
import com.intellij.util.User32Ex
import com.sun.jna.platform.win32.WinDef
import kotlinx.coroutines.withContext
import org.jetbrains.annotations.ApiStatus

View File

@@ -3,9 +3,8 @@ package com.intellij.execution.process.window.to.foreground
import com.intellij.openapi.util.Key
import com.intellij.openapi.util.UserDataHolder
import com.intellij.openapi.util.getOrCreateUserData
import com.intellij.openapi.util.getOrCreateUserDataUnsafe
import com.intellij.util.User32Ex
import com.intellij.ui.User32Ex
import com.intellij.util.findMainWindow
import com.intellij.util.findWindowsWithText
import com.jetbrains.rd.util.getLogger

View File

@@ -3,7 +3,6 @@ package com.intellij.ui;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.util.User32Ex;
import com.intellij.util.ui.EDT;
import com.sun.jna.Function;
import com.sun.jna.Memory;

View File

@@ -1,6 +1,7 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.util
import com.intellij.ui.User32Ex
import com.jetbrains.rd.util.error
import com.jetbrains.rd.util.getLogger
import com.jetbrains.rd.util.trace

View File

@@ -12,5 +12,6 @@
<orderEntry type="module" module-name="intellij.platform.core.ui" />
<orderEntry type="library" name="jetbrains-annotations" level="project" />
<orderEntry type="module" module-name="intellij.platform.ide.core" />
<orderEntry type="library" name="jna" level="project" />
</component>
</module>

View File

@@ -1,5 +1,5 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.util;
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ui;
import com.sun.jna.Callback;
import com.sun.jna.Memory;
@@ -29,10 +29,15 @@ public interface User32Ex extends StdCallLibrary {
int Flags);
boolean FlashWindow(WinDef.HWND hwnd, boolean bInvert);
boolean SystemParametersInfo(WinDef.UINT uiAction, WinDef.UINT uiParam, WinDef.BOOLByReference pvParam, WinDef.UINT fWinIni);
boolean SystemParametersInfo(WinDef.UINT uiAction, WinDef.UINT uiParam, WinDef.UINTByReference pvParam, WinDef.UINT fWinIni);
boolean SystemParametersInfo(WinDef.UINT uiAction, WinDef.UINT uiParam, WinDef.UINT pvParam, WinDef.UINT fWinIni);
boolean AllowSetForegroundWindow(WinDef.DWORD pid);
boolean SetForegroundWindow(WinDef.HWND hwnd);
@ApiStatus.Internal

View File

@@ -1,14 +1,14 @@
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ui;
import com.intellij.jna.JnaLoader;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.util.User32Ex;
import com.intellij.util.ui.UIUtil;
import com.sun.jna.platform.win32.Advapi32Util;
import com.sun.jna.platform.win32.WinDef;
import com.sun.jna.platform.win32.WinReg;
import org.jetbrains.annotations.ApiStatus;
import javax.swing.*;
import java.awt.*;
@@ -16,11 +16,12 @@ import java.awt.event.AWTEventListener;
/**
* This class allows to disable Windows focus stealing prevention mechanism. The changes have a system-wide effect,
* i.e. focus stealing can only be enabled for all applications in the system, not just for IDE process.
* i.e., focus stealing can only be enabled for all applications in the system, not just for an IDE process.
* <p>
* The desired effect is achieved by setting system-wide 'foreground lock timeout' value to zero. This is a duration that should pass after
* user input in one window before another window is allowed to steal focus.
*/
@ApiStatus.Internal
public final class WinFocusStealer implements AWTEventListener {
private static final Logger LOG = Logger.getInstance(WinFocusStealer.class);
private static final int DEFAULT_TIMEOUT_MS = 200000; // default registry value on Windows 10 as of time this code is written
@@ -30,7 +31,7 @@ public final class WinFocusStealer implements AWTEventListener {
private WinFocusStealer() {
if (JnaLoader.isLoaded()) {
myEnabled = true;
doUpdate(false); // make sure to restore the default state if IDE crashed after enabling focus stealing
doUpdate(false); // make sure to restore the default state if the IDE crashed after enabling focus stealing
SwingUtilities.invokeLater(() -> Toolkit.getDefaultToolkit().addAWTEventListener(this,
AWTEvent.KEY_EVENT_MASK |
AWTEvent.MOUSE_EVENT_MASK |
@@ -46,7 +47,7 @@ public final class WinFocusStealer implements AWTEventListener {
/**
* Enables or disables focus stealing globally in the system. This can only come to effect if the IDE window is currently active.
* If this is not the case, at the time this method is invoked, the actual change will be performed when next user input event is
* If this is not the case, at the time this method is invoked, the actual change will be performed when the next user input event is
* received.
* <p>
* With focus stealing enabled, {@link AppIcon#requestFocus(Window)} method should bring the target IDE window into foreground, even if

View File

@@ -65,6 +65,7 @@
<orderEntry type="module" module-name="intellij.platform.diagnostic.telemetry.impl" />
<orderEntry type="module" module-name="intellij.platform.diagnostic" />
<orderEntry type="module" module-name="intellij.platform.bootstrap" />
<orderEntry type="module" module-name="intellij.platform.ide.ui" />
<orderEntry type="module" module-name="intellij.platform.lang.core" />
<orderEntry type="module" module-name="intellij.platform.runtime.product" />
<orderEntry type="module" module-name="intellij.platform.execution" />

View File

@@ -55,6 +55,7 @@
<orderEntry type="module" module-name="intellij.platform.util.text.matching" />
<orderEntry type="module" module-name="intellij.platform.util.coroutines" />
<orderEntry type="module" module-name="intellij.platform.editor.ex" />
<orderEntry type="module" module-name="intellij.platform.ide.ui" />
<orderEntry type="library" name="jackson" level="project" />
<orderEntry type="library" name="jackson-databind" level="project" />
<orderEntry type="module" module-name="intellij.platform.kernel" />