mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2025-12-06 09:29:38 +01:00
JBR-4680 idea window flickers while changing the screen brightness
Update insets in separate notification
This commit is contained in:
@@ -66,8 +66,11 @@ import java.util.Map;
|
||||
import sun.awt.AppContext;
|
||||
import sun.awt.SunToolkit;
|
||||
import sun.java2d.SunGraphicsEnvironment;
|
||||
import sun.util.logging.PlatformLogger;
|
||||
|
||||
class _AppEventHandler {
|
||||
private static final PlatformLogger logger = PlatformLogger.getLogger(_AppEventHandler.class.getName());
|
||||
|
||||
private static final int NOTIFY_ABOUT = 1;
|
||||
private static final int NOTIFY_PREFS = 2;
|
||||
private static final int NOTIFY_OPEN_APP = 3;
|
||||
@@ -267,10 +270,13 @@ class _AppEventHandler {
|
||||
instance.systemSleepDispatcher.dispatch(new _NativeEvent(Boolean.FALSE));
|
||||
break;
|
||||
case NOTIFY_SCREEN_CHANGE_PARAMETERS:
|
||||
if (logger.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
logger.fine("NOTIFY_SCREEN_CHANGE_PARAMETERS");
|
||||
}
|
||||
if (AppContext.getAppContext() != null) {
|
||||
EventQueue.invokeLater(
|
||||
() -> ((SunGraphicsEnvironment)SunGraphicsEnvironment.
|
||||
getLocalGraphicsEnvironment()).displayChanged());
|
||||
getLocalGraphicsEnvironment()).displayParametersChanged());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -46,7 +46,7 @@ import sun.util.logging.PlatformLogger;
|
||||
import static java.awt.peer.ComponentPeer.SET_BOUNDS;
|
||||
|
||||
public final class CGraphicsDevice extends GraphicsDevice
|
||||
implements DisplayChangedListener {
|
||||
implements DisplayChangedListener, DisplayParametersChangedListener {
|
||||
|
||||
private static final PlatformLogger logger = PlatformLogger.getLogger(CGraphicsDevice.class.getName());
|
||||
/**
|
||||
@@ -224,6 +224,20 @@ public final class CGraphicsDevice extends GraphicsDevice
|
||||
//TODO configs?
|
||||
}
|
||||
|
||||
public void displayParametersChanged() {
|
||||
Insets newScreenInsets = nativeGetScreenInsets(displayID);
|
||||
if (!newScreenInsets.equals(screenInsets)) {
|
||||
if (logger.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
logger.fine("Screen insets for display(" + displayID + ") changed " +
|
||||
"[top=" + screenInsets.top + ",left=" + screenInsets.left +
|
||||
",bottom=" + screenInsets.bottom + ",right=" + screenInsets.right +
|
||||
"]->[top=" + newScreenInsets.top + ",left=" + newScreenInsets.left +
|
||||
",bottom=" + newScreenInsets.bottom + ",right=" + newScreenInsets.right +
|
||||
"]");
|
||||
}
|
||||
screenInsets = newScreenInsets;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void paletteChanged() {
|
||||
// devices do not need to react to this event.
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2022, JetBrains s.r.o.. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.awt;
|
||||
|
||||
import java.util.EventListener;
|
||||
|
||||
public interface DisplayParametersChangedListener extends EventListener {
|
||||
/**
|
||||
* Invoked when the display parameters changed.
|
||||
*/
|
||||
public void displayParametersChanged();
|
||||
}
|
||||
@@ -46,6 +46,7 @@ import java.util.Locale;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import sun.awt.DisplayChangedListener;
|
||||
import sun.awt.DisplayParametersChangedListener;
|
||||
import sun.awt.SunDisplayChanger;
|
||||
import sun.font.FontManager;
|
||||
import sun.font.FontManagerFactory;
|
||||
@@ -62,7 +63,7 @@ import sun.security.action.GetPropertyAction;
|
||||
* @see GraphicsConfiguration
|
||||
*/
|
||||
public abstract class SunGraphicsEnvironment extends GraphicsEnvironment
|
||||
implements DisplayChangedListener {
|
||||
implements DisplayChangedListener, DisplayParametersChangedListener {
|
||||
|
||||
/** Establish the default font to be used by SG2D. */
|
||||
private final Font defaultFont = new Font(Font.DIALOG, Font.PLAIN, 12);
|
||||
@@ -266,6 +267,15 @@ public abstract class SunGraphicsEnvironment extends GraphicsEnvironment
|
||||
displayChanger.notifyListeners();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayParametersChanged() {
|
||||
for (GraphicsDevice gd : getScreenDevices()) {
|
||||
if (gd instanceof DisplayParametersChangedListener) {
|
||||
((DisplayParametersChangedListener) gd).displayParametersChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Part of the DisplayChangedListener interface:
|
||||
* propagate this event to listeners
|
||||
|
||||
Reference in New Issue
Block a user