Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/Eclipse-R4_21/Control.java b/Eclipse-R4_26/Control.java
- index bfedd8d..1155bdc 100644
- --- a/Eclipse-R4_21/Control.java
- +++ b/Eclipse-R4_26/Control.java
- @@ -57,6 +57,8 @@ public abstract class Control extends Widget implements Drawable {
- static final boolean DISABLE_EMOJI = Boolean.getBoolean("SWT_GTK_INPUT_HINT_NO_EMOJI");
- long fixedHandle;
- + long firstFixedHandle = 0;
- + long keyController;
- long redrawWindow, enableWindow, provider;
- int drawCount, backgroundAlpha = 255;
- long dragGesture, zoomGesture, rotateGesture, panGesture;
- @@ -111,7 +113,6 @@ public abstract class Control extends Widget implements Drawable {
- * is currently pressed or released for DND.
- */
- static boolean mouseDown;
- - boolean dragBegun;
- /**
- * Flag to check the scale factor upon the first drawing of this Control.
- @@ -432,8 +433,9 @@ void hookEvents () {
- private void hookKeyboardAndFocusSignals(long focusHandle) {
- if (GTK.GTK4) {
- - long keyController = GTK4.gtk_event_controller_key_new();
- + keyController = GTK4.gtk_event_controller_key_new();
- GTK4.gtk_widget_add_controller(focusHandle, keyController);
- + GTK.gtk_event_controller_set_propagation_phase(keyController, GTK.GTK_PHASE_CAPTURE);
- OS.g_signal_connect(keyController, OS.key_pressed, display.keyPressReleaseProc, KEY_PRESSED);
- OS.g_signal_connect(keyController, OS.key_released, display.keyPressReleaseProc, KEY_RELEASED);
- @@ -882,11 +884,7 @@ void forceResize () {
- gtk_widget_get_preferred_size (topHandle, requisition);
- GtkAllocation allocation = new GtkAllocation ();
- GTK.gtk_widget_get_allocation(topHandle, allocation);
- - if (GTK.GTK4) {
- - GTK4.gtk_widget_size_allocate (topHandle, allocation, -1);
- - } else {
- - GTK3.gtk_widget_size_allocate (topHandle, allocation);
- - }
- + gtk_widget_size_allocate(topHandle, allocation, -1);
- }
- /**
- @@ -1070,7 +1068,7 @@ Point resizeCalculationsGTK3 (long widget, int width, int height) {
- }
- int setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
- - // bug in GTK2 crashes JVM, in GTK3 the new shell only. See bug 472743
- + // bug in GTK3 the crashes new shell only. See bug 472743
- width = Math.min(width, (2 << 14) - 1);
- height = Math.min(height, (2 << 14) - 1);
- @@ -1153,11 +1151,7 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
- Control focusControl = display.getFocusControl();
- GTK.gtk_widget_show(topHandle);
- gtk_widget_get_preferred_size (topHandle, requisition);
- - if (GTK.GTK4) {
- - GTK4.gtk_widget_size_allocate (topHandle, allocation, -1);
- - } else {
- - GTK3.gtk_widget_size_allocate (topHandle, allocation);
- - }
- + gtk_widget_size_allocate(topHandle, allocation, -1);
- GTK.gtk_widget_hide(topHandle);
- /* Bug 540002: Showing and hiding widget causes original focused control to loose focus,
- * Reset focus to original focused control after dealing with allocation.
- @@ -2676,36 +2670,36 @@ boolean dragDetect (int button, int count, int stateMask, int x, int y) {
- }
- boolean dragDetect (int x, int y, boolean filter, boolean dragOnTimeout, boolean [] consume) {
- - boolean dragging = false;
- /*
- * Feature in GTK: In order to support both X.11/Wayland, GTKGestures are used
- * as of GTK3.14 in order to acquire mouse position offsets to decide on dragging.
- * See Bug 503431.
- */
- if (!OS.isX11()) { // Wayland
- + // Don't drag if mouse is not down. This condition is not as
- + // trivial as it seems, see Bug 541635 where drag is tested
- + // after drag already completed and mouse is released.
- + if (!mouseDown) {
- + return false;
- + }
- +
- double [] offsetX = new double[1];
- double [] offsetY = new double [1];
- double [] startX = new double[1];
- double [] startY = new double [1];
- - if (GTK.gtk_gesture_drag_get_start_point(dragGesture, startX, startY)) {
- - GTK.gtk_gesture_drag_get_offset(dragGesture, offsetX, offsetY);
- - if (GTK3.gtk_drag_check_threshold(handle, (int)startX[0], (int) startY[0], (int) startX[0]
- - + (int) offsetX[0], (int) startY[0] + (int) offsetY[0])) {
- - dragging = true;
- - }
- - } else {
- + if (!GTK.gtk_gesture_drag_get_start_point(dragGesture, startX, startY)) {
- return false;
- }
- - // Block until mouse was released or drag was detected, see Bug 515396.
- - while (true) {
- - if (!mouseDown) {
- - return false;
- - }
- - if (dragBegun) {
- - return true;
- - }
- +
- + GTK.gtk_gesture_drag_get_offset(dragGesture, offsetX, offsetY);
- + if (GTK3.gtk_drag_check_threshold(handle, (int)startX[0], (int) startY[0], (int) startX[0]
- + + (int) offsetX[0], (int) startY[0] + (int) offsetY[0])) {
- + return true;
- }
- +
- + return false;
- } else {
- + boolean dragging = false;
- boolean quit = false;
- //428852 DND workaround for GTK3.
- //Gtk3 no longer sends motion events on the same control during thread sleep
- @@ -2806,8 +2800,8 @@ boolean dragDetect (int x, int y, boolean filter, boolean dragOnTimeout, boolean
- }
- gdk_event_free (eventPtr);
- }
- + return dragging;
- }
- - return dragging;
- }
- boolean filterKey (long event) {
- @@ -3236,29 +3230,19 @@ public Menu getMenu () {
- public Monitor getMonitor () {
- checkWidget ();
- Monitor[] monitors = display.getMonitors ();
- - if (GTK.GTK_VERSION >= OS.VERSION(3, 22, 0)) {
- - long display = GDK.gdk_display_get_default ();
- - if (display != 0) {
- - long monitor;
- - if (GTK.GTK4) {
- - monitor = GDK.gdk_display_get_monitor_at_surface(display, paintSurface ());
- - } else {
- - monitor = GDK.gdk_display_get_monitor_at_window(display, paintWindow ());
- - }
- - long toCompare;
- - for (int i = 0; i < monitors.length; i++) {
- - toCompare = GDK.gdk_display_get_monitor(display, i);
- - if (toCompare == monitor) {
- - return monitors[i];
- - }
- - }
- + long displayHandle = GDK.gdk_display_get_default ();
- + if (displayHandle != 0) {
- + long monitor;
- + if (GTK.GTK4) {
- + monitor = GDK.gdk_display_get_monitor_at_surface(displayHandle, paintSurface ());
- + } else {
- + monitor = GDK.gdk_display_get_monitor_at_window(displayHandle, paintWindow ());
- }
- - } else {
- - long screen = GDK.gdk_screen_get_default ();
- - if (screen != 0) {
- - int monitorNumber = GDK.gdk_screen_get_monitor_at_window (screen, paintWindow ());
- - if (monitorNumber >= 0 && monitorNumber < monitors.length) {
- - return monitors [monitorNumber];
- + long toCompare;
- + for (int i = 0; i < monitors.length; i++) {
- + toCompare = GDK.gdk_display_get_monitor(displayHandle, i);
- + if (toCompare == monitor) {
- + return monitors[i];
- }
- }
- }
- @@ -3444,7 +3428,6 @@ void gtk_style_context_get_border (long context, int state, GtkBorder padding) {
- @Override
- void gtk_gesture_press_event (long gesture, int n_press, double x, double y, long event) {
- mouseDown = true;
- - dragBegun = false;
- int eventButton = GDK.gdk_button_event_get_button(event);
- int eventTime = GDK.gdk_event_get_time(event);
- @@ -3488,7 +3471,6 @@ long gtk_button_press_event (long widget, long event) {
- long gtk_button_press_event (long widget, long event, boolean sendMouseDown) {
- mouseDown = true;
- - dragBegun = false;
- double [] eventX = new double [1];
- double [] eventY = new double [1];
- @@ -3630,6 +3612,18 @@ long gtk_commit (long imcontext, long text) {
- @Override
- void gtk4_enter_event(long controller, double x, double y, long event) {
- + /*
- + * Set tool tip for this shell, and also null tooltip for shell
- + * if control being entered does not have a tooltip text set.
- + */
- + byte [] buffer = null;
- + if (toolTipText != null && toolTipText.length() != 0) {
- + char [] chars = fixMnemonic (toolTipText, false, true);
- + buffer = Converter.wcsToMbcs (chars, true);
- + }
- + long toolHandle = getShell().handle;
- + GTK.gtk_widget_set_tooltip_text (toolHandle, buffer);
- +
- if (display.currentControl == this) return;
- // Disconnect previous current Control and send MouseExit event to it
- @@ -3932,6 +3926,25 @@ void gtk4_focus_enter_event(long controller, long event) {
- sendFocusEvent(SWT.FocusIn);
- }
- +@Override
- +void gtk4_focus_window_event(long handle, long event) {
- + super.gtk4_focus_window_event(handle, event);
- +
- + if(firstFixedHandle == 0) {
- + long child = handle;
- + //3rd child of shell will be SWTFixed
- + for(int i = 0; i<3; i++) {
- + child = GTK4.gtk_widget_get_first_child(child);
- + }
- + firstFixedHandle = child != 0 ? child:0;
- + }
- +
- + if(firstFixedHandle !=0 && GTK.gtk_widget_has_focus(firstFixedHandle)) {
- + if(event == SWT.FocusIn)sendFocusEvent(SWT.FocusIn);
- + else sendFocusEvent(SWT.FocusOut);
- + }
- +}
- +
- @Override
- long gtk_focus_out_event (long widget, long event) {
- // widget could be disposed at this point
- @@ -4093,10 +4106,6 @@ long gtk_mnemonic_activate (long widget, long arg1) {
- @Override
- void gtk4_motion_event(long controller, double x, double y, long event) {
- - if (mouseDown) {
- - dragBegun = true;
- - }
- -
- if (this == display.currentControl && (hooks(SWT.MouseHover) || filters(SWT.MouseHover))) {
- display.addMouseHoverTimeout(handle);
- }
- @@ -4127,9 +4136,6 @@ void gtk4_motion_event(long controller, double x, double y, long event) {
- @Override
- long gtk_motion_notify_event (long widget, long event) {
- int result;
- - if (mouseDown) {
- - dragBegun = true;
- - }
- double[] eventX = new double[1];
- double[] eventY = new double[1];
- @@ -4831,7 +4837,13 @@ void destroyWidget() {
- if (GTK.GTK4) {
- // Remove widget from hierarchy by removing it from parent container
- if (parent != null) {
- - OS.swt_fixed_remove(parent.parentingHandle(), fixedHandle);
- + long currHandle = topHandle();
- + if(GTK.GTK_IS_WINDOW(currHandle)) {
- + GTK4.gtk_window_destroy(currHandle);
- + }
- + else {
- + OS.swt_fixed_remove(parent.parentingHandle(), fixedHandle);
- + }
- }
- releaseHandle();
- } else {
- @@ -5007,7 +5019,13 @@ boolean sendMouseEvent (int type, int button, int count, int detail, boolean sen
- sendOrPost(SWT.MouseDown, mouseDownEvent);
- }
- }
- - return true;
- + /* This checks for Wayland, a previous MouseDown || MouseMove in the
- + * dragDetectionQueue and it checks if the current event is MouseMove
- + * This will prevent them from not being queued, which caused
- + * Bug 576215 - [Wayland] Mouse events not received as on other platforms.
- + * In x11 this will always return true as before.
- + */
- + if( (OS.isX11() || (dragDetectionQueue == null) || (type != SWT.MouseMove)) ) return true;
- }
- Event event = new Event ();
- event.time = time;
- @@ -5039,7 +5057,6 @@ boolean sendMouseEvent (int type, int button, int count, int detail, boolean sen
- /**
- * Bug 510446:
- - * In the original gtk2 DnD architecture, Drag detection was done in mouseDown.
- * For Wayland support, Drag detection is now done in mouseMove (as does gtk internally).
- *
- * However, traditionally external widgets (e.g StyledText or non-SWT widgets) expect to
- @@ -5052,7 +5069,7 @@ boolean sendMouseEvent (int type, int button, int count, int detail, boolean sen
- * - To ensure we follow 'send/post' contract as per parameter, we
- * temporarily utilize event.data to hold send/post flag.
- * There's also logic in place such that mouseDown/mouseMotion is always sent before mouseUp.
- - * - On Gtk2, mouseMove is sent during DnD. On Gtk3x11 it's not due to hacky implementation of DnD.
- + * - On Gtk3x11 it's not due to hacky implementation of DnD.
- * On Wayland mouseMove is once again sent during DnD as per improved architecture.
- */
- event.data = Boolean.valueOf(send);
- @@ -5281,21 +5298,6 @@ public void setBackgroundImage (Image image) {
- }
- void setBackgroundSurface (Image image) {
- - if (GTK.GTK_VERSION >= OS.VERSION(3, 22, 0)) {
- - // gdk_window_set_background_pattern() deprecated in GTK3.22+
- - return;
- - }
- -
- - long window = GTK3.gtk_widget_get_window (paintHandle ());
- - if (window != 0) {
- - if (image.surface != 0) {
- - long pattern = Cairo.cairo_pattern_create_for_surface(image.surface);
- - if (pattern == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- - Cairo.cairo_pattern_set_extend(pattern, Cairo.CAIRO_EXTEND_REPEAT);
- - GDK.gdk_window_set_background_pattern(window, pattern);
- - Cairo.cairo_pattern_destroy(pattern);
- - }
- - }
- }
- /**
- @@ -5787,7 +5789,6 @@ void setOrientation (boolean create) {
- /**
- * Sets the orientation of the receiver, which must be one
- * of the constants <code>SWT.LEFT_TO_RIGHT</code> or <code>SWT.RIGHT_TO_LEFT</code>.
- - * <p>
- *
- * @param orientation new orientation style
- *
- @@ -5875,11 +5876,7 @@ public boolean setParent (Composite parent) {
- allocation.y = y;
- allocation.width = width;
- allocation.height = height;
- - if (GTK.GTK4) {
- - GTK4.gtk_widget_size_allocate (topHandle, allocation, -1);
- - } else {
- - GTK3.gtk_widget_size_allocate (topHandle, allocation);
- - }
- + gtk_widget_size_allocate(topHandle, allocation, -1);
- this.parent = parent;
- setZOrder (null, false, true);
- reskin (SWT.ALL);
- @@ -5955,10 +5952,6 @@ public void setRedraw (boolean redraw) {
- GDK.GDK_BUTTON_MOTION_MASK | GDK.GDK_BUTTON1_MOTION_MASK |
- GDK.GDK_BUTTON2_MOTION_MASK | GDK.GDK_BUTTON3_MOTION_MASK;
- GDK.gdk_window_set_events (window, GDK.gdk_window_get_events (window) & ~mouseMask);
- - // No gdk_surface_set_background_pattern() on GTK4.
- - if (GTK.GTK_VERSION < OS.VERSION(3, 22, 0)) {
- - GDK.gdk_window_set_background_pattern(redrawWindow, 0);
- - }
- GDK.gdk_window_show (redrawWindow);
- }
- }
- @@ -6779,10 +6772,11 @@ boolean traverseMnemonic (char key) {
- public void update () {
- checkWidget ();
- update (false, true);
- +
- }
- void update (boolean all, boolean flush) {
- -// checkWidget();
- + if(GTK.GTK4) GTK.gtk_widget_queue_draw(handle);
- if (!GTK.gtk_widget_get_visible (topHandle ())) return;
- if (!GTK.gtk_widget_get_realized (handle)) return;
- long window = paintWindow ();
- diff --git a/Eclipse-R4_21/DPIUtil.java b/Eclipse-R4_26/DPIUtil.java
- index f755898..874339b 100644
- --- a/Eclipse-R4_21/DPIUtil.java
- +++ b/Eclipse-R4_26/DPIUtil.java
- @@ -1,5 +1,5 @@
- /*******************************************************************************
- - * Copyright (c) 2017 IBM Corporation and others.
- + * Copyright (c) 2022 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- @@ -10,6 +10,7 @@
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- + * Daniel Kruegler - #420 - [High DPI] "swt.autoScale" should add new "half" option
- *******************************************************************************/
- package org.eclipse.swt.internal;
- @@ -54,6 +55,9 @@ public class DPIUtil {
- * generally rounded down (e.g. at 150%, will use 100%), unless close to
- * the next integer multiple (currently at 175%, will use 200%).</li>
- * <li><b>integer200</b>: like <b>integer</b>, but the maximal zoom level is 200%.</li>
- + * <li><b>half</b>: deviceZoom depends on the current display resolution,
- + * but only uses integer multiples of 50%. The detected native zoom is
- + * rounded to the closest permissible value, with tie-breaker towards even.</li>
- * <li><b>quarter</b>: deviceZoom depends on the current display resolution,
- * but only uses integer multiples of 25%. The detected native zoom is
- * rounded to the closest permissible value.</li>
- @@ -456,8 +460,13 @@ public static int getZoomForAutoscaleProperty (int nativeDeviceZoom) {
- if (autoScaleValue != null) {
- if ("false".equalsIgnoreCase (autoScaleValue)) {
- zoom = 100;
- + } else if ("half".equalsIgnoreCase (autoScaleValue)) {
- + // Math.round rounds 125->150 and 175->200,
- + // Math.rint rounds 125->100 and 175->200 matching
- + // "integer200"
- + zoom = (int) Math.rint(nativeDeviceZoom / 50d) * 50;
- } else if ("quarter".equalsIgnoreCase (autoScaleValue)) {
- - zoom = (int) (Math.round (nativeDeviceZoom / 25f) * 25);
- + zoom = Math.round(nativeDeviceZoom / 25f) * 25;
- } else if ("exact".equalsIgnoreCase (autoScaleValue)) {
- zoom = nativeDeviceZoom;
- } else {
- @@ -471,10 +480,6 @@ public static int getZoomForAutoscaleProperty (int nativeDeviceZoom) {
- }
- if (zoom == 0) { // || "integer".equalsIgnoreCase (value) || "integer200".equalsIgnoreCase (value)
- zoom = Math.max ((nativeDeviceZoom + 25) / 100 * 100, 100);
- - if (!"integer".equalsIgnoreCase(autoScaleValue)) {
- - // integer200, or default
- - zoom = Math.min (zoom, 200);
- - }
- }
- return zoom;
- }
- diff --git a/Eclipse-R4_21/Display.java b/Eclipse-R4_26/Display.java
- index 74ea637..1bd1186 100644
- --- a/Eclipse-R4_21/Display.java
- +++ b/Eclipse-R4_26/Display.java
- @@ -1,5 +1,5 @@
- /*******************************************************************************
- - * Copyright (c) 2000, 2020 IBM Corporation and others.
- + * Copyright (c) 2000, 2022 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- @@ -10,6 +10,7 @@
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- + * Christoph Läubrich - Issue #64 - Integration with java.util.concurrent framework
- *******************************************************************************/
- package org.eclipse.swt.widgets;
- @@ -19,6 +20,7 @@ import java.lang.reflect.*;
- import java.net.*;
- import java.util.*;
- import java.util.Map.*;
- +import java.util.concurrent.*;
- import java.util.function.*;
- import java.util.regex.*;
- import java.util.regex.Pattern;
- @@ -111,7 +113,7 @@ import org.eclipse.swt.internal.gtk4.*;
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- * @noextend This class is not intended to be subclassed by clients.
- */
- -public class Display extends Device {
- +public class Display extends Device implements Executor {
- static boolean strictChecks = System.getProperty("org.eclipse.swt.internal.gtk.enableStrictChecks") != null;
- @@ -127,16 +129,18 @@ public class Display extends Device {
- long fds;
- int allocated_nfds;
- boolean wake;
- + boolean windowSizeSet;
- int [] max_priority = new int [1], timeout = new int [1];
- Callback eventCallback;
- long eventProc, windowProc2, windowProc3, windowProc4, windowProc5, windowProc6;
- long changeValueProc;
- - long snapshotDrawProc, keyPressReleaseProc, focusProc, enterMotionProc, leaveProc,
- + long snapshotDrawProc, keyPressReleaseProc, focusProc, windowActiveProc, enterMotionProc, leaveProc,
- scrollProc, resizeProc, activateProc, gesturePressReleaseProc;
- long notifyProc;
- + long computeSizeProc;
- Callback windowCallback2, windowCallback3, windowCallback4, windowCallback5, windowCallback6;
- Callback changeValue;
- - Callback snapshotDraw, keyPressReleaseCallback, focusCallback, enterMotionCallback,
- + Callback snapshotDraw, keyPressReleaseCallback, focusCallback, windowActiveCallback, enterMotionCallback, computeSizeCallback,
- scrollCallback, leaveCallback, resizeCallback, activateCallback, gesturePressReleaseCallback;
- Callback notifyCallback;
- EventTable eventTable, filterTable;
- @@ -220,19 +224,6 @@ public class Display extends Device {
- SessionManagerListener sessionManagerListener;
- Runnable [] disposeList;
- - /*
- - * DBus objects to be freed upong Display release. Only public for use in
- - * other areas of SWT (i.e. WebKit). See bug 540060.
- - */
- - /** @noreference */
- - public ArrayList<Long> dBusServers = new ArrayList<>();
- - /** @noreference */
- - public ArrayList<Long> dBusAuthObservers = new ArrayList<>();
- - /** @noreference */
- - public ArrayList<Long> dBusGUIDS = new ArrayList<>();
- - /** @noreference */
- - public ArrayList<Long> dBusConnections = new ArrayList<>();
- -
- /* Deferred Layout list */
- Composite[] layoutDeferred;
- int layoutDeferredCount;
- @@ -507,7 +498,7 @@ public class Display extends Device {
- /* Multiple Displays. */
- static Display Default;
- - static Display [] Displays = new Display [4];
- + static Display [] Displays = new Display [1];
- /* Skinning support */
- Widget [] skinList = new Widget [GROW_SIZE];
- @@ -526,7 +517,7 @@ public class Display extends Device {
- /* Minimum GTK version requirement */
- static final int GTK3_MAJOR = 3;
- - static final int GTK3_MINOR = 20;
- + static final int GTK3_MINOR = 22;
- static final int GTK3_MICRO = 0;
- /* Latest GTK version support */
- @@ -859,7 +850,7 @@ void addPopup (Menu menu) {
- void addSkinnableWidget (Widget widget) {
- if (skinCount >= skinList.length) {
- - Widget[] newSkinWidgets = new Widget [skinList.length + GROW_SIZE];
- + Widget[] newSkinWidgets = new Widget [(skinList.length + 1) * 3 / 2];
- System.arraycopy (skinList, 0, newSkinWidgets, 0, skinList.length);
- skinList = newSkinWidgets;
- }
- @@ -940,6 +931,49 @@ public void asyncExec (Runnable runnable) {
- }
- }
- +/**
- + * Executes the given runnable in the user-interface thread of this Display.
- + * <ul>
- + * <li>If the calling thread is the user-interface thread of this display it is
- + * executed immediately and the method returns after the command has run, as with
- + * the method {@link Display#syncExec(Runnable)}.</li>
- + * <li>In all other cases the <code>run()</code> method of the runnable is
- + * asynchronously executed as with the method
- + * {@link Display#asyncExec(Runnable)} at the next reasonable opportunity. The
- + * caller of this method continues to run in parallel, and is not notified when
- + * the runnable has completed.</li>
- + * </ul>
- + * <p>
- + * This can be used in cases where one want to execute some piece of code that
- + * should be guaranteed to run in the user-interface thread regardless of the
- + * current thread.
- + * </p>
- + *
- + * <p>
- + * Note that at the time the runnable is invoked, widgets that have the receiver
- + * as their display may have been disposed. Therefore, it is advised to check
- + * for this case inside the runnable before accessing the widget.
- + * </p>
- + *
- + * @param runnable the runnable to execute in the user-interface thread, never
- + * <code>null</code>
- + * @throws RejectedExecutionException if this task cannot be accepted for
- + * execution
- + * @throws NullPointerException if runnable is null
- + */
- +@Override
- +public void execute(Runnable runnable) {
- + Objects.requireNonNull(runnable);
- + if (isDisposed()) {
- + throw new RejectedExecutionException(new SWTException (SWT.ERROR_WIDGET_DISPOSED, null));
- + }
- + if (thread == Thread.currentThread()) {
- + syncExec(runnable);
- + } else {
- + asyncExec(runnable);
- + }
- +}
- +
- /**
- * Causes the system hardware to emit a short sound
- * (if it supports this capability).
- @@ -1156,6 +1190,7 @@ void createDisplay (DeviceData data) {
- GDK.gdk_threads_enter ();
- }
- boolean init;
- + windowSizeSet = false;
- if (GTK.GTK4) {
- init = GTK4.gtk_init_check();
- } else {
- @@ -1376,7 +1411,7 @@ Image createImage (String name) {
- OS.g_object_unref(paintable);
- } else {
- long iconTheme = GTK3.gtk_icon_theme_get_default();
- - pixbuf = GTK3.gtk_icon_theme_load_icon(iconTheme, buffer, 48, GTK.GTK_ICON_LOOKUP_FORCE_SIZE, 0);
- + pixbuf = GTK3.gtk_icon_theme_load_icon(iconTheme, buffer, 48, GTK.GTK_ICON_LOOKUP_FORCE_SIZE|GTK.GTK_ICON_LOOKUP_FORCE_REGULAR, 0);
- }
- if (pixbuf == 0) return null;
- @@ -1765,45 +1800,29 @@ Rectangle getBoundsInPixels () {
- checkDevice ();
- Rectangle bounds = new Rectangle(0, 0, 0, 0);
- int maxWidth = 0, maxHeight = 0;
- - if (GTK.GTK_VERSION >= OS.VERSION(3, 22, 0)) {
- - long display = GDK.gdk_display_get_default();
- - int monitorCount = 0;
- - long monitorList = 0;
- - if (GTK.GTK4) {
- - monitorList = GDK.gdk_display_get_monitors(display);
- - monitorCount = OS.g_list_model_get_n_items(monitorList);
- - } else {
- - monitorCount = GDK.gdk_display_get_n_monitors(display);
- - }
- -
- - if (monitorCount > 0) {
- - for (int i = 0; i < monitorCount; i++) {
- - long monitor = GTK.GTK4 ? OS.g_list_model_get_item(monitorList, i) : GDK.gdk_display_get_monitor(display, i);
- - GdkRectangle geometry = new GdkRectangle();
- - GDK.gdk_monitor_get_geometry(monitor, geometry);
- + long display = GDK.gdk_display_get_default();
- + int monitorCount = 0;
- + long monitorList = 0;
- + if (GTK.GTK4) {
- + monitorList = GDK.gdk_display_get_monitors(display);
- + monitorCount = OS.g_list_model_get_n_items(monitorList);
- + } else {
- + monitorCount = GDK.gdk_display_get_n_monitors(display);
- + }
- - if ((geometry.x + geometry.width) > maxWidth) maxWidth = geometry.x + geometry.width;
- - if ((geometry.y + geometry.height) > maxHeight) maxHeight = geometry.y + geometry.height;
- - }
- + if (monitorCount > 0) {
- + for (int i = 0; i < monitorCount; i++) {
- + long monitor = GTK.GTK4 ? OS.g_list_model_get_item(monitorList, i) : GDK.gdk_display_get_monitor(display, i);
- + GdkRectangle geometry = new GdkRectangle();
- + GDK.gdk_monitor_get_geometry(monitor, geometry);
- - bounds.width = maxWidth;
- - bounds.height = maxHeight;
- - return bounds;
- - }
- - } else {
- - long screen = GDK.gdk_screen_get_default();
- - int monitorCount = GDK.gdk_screen_get_n_monitors(screen);
- - if (monitorCount > 0) {
- - for (int i = 0; i < monitorCount; i++) {
- - GdkRectangle dest = new GdkRectangle ();
- - GDK.gdk_screen_get_monitor_geometry (screen, i, dest);
- - if ((dest.x + dest.width) > maxWidth) maxWidth = dest.x + dest.width;
- - if ((dest.y + dest.height) > maxHeight) maxHeight = dest.y + dest.height;
- - }
- - bounds.width = maxWidth;
- - bounds.height = maxHeight;
- - return bounds;
- + if ((geometry.x + geometry.width) > maxWidth) maxWidth = geometry.x + geometry.width;
- + if ((geometry.y + geometry.height) > maxHeight) maxHeight = geometry.y + geometry.height;
- }
- +
- + bounds.width = maxWidth;
- + bounds.height = maxHeight;
- + return bounds;
- }
- if (GTK.GTK4) {
- @@ -2574,10 +2593,6 @@ int getLastEventTime () {
- return lastEventTime;
- }
- -int getMessageCount () {
- - return synchronizer.getMessageCount ();
- -}
- -
- Dialog getModalDialog () {
- return modalDialog;
- }
- @@ -2588,9 +2603,6 @@ Dialog getModalDialog () {
- * windows. See http://freedesktop.org/Standards/wm-spec.
- */
- Rectangle getWorkArea() {
- - if (OS.IsWin32) {
- - return null;
- - }
- byte[] name = Converter.wcsToMbcs ("_NET_WORKAREA", true); //$NON-NLS-1$
- long atom = GDK.gdk_atom_intern (name, true);
- if (atom == GDK.GDK_NONE) return null;
- @@ -2604,11 +2616,11 @@ Rectangle getWorkArea() {
- Rectangle result = null;
- if (data [0] != 0) {
- if (actualLength [0] == 16) {
- - int values [] = new int [4];
- + int[] values = new int [4];
- C.memmove (values, data[0], 16);
- result = new Rectangle (values [0],values [1],values [2],values [3]);
- } else if (actualLength [0] == 32) {
- - long values [] = new long [4];
- + long[] values = new long [4];
- C.memmove (values, data[0], 32);
- result = new Rectangle ((int)values [0],(int)values [1],(int)values [2],(int)values [3]);
- }
- @@ -2628,77 +2640,47 @@ public Monitor[] getMonitors() {
- checkDevice();
- Monitor[] monitors = null;
- Rectangle workArea = DPIUtil.autoScaleDown(getWorkArea ());
- - if (GTK.GTK_VERSION >= OS.VERSION(3, 22, 0)) {
- - long display = GDK.gdk_display_get_default();
- - if (display != 0) {
- - int monitorCount;
- - long monitorList = 0;
- - if (GTK.GTK4) {
- - monitorList = GDK.gdk_display_get_monitors(display);
- - monitorCount = OS.g_list_model_get_n_items(monitorList);
- - } else {
- - monitorCount = GDK.gdk_display_get_n_monitors(display);
- - }
- -
- - if (monitorCount > 0) {
- - monitors = new Monitor[monitorCount];
- - GdkRectangle geometry = new GdkRectangle();
- - for (int i = 0; i < monitorCount; i++) {
- - long gdkMonitor = GTK.GTK4 ? OS.g_list_model_get_item(monitorList, i) : GDK.gdk_display_get_monitor(display, i);
- - GDK.gdk_monitor_get_geometry(gdkMonitor, geometry);
- -
- - Monitor monitor = new Monitor();
- - monitor.handle = gdkMonitor;
- - monitor.x = DPIUtil.autoScaleDown(geometry.x);
- - monitor.y = DPIUtil.autoScaleDown(geometry.y);
- - monitor.width = DPIUtil.autoScaleDown(geometry.width);
- - monitor.height = DPIUtil.autoScaleDown(geometry.height);
- - if (!OS.isX11()) {
- - int scaleFactor = (int) GDK.gdk_monitor_get_scale_factor(gdkMonitor);
- - monitor.zoom = scaleFactor * 100;
- - } else {
- - monitor.zoom = Display._getDeviceZoom(monitor.handle);
- - }
- -
- - /* workarea was defined in GTK 3.4. If present, it will return the best results
- - * since it takes into account per-monitor trim. Not available in GTK4.
- - */
- - if (!GTK.GTK4) GDK.gdk_monitor_get_workarea(gdkMonitor, geometry);
- - monitor.clientX = DPIUtil.autoScaleDown(geometry.x);
- - monitor.clientY = DPIUtil.autoScaleDown(geometry.y);
- - monitor.clientWidth = DPIUtil.autoScaleDown(geometry.width);
- - monitor.clientHeight = DPIUtil.autoScaleDown(geometry.height);
- -
- - monitors[i] = monitor;
- - }
- - }
- + long display = GDK.gdk_display_get_default();
- + if (display != 0) {
- + int monitorCount;
- + long monitorList = 0;
- + if (GTK.GTK4) {
- + monitorList = GDK.gdk_display_get_monitors(display);
- + monitorCount = OS.g_list_model_get_n_items(monitorList);
- + } else {
- + monitorCount = GDK.gdk_display_get_n_monitors(display);
- }
- - } else {
- - long screen = GDK.gdk_screen_get_default ();
- - if (screen != 0) {
- - int monitorCount = GDK.gdk_screen_get_n_monitors (screen);
- - if (monitorCount > 0) {
- - monitors = new Monitor [monitorCount];
- - GdkRectangle dest = new GdkRectangle ();
- - for (int i = 0; i < monitorCount; i++) {
- - GDK.gdk_screen_get_monitor_geometry (screen, i, dest);
- - Monitor monitor = new Monitor ();
- - monitor.handle = i;
- - monitor.x = DPIUtil.autoScaleDown (dest.x);
- - monitor.y = DPIUtil.autoScaleDown (dest.y);
- - monitor.width = DPIUtil.autoScaleDown (dest.width);
- - monitor.height = DPIUtil.autoScaleDown (dest.height);
- - monitor.zoom = Display._getDeviceZoom(monitor.handle);
- - // workarea was defined in GTK 3.4. If present, it will return the best results
- - // since it takes into account per-monitor trim
- - GDK.gdk_screen_get_monitor_workarea (screen, i, dest);
- - monitor.clientX = DPIUtil.autoScaleDown (dest.x);
- - monitor.clientY = DPIUtil.autoScaleDown (dest.y);
- - monitor.clientWidth = DPIUtil.autoScaleDown (dest.width);
- - monitor.clientHeight = DPIUtil.autoScaleDown (dest.height);
- - monitors [i] = monitor;
- + if (monitorCount > 0) {
- + monitors = new Monitor[monitorCount];
- + GdkRectangle geometry = new GdkRectangle();
- + for (int i = 0; i < monitorCount; i++) {
- + long gdkMonitor = GTK.GTK4 ? OS.g_list_model_get_item(monitorList, i) : GDK.gdk_display_get_monitor(display, i);
- + GDK.gdk_monitor_get_geometry(gdkMonitor, geometry);
- +
- + Monitor monitor = new Monitor();
- + monitor.handle = gdkMonitor;
- + monitor.x = DPIUtil.autoScaleDown(geometry.x);
- + monitor.y = DPIUtil.autoScaleDown(geometry.y);
- + monitor.width = DPIUtil.autoScaleDown(geometry.width);
- + monitor.height = DPIUtil.autoScaleDown(geometry.height);
- + if (!OS.isX11()) {
- + int scaleFactor = (int) GDK.gdk_monitor_get_scale_factor(gdkMonitor);
- + monitor.zoom = scaleFactor * 100;
- + } else {
- + monitor.zoom = Display._getDeviceZoom(monitor.handle);
- }
- +
- + /* workarea was defined in GTK 3.4. If present, it will return the best results
- + * since it takes into account per-monitor trim. Not available in GTK4.
- + */
- + if (!GTK.GTK4) GDK.gdk_monitor_get_workarea(gdkMonitor, geometry);
- + monitor.clientX = DPIUtil.autoScaleDown(geometry.x);
- + monitor.clientY = DPIUtil.autoScaleDown(geometry.y);
- + monitor.clientWidth = DPIUtil.autoScaleDown(geometry.width);
- + monitor.clientHeight = DPIUtil.autoScaleDown(geometry.height);
- +
- + monitors[i] = monitor;
- }
- }
- }
- @@ -2745,7 +2727,7 @@ public Monitor getPrimaryMonitor() {
- if (GTK.GTK4) {
- primaryMonitorIndex = 0;
- - } else if (GTK.GTK_VERSION >= OS.VERSION(3, 22, 0)) {
- + } else {
- //attempt to find actual primary monitor if one is configured:
- long display = GDK.gdk_display_get_default();
- long monitor = GDK.gdk_display_get_primary_monitor(display);
- @@ -2756,12 +2738,6 @@ public Monitor getPrimaryMonitor() {
- break;
- }
- }
- - } else {
- - long screen = GDK.gdk_screen_get_default();
- - if (screen != 0) {
- - //if no primary monitor is configured by the user, this returns 0.
- - primaryMonitorIndex = GDK.gdk_screen_get_primary_monitor(screen);
- - }
- }
- return monitors[primaryMonitorIndex];
- @@ -3000,23 +2976,23 @@ public Image getSystemImage (int id) {
- switch (id) {
- case SWT.ICON_ERROR:
- if (errorImage == null) {
- - errorImage = createImage ("dialog-error"); //$NON-NLS-1$
- + errorImage = createImage ("dialog-error-symbolic"); //$NON-NLS-1$
- }
- return errorImage;
- case SWT.ICON_INFORMATION:
- case SWT.ICON_WORKING:
- if (infoImage == null) {
- - infoImage = createImage ("dialog-information"); //$NON-NLS-1$
- + infoImage = createImage ("dialog-information-symbolic"); //$NON-NLS-1$
- }
- return infoImage;
- case SWT.ICON_QUESTION:
- if (questionImage == null) {
- - questionImage = createImage ("dialog-question"); //$NON-NLS-1$
- + questionImage = createImage ("dialog-question-symbolic"); //$NON-NLS-1$
- }
- return questionImage;
- case SWT.ICON_WARNING:
- if (warningImage == null) {
- - warningImage = createImage ("dialog-warning"); //$NON-NLS-1$
- + warningImage = createImage ("dialog-warning-symbolic"); //$NON-NLS-1$
- }
- return warningImage;
- }
- @@ -3532,11 +3508,12 @@ void initializeCallbacks () {
- signalIds [Widget.MAP_EVENT] = OS.g_signal_lookup (OS.map_event, GTK.GTK_TYPE_WIDGET ());
- signalIds [Widget.MNEMONIC_ACTIVATE] = OS.g_signal_lookup (OS.mnemonic_activate, GTK.GTK_TYPE_WIDGET ());
- signalIds [Widget.MOTION_NOTIFY_EVENT] = OS.g_signal_lookup (OS.motion_notify_event, GTK.GTK_TYPE_WIDGET ());
- + signalIds [Widget.COMPUTE_SIZE] = OS.g_signal_lookup(OS.compute_size, GTK.GTK_TYPE_WIDGET() );
- /*
- - * Connect to the "popped-up" signal on GTK3.22+ if the user has specified the
- + * Connect to the "popped-up" signal if the user has specified the
- * SWT_MENU_LOCATION_DEBUGGING environment variable.
- */
- - if (GTK.GTK_VERSION >= OS.VERSION(3, 22, 0) && OS.SWT_MENU_LOCATION_DEBUGGING) {
- + if (OS.SWT_MENU_LOCATION_DEBUGGING) {
- long menuType = GTK3.GTK_TYPE_MENU ();
- OS.g_type_class_ref (menuType);
- signalIds [Widget.POPPED_UP] = OS.g_signal_lookup (OS.popped_up, menuType);
- @@ -3569,6 +3546,9 @@ void initializeCallbacks () {
- focusCallback = new Callback(this, "focusProc", void.class, new Type[] {long.class, long.class}); //$NON-NLS-1$
- focusProc = focusCallback.getAddress();
- + windowActiveCallback = new Callback(this, "windowActiveProc", void.class, new Type[] {long.class, long.class}); //$NON-NLS-1$
- + windowActiveProc = windowActiveCallback.getAddress();
- +
- enterMotionCallback = new Callback(this, "enterMotionProc", void.class, new Type[] {
- long.class, double.class, double.class, long.class}); //$NON-NLS-1$
- enterMotionProc = enterMotionCallback.getAddress ();
- @@ -3589,6 +3569,9 @@ void initializeCallbacks () {
- activateCallback = new Callback(this, "activateProc", void.class, new Type[] {long.class, long.class, long.class}); //$NON-NLS-1$
- activateProc = activateCallback.getAddress();
- +
- + computeSizeCallback = new Callback(this, "computeSizeProc", void.class, new Type[] {long.class, long.class, long.class}); //$NON-NLS-1$
- + computeSizeProc = computeSizeCallback.getAddress();
- }
- notifyCallback = new Callback(this, "notifyProc", long.class, new Type[] {
- @@ -3664,7 +3647,6 @@ void initializeCallbacks () {
- closuresProc [Widget.TOGGLED] = windowProc3;
- closuresProc [Widget.UNMAP_EVENT] = windowProc3;
- closuresProc [Widget.WINDOW_STATE_EVENT] = windowProc3;
- - closuresProc [Widget.ROW_DELETED] = windowProc3;
- closuresProc [Widget.DIRECTION_CHANGED] = windowProc3;
- windowCallback4 = new Callback (this, "windowProc", 4); //$NON-NLS-1$
- @@ -3679,7 +3661,6 @@ void initializeCallbacks () {
- closuresProc [Widget.SWITCH_PAGE] = windowProc4;
- closuresProc [Widget.TEST_COLLAPSE_ROW] = windowProc4;
- closuresProc [Widget.TEST_EXPAND_ROW] = windowProc4;
- - closuresProc [Widget.ROW_INSERTED] = windowProc4;
- closuresProc [Widget.ROW_HAS_CHILD_TOGGLED] = windowProc4;
- closuresProc [Widget.DELETE_FROM_CURSOR] = windowProc4;
- closuresProc [Widget.DELETE_FROM_CURSOR_INVERSE] = windowProc4;
- @@ -3808,13 +3789,11 @@ void initializeSubclasses () {
- OS.G_OBJECT_CLASS_SET_CONSTRUCTOR (pangoFontFaceClass, OS.pangoFontFaceNewProc_CALLBACK(pangoFontFaceNewProc));
- OS.g_type_class_unref (pangoFontFaceClass);
- - if (!OS.IsWin32) { /* TODO [win32] replace unixprint */
- - long printerOptionWidgetType = GTK.gtk_printer_option_widget_get_type();
- - long printerOptionWidgetClass = OS.g_type_class_ref (printerOptionWidgetType);
- - printerOptionWidgetNewProc = OS.G_OBJECT_CLASS_CONSTRUCTOR (printerOptionWidgetClass);
- - OS.G_OBJECT_CLASS_SET_CONSTRUCTOR (printerOptionWidgetClass, OS.printerOptionWidgetNewProc_CALLBACK(printerOptionWidgetNewProc));
- - OS.g_type_class_unref (printerOptionWidgetClass);
- - }
- + long printerOptionWidgetType = GTK.gtk_printer_option_widget_get_type();
- + long printerOptionWidgetClass = OS.g_type_class_ref (printerOptionWidgetType);
- + printerOptionWidgetNewProc = OS.G_OBJECT_CLASS_CONSTRUCTOR (printerOptionWidgetClass);
- + OS.G_OBJECT_CLASS_SET_CONSTRUCTOR (printerOptionWidgetClass, OS.printerOptionWidgetNewProc_CALLBACK(printerOptionWidgetNewProc));
- + OS.g_type_class_unref (printerOptionWidgetClass);
- }
- }
- @@ -3844,44 +3823,6 @@ void initializeSessionManager() {
- sessionManagerDBus.addListener(sessionManagerListener);
- }
- -/**
- - * Some parts of SWT (like WebKit) use GDBus for IPC. Some of these objects
- - * cannot be disposed of in their own classes due to design challenges.
- - * In these instances we release them along with this Display. This ensures
- - * no Browser will be using them at disposal time.
- - */
- -void releaseDBusServices() {
- - releaseSessionManager();
- - for (long connection : dBusConnections) {
- - if (OS.g_dbus_connection_is_closed(connection)) continue;
- - long [] error = new long [1];
- - boolean closed = OS.g_dbus_connection_close_sync(connection, 0, error);
- - if (error[0] != 0) {
- - String msg = extractFreeGError(error[0]);
- - System.err.println("SWT Display: error closing connection: " + msg);
- - }
- - if (closed) {
- - // Free this as we added a reference to it
- - OS.g_object_unref(connection);
- - }
- - }
- - for (long server : dBusServers) {
- - OS.g_dbus_server_stop(server);
- - OS.g_object_unref(server);
- - }
- - for (long authObserver : dBusAuthObservers) {
- - OS.g_object_unref(authObserver);
- - }
- - for (long guid : dBusGUIDS) {
- - OS.g_free(guid);
- - }
- - dBusConnections.clear();
- - dBusServers.clear();
- - dBusAuthObservers.clear();
- - dBusGUIDS.clear();
- - dBusServers = dBusAuthObservers = dBusGUIDS = dBusConnections = null;
- -}
- -
- /**
- * Helper method to extract GError messages. Only call if the pointer is valid (i.e. non-zero).
- *
- @@ -4665,7 +4606,6 @@ protected void release () {
- synchronizer.releaseSynchronizer ();
- synchronizer = null;
- - releaseDBusServices ();
- releaseSessionManager ();
- releaseDisplay ();
- super.release ();
- @@ -4696,6 +4636,10 @@ void releaseDisplay () {
- focusCallback = null;
- focusProc = 0;
- + windowActiveCallback.dispose();
- + windowActiveCallback = null;
- + windowActiveProc = 0;
- +
- enterMotionCallback.dispose();
- enterMotionCallback = null;
- enterMotionProc = 0;
- @@ -5079,12 +5023,7 @@ String dumpWidgetTableInfo() {
- for (int i = 0; i < widgetTable.length; i++) {
- Widget w = widgetTable[i];
- if (w != null && w.isDisposed()) {
- - Collection<Integer> list = disposed.get(w);
- - if (list == null) {
- - list = new ArrayList<>();
- - disposed.put(w, list);
- - }
- - list.add(Integer.valueOf(i));
- + disposed.computeIfAbsent(w, k -> new ArrayList<>()).add(Integer.valueOf(i));
- }
- }
- if (!disposed.isEmpty()) {
- @@ -5249,11 +5188,13 @@ public static String getAppVersion () {
- * to any value other than "SWT" (case insensitive),
- * it is used to set the application user model ID
- * which is used by the OS for taskbar grouping.
- - * @see <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/dd378459%28v=vs.85%29.aspx#HOW">AppUserModelID (Windows)</a>
- - * </p><p>
- + * </p>
- + * <p>
- * Specifying <code>null</code> for the name clears it.
- * </p>
- *
- + * @see <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/dd378459%28v=vs.85%29.aspx#HOW">AppUserModelID (Windows)</a>
- + *
- * @param name the new app name or <code>null</code>
- */
- public static void setAppName (String name) {
- @@ -5287,6 +5228,17 @@ public static void setAppVersion (String version) {
- * @since 2.1
- */
- public void setCursorLocation (int x, int y) {
- + /*
- + * Wayland does not support mouse warping, thus setCursorLocation
- + * is not supported due to gdk_device_warp not being implemented
- + * in Wayland. There currently is no good solution that could be
- + * implemented, so a log entry was determined to be sufficient.
- + *
- + * See Bug 577099
- + */
- + if(!OS.isX11()) {
- + System.err.println("SWT Display.java Error: setCursorLocation only supported on X11. \n");
- + }
- setCursorLocation(new Point (x, y));
- }
- @@ -5652,7 +5604,7 @@ public boolean sleep () {
- runSettings = true;
- return false;
- }
- - if (getMessageCount () != 0) return true;
- + if (!synchronizer.isMessagesEmpty()) return true;
- sendPreExternalEventDispatchEvent ();
- if (!GTK.GTK4) GDK.gdk_threads_leave ();
- /*
- @@ -5692,7 +5644,7 @@ public boolean sleep () {
- OS.g_main_context_check (context, max_priority [0], fds, nfds);
- OS.g_main_context_release (context);
- }
- - } while (!result && getMessageCount () == 0 && !wake);
- + } while (!result && synchronizer.isMessagesEmpty() && !wake);
- wake = false;
- if (!GTK.GTK4) GDK.gdk_threads_enter ();
- sendPostExternalEventDispatchEvent ();
- @@ -5864,6 +5816,25 @@ void saveResources () {
- }
- }
- +private void sendJDKInternalEvent(int eventType) {
- + sendJDKInternalEvent(eventType, 0);
- +}
- +/** does sent event with JDK time**/
- +private void sendJDKInternalEvent(int eventType, int detail) {
- + if (eventTable == null || !eventTable.hooks (eventType)) {
- + return;
- + }
- + Event event = new Event ();
- + event.detail = detail;
- + event.display = this;
- + event.type = eventType;
- + // time is set for debugging purpose only:
- + event.time = (int) (System.nanoTime() / 1000_000L);
- + if (!filterEvent (event)) {
- + sendEvent (eventTable, event);
- + }
- +}
- +
- void sendEvent (int eventType, Event event) {
- if (eventTable == null && filterTable == null) {
- return;
- @@ -5891,11 +5862,7 @@ void sendPreEvent (int eventType) {
- if (eventType != SWT.PreEvent && eventType != SWT.PostEvent
- && eventType != SWT.PreExternalEventDispatch
- && eventType != SWT.PostExternalEventDispatch) {
- - if (eventTable != null && eventTable.hooks (SWT.PreEvent)) {
- - Event event = new Event ();
- - event.detail = eventType;
- - sendEvent (SWT.PreEvent, event);
- - }
- + sendJDKInternalEvent (SWT.PreEvent, eventType);
- }
- }
- @@ -5903,11 +5870,7 @@ void sendPostEvent (int eventType) {
- if (eventType != SWT.PreEvent && eventType != SWT.PostEvent
- && eventType != SWT.PreExternalEventDispatch
- && eventType != SWT.PostExternalEventDispatch) {
- - if (eventTable != null && eventTable.hooks (SWT.PostEvent)) {
- - Event event = new Event ();
- - event.detail = eventType;
- - sendEvent (SWT.PostEvent, event);
- - }
- + sendJDKInternalEvent (SWT.PostEvent, eventType);
- }
- }
- @@ -5917,9 +5880,7 @@ void sendPostEvent (int eventType) {
- * @noreference This method is not intended to be referenced by clients.
- */
- public void sendPreExternalEventDispatchEvent () {
- - if (eventTable != null && eventTable.hooks (SWT.PreExternalEventDispatch)) {
- - sendEvent (SWT.PreExternalEventDispatch, null);
- - }
- + sendJDKInternalEvent (SWT.PreExternalEventDispatch);
- }
- /**
- @@ -5928,9 +5889,7 @@ public void sendPreExternalEventDispatchEvent () {
- * @noreference This method is not intended to be referenced by clients.
- */
- public void sendPostExternalEventDispatchEvent () {
- - if (eventTable != null && eventTable.hooks (SWT.PostExternalEventDispatch)) {
- - sendEvent (SWT.PostExternalEventDispatch, null);
- - }
- + sendJDKInternalEvent (SWT.PostExternalEventDispatch);
- }
- void setCurrentCaret (Caret caret) {
- @@ -6001,6 +5960,54 @@ public void syncExec (Runnable runnable) {
- synchronizer.syncExec (runnable);
- }
- +/**
- + * Calls the callable on the user-interface thread at the next reasonable
- + * opportunity, and returns the its result from this method. The thread which
- + * calls this method is suspended until the callable completes.
- + * <p>
- + * Note that at the time the callable is invoked, widgets that have the receiver
- + * as their display may have been disposed. Therefore, it is necessary to check
- + * for this case inside the callable before accessing the widget.
- + * </p>
- + * <p>
- + * Any exception that is thrown from the callable is re-thrown in the calling
- + * thread. Note: The exception retains its original stack trace from the
- + * throwing thread. The call to {@code syncCall} will not be present in the
- + * stack trace.
- + * </p>
- + *
- + * @param callable the code to call on the user-interface thread
- + *
- + * @exception SWTException <code>ERROR_DEVICE_DISPOSED</code> - if the receiver
- + * has been disposed
- + * @exception E An exception that is thrown by the callable on the
- + * user-interface thread, and re-thrown on the calling
- + * thread
- + *
- + * @see #syncExec(Runnable)
- + * @see SwtCallable#call()
- + * @since 3.118
- + */
- +public <T, E extends Exception> T syncCall(SwtCallable<T, E> callable) throws E {
- + Objects.nonNull(callable);
- + @SuppressWarnings("unchecked")
- + T[] t = (T[]) new Object[1];
- + Object[] ex = new Object[1];
- + syncExec(() -> {
- + try {
- + t[0] = callable.call();
- + } catch (Exception e) {
- + ex[0] = e;
- + }
- + });
- + if (ex[0] != null) {
- + @SuppressWarnings("unchecked")
- + E e = (E) ex[0];
- + throw e;
- + }
- + return t[0];
- +}
- +
- static int translateKey (int key) {
- for (int i=0; i<KeyTable.length; i++) {
- if (KeyTable [i] [0] == key) return KeyTable [i] [1];
- @@ -6071,13 +6078,18 @@ boolean scrollProc(long controller, double dx, double dy, long user_data) {
- return false;
- }
- -void focusProc(long controller, long user_data) {
- +void focusProc(long controller, long user_data) {;
- long handle = GTK.gtk_event_controller_get_widget(controller);
- Widget widget = getWidget(handle);
- if (widget != null) widget.focusProc(controller, user_data);
- }
- +void windowActiveProc(long handle, long user_data) {;
- + Widget widget = getWidget(handle);
- + if (widget != null) widget.windowActiveProc(handle, user_data);
- +}
- +
- boolean keyPressReleaseProc(long controller, int keyval, int keycode, int state, long user_data) {
- long handle = GTK.gtk_event_controller_get_widget(controller);
- Widget widget = getWidget(handle);
- @@ -6100,6 +6112,10 @@ void leaveProc(long controller, long user_data) {
- if (widget != null) widget.leaveProc(controller, handle, user_data);
- }
- +void computeSizeProc(long toplevel, long size, long user_data) {
- + //TODO: GTK4 - Could be needed for minimum Size, signal remains connected
- +}
- +
- void activateProc(long action, long parameter, long user_data) {
- Widget widget = getWidget(user_data);
- if(widget == null) return;
- @@ -6221,18 +6237,11 @@ static int _getDeviceZoom (long monitor_num) {
- * if gdk_screen_set_resolution has not been called.
- */
- int dpi = 96;
- - if (GTK.GTK_VERSION >= OS.VERSION(3, 22, 0)) {
- - long display = GDK.gdk_display_get_default();
- - long monitor = GDK.gdk_display_get_monitor_at_point(display, 0, 0);
- - int scale = GDK.gdk_monitor_get_scale_factor(monitor);
- - dpi = dpi * scale;
- - } else {
- - long screen = GDK.gdk_screen_get_default ();
- - dpi = (int) GDK.gdk_screen_get_resolution (screen);
- - if (dpi <= 0) dpi = 96; // gdk_screen_get_resolution returns -1 in case of error
- - int scale = GDK.gdk_screen_get_monitor_scale_factor (screen, (int) monitor_num);
- - dpi = dpi * scale;
- - }
- + long display = GDK.gdk_display_get_default();
- + long monitor = GDK.gdk_display_get_monitor_at_point(display, 0, 0);
- + int scale = GDK.gdk_monitor_get_scale_factor(monitor);
- + dpi = dpi * scale;
- return DPIUtil.mapDPIToZoom (dpi);
- }
- +
- }
- diff --git a/Eclipse-R4_21/SWT.java b/Eclipse-R4_26/SWT.java
- index 35d5860..9783715 100644
- --- a/Eclipse-R4_21/SWT.java
- +++ b/Eclipse-R4_26/SWT.java
- @@ -1020,6 +1020,20 @@ public class SWT {
- */
- public static final int ZoomChanged = 55;
- + /**
- + * The SWT emptiness change event type (value is 56).
- + *
- + * <p>
- + * This event is sent on <code>Tree</code> when the first <code>TreeItem</code> was
- + * added to it (with the <code>detail</code> field set to 0) or the last
- + * <code>TreeItem</code> was removed from it (with the <code>detail</code> field
- + * set to 1).
- + * </p>
- + *
- + * @since 3.118
- + */
- + public static final int EmptinessChanged = 56;
- +
- /* Event Details */
- /**
- @@ -2261,6 +2275,7 @@ public class SWT {
- * <p><b>Used By:</b></p>
- * <ul>
- * <li><code>FormAttachment</code> in a <code>FormLayout</code></li>
- + * <li><code>BoderData</code> in a <code>BoderLayout</code></li>
- * </ul>
- */
- public static final int TOP = UP;
- @@ -2285,6 +2300,7 @@ public class SWT {
- * <ul>
- * <li><code>FormAttachment</code> in a <code>FormLayout</code></li>
- * <li><code>TabFolder</code></li>
- + * <li><code>BoderData</code> in a <code>BoderLayout</code></li>
- * </ul>
- */
- public static final int BOTTOM = DOWN;
- @@ -2315,6 +2331,10 @@ public class SWT {
- * This constant can also be used to representing the left keyboard
- * location during a key event.
- * </p>
- + * <p><b>Used By:</b></p>
- + * <ul>
- + * <li><code>BoderData</code> in a <code>BoderLayout</code></li>
- + * </ul>
- */
- public static final int LEFT = LEAD;
- @@ -2344,6 +2364,10 @@ public class SWT {
- * This constant can also be used to representing the right keyboard
- * location during a key event.
- * </p>
- + * <p><b>Used By:</b></p>
- + * <ul>
- + * <li><code>BoderData</code> in a <code>BoderLayout</code></li>
- + * </ul>
- */
- public static final int RIGHT = TRAIL;
- @@ -2355,6 +2379,7 @@ public class SWT {
- * <li><code>Label</code></li>
- * <li><code>TableColumn</code></li>
- * <li><code>FormAttachment</code> in a <code>FormLayout</code></li>
- + * <li><code>BoderData</code> in a <code>BoderLayout</code></li>
- * </ul>
- */
- public static final int CENTER = 1 << 24;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement