Advertisement
Guest User

Eclipse-Diff_4.21-4.26.log

a guest
Dec 15th, 2022
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 50.69 KB | None | 0 0
  1. diff --git a/Eclipse-R4_21/Control.java b/Eclipse-R4_26/Control.java
  2. index bfedd8d..1155bdc 100644
  3. --- a/Eclipse-R4_21/Control.java
  4. +++ b/Eclipse-R4_26/Control.java
  5. @@ -57,6 +57,8 @@ public abstract class Control extends Widget implements Drawable {
  6. static final boolean DISABLE_EMOJI = Boolean.getBoolean("SWT_GTK_INPUT_HINT_NO_EMOJI");
  7.  
  8. long fixedHandle;
  9. + long firstFixedHandle = 0;
  10. + long keyController;
  11. long redrawWindow, enableWindow, provider;
  12. int drawCount, backgroundAlpha = 255;
  13. long dragGesture, zoomGesture, rotateGesture, panGesture;
  14. @@ -111,7 +113,6 @@ public abstract class Control extends Widget implements Drawable {
  15. * is currently pressed or released for DND.
  16. */
  17. static boolean mouseDown;
  18. - boolean dragBegun;
  19.  
  20. /**
  21. * Flag to check the scale factor upon the first drawing of this Control.
  22. @@ -432,8 +433,9 @@ void hookEvents () {
  23.  
  24. private void hookKeyboardAndFocusSignals(long focusHandle) {
  25. if (GTK.GTK4) {
  26. - long keyController = GTK4.gtk_event_controller_key_new();
  27. + keyController = GTK4.gtk_event_controller_key_new();
  28. GTK4.gtk_widget_add_controller(focusHandle, keyController);
  29. + GTK.gtk_event_controller_set_propagation_phase(keyController, GTK.GTK_PHASE_CAPTURE);
  30. OS.g_signal_connect(keyController, OS.key_pressed, display.keyPressReleaseProc, KEY_PRESSED);
  31. OS.g_signal_connect(keyController, OS.key_released, display.keyPressReleaseProc, KEY_RELEASED);
  32.  
  33. @@ -882,11 +884,7 @@ void forceResize () {
  34. gtk_widget_get_preferred_size (topHandle, requisition);
  35. GtkAllocation allocation = new GtkAllocation ();
  36. GTK.gtk_widget_get_allocation(topHandle, allocation);
  37. - if (GTK.GTK4) {
  38. - GTK4.gtk_widget_size_allocate (topHandle, allocation, -1);
  39. - } else {
  40. - GTK3.gtk_widget_size_allocate (topHandle, allocation);
  41. - }
  42. + gtk_widget_size_allocate(topHandle, allocation, -1);
  43. }
  44.  
  45. /**
  46. @@ -1070,7 +1068,7 @@ Point resizeCalculationsGTK3 (long widget, int width, int height) {
  47. }
  48.  
  49. int setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
  50. - // bug in GTK2 crashes JVM, in GTK3 the new shell only. See bug 472743
  51. + // bug in GTK3 the crashes new shell only. See bug 472743
  52. width = Math.min(width, (2 << 14) - 1);
  53. height = Math.min(height, (2 << 14) - 1);
  54.  
  55. @@ -1153,11 +1151,7 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
  56. Control focusControl = display.getFocusControl();
  57. GTK.gtk_widget_show(topHandle);
  58. gtk_widget_get_preferred_size (topHandle, requisition);
  59. - if (GTK.GTK4) {
  60. - GTK4.gtk_widget_size_allocate (topHandle, allocation, -1);
  61. - } else {
  62. - GTK3.gtk_widget_size_allocate (topHandle, allocation);
  63. - }
  64. + gtk_widget_size_allocate(topHandle, allocation, -1);
  65. GTK.gtk_widget_hide(topHandle);
  66. /* Bug 540002: Showing and hiding widget causes original focused control to loose focus,
  67. * Reset focus to original focused control after dealing with allocation.
  68. @@ -2676,36 +2670,36 @@ boolean dragDetect (int button, int count, int stateMask, int x, int y) {
  69. }
  70.  
  71. boolean dragDetect (int x, int y, boolean filter, boolean dragOnTimeout, boolean [] consume) {
  72. - boolean dragging = false;
  73. /*
  74. * Feature in GTK: In order to support both X.11/Wayland, GTKGestures are used
  75. * as of GTK3.14 in order to acquire mouse position offsets to decide on dragging.
  76. * See Bug 503431.
  77. */
  78. if (!OS.isX11()) { // Wayland
  79. + // Don't drag if mouse is not down. This condition is not as
  80. + // trivial as it seems, see Bug 541635 where drag is tested
  81. + // after drag already completed and mouse is released.
  82. + if (!mouseDown) {
  83. + return false;
  84. + }
  85. +
  86. double [] offsetX = new double[1];
  87. double [] offsetY = new double [1];
  88. double [] startX = new double[1];
  89. double [] startY = new double [1];
  90. - if (GTK.gtk_gesture_drag_get_start_point(dragGesture, startX, startY)) {
  91. - GTK.gtk_gesture_drag_get_offset(dragGesture, offsetX, offsetY);
  92. - if (GTK3.gtk_drag_check_threshold(handle, (int)startX[0], (int) startY[0], (int) startX[0]
  93. - + (int) offsetX[0], (int) startY[0] + (int) offsetY[0])) {
  94. - dragging = true;
  95. - }
  96. - } else {
  97. + if (!GTK.gtk_gesture_drag_get_start_point(dragGesture, startX, startY)) {
  98. return false;
  99. }
  100. - // Block until mouse was released or drag was detected, see Bug 515396.
  101. - while (true) {
  102. - if (!mouseDown) {
  103. - return false;
  104. - }
  105. - if (dragBegun) {
  106. - return true;
  107. - }
  108. +
  109. + GTK.gtk_gesture_drag_get_offset(dragGesture, offsetX, offsetY);
  110. + if (GTK3.gtk_drag_check_threshold(handle, (int)startX[0], (int) startY[0], (int) startX[0]
  111. + + (int) offsetX[0], (int) startY[0] + (int) offsetY[0])) {
  112. + return true;
  113. }
  114. +
  115. + return false;
  116. } else {
  117. + boolean dragging = false;
  118. boolean quit = false;
  119. //428852 DND workaround for GTK3.
  120. //Gtk3 no longer sends motion events on the same control during thread sleep
  121. @@ -2806,8 +2800,8 @@ boolean dragDetect (int x, int y, boolean filter, boolean dragOnTimeout, boolean
  122. }
  123. gdk_event_free (eventPtr);
  124. }
  125. + return dragging;
  126. }
  127. - return dragging;
  128. }
  129.  
  130. boolean filterKey (long event) {
  131. @@ -3236,29 +3230,19 @@ public Menu getMenu () {
  132. public Monitor getMonitor () {
  133. checkWidget ();
  134. Monitor[] monitors = display.getMonitors ();
  135. - if (GTK.GTK_VERSION >= OS.VERSION(3, 22, 0)) {
  136. - long display = GDK.gdk_display_get_default ();
  137. - if (display != 0) {
  138. - long monitor;
  139. - if (GTK.GTK4) {
  140. - monitor = GDK.gdk_display_get_monitor_at_surface(display, paintSurface ());
  141. - } else {
  142. - monitor = GDK.gdk_display_get_monitor_at_window(display, paintWindow ());
  143. - }
  144. - long toCompare;
  145. - for (int i = 0; i < monitors.length; i++) {
  146. - toCompare = GDK.gdk_display_get_monitor(display, i);
  147. - if (toCompare == monitor) {
  148. - return monitors[i];
  149. - }
  150. - }
  151. + long displayHandle = GDK.gdk_display_get_default ();
  152. + if (displayHandle != 0) {
  153. + long monitor;
  154. + if (GTK.GTK4) {
  155. + monitor = GDK.gdk_display_get_monitor_at_surface(displayHandle, paintSurface ());
  156. + } else {
  157. + monitor = GDK.gdk_display_get_monitor_at_window(displayHandle, paintWindow ());
  158. }
  159. - } else {
  160. - long screen = GDK.gdk_screen_get_default ();
  161. - if (screen != 0) {
  162. - int monitorNumber = GDK.gdk_screen_get_monitor_at_window (screen, paintWindow ());
  163. - if (monitorNumber >= 0 && monitorNumber < monitors.length) {
  164. - return monitors [monitorNumber];
  165. + long toCompare;
  166. + for (int i = 0; i < monitors.length; i++) {
  167. + toCompare = GDK.gdk_display_get_monitor(displayHandle, i);
  168. + if (toCompare == monitor) {
  169. + return monitors[i];
  170. }
  171. }
  172. }
  173. @@ -3444,7 +3428,6 @@ void gtk_style_context_get_border (long context, int state, GtkBorder padding) {
  174. @Override
  175. void gtk_gesture_press_event (long gesture, int n_press, double x, double y, long event) {
  176. mouseDown = true;
  177. - dragBegun = false;
  178.  
  179. int eventButton = GDK.gdk_button_event_get_button(event);
  180. int eventTime = GDK.gdk_event_get_time(event);
  181. @@ -3488,7 +3471,6 @@ long gtk_button_press_event (long widget, long event) {
  182.  
  183. long gtk_button_press_event (long widget, long event, boolean sendMouseDown) {
  184. mouseDown = true;
  185. - dragBegun = false;
  186.  
  187. double [] eventX = new double [1];
  188. double [] eventY = new double [1];
  189. @@ -3630,6 +3612,18 @@ long gtk_commit (long imcontext, long text) {
  190.  
  191. @Override
  192. void gtk4_enter_event(long controller, double x, double y, long event) {
  193. + /*
  194. + * Set tool tip for this shell, and also null tooltip for shell
  195. + * if control being entered does not have a tooltip text set.
  196. + */
  197. + byte [] buffer = null;
  198. + if (toolTipText != null && toolTipText.length() != 0) {
  199. + char [] chars = fixMnemonic (toolTipText, false, true);
  200. + buffer = Converter.wcsToMbcs (chars, true);
  201. + }
  202. + long toolHandle = getShell().handle;
  203. + GTK.gtk_widget_set_tooltip_text (toolHandle, buffer);
  204. +
  205. if (display.currentControl == this) return;
  206.  
  207. // Disconnect previous current Control and send MouseExit event to it
  208. @@ -3932,6 +3926,25 @@ void gtk4_focus_enter_event(long controller, long event) {
  209. sendFocusEvent(SWT.FocusIn);
  210. }
  211.  
  212. +@Override
  213. +void gtk4_focus_window_event(long handle, long event) {
  214. + super.gtk4_focus_window_event(handle, event);
  215. +
  216. + if(firstFixedHandle == 0) {
  217. + long child = handle;
  218. + //3rd child of shell will be SWTFixed
  219. + for(int i = 0; i<3; i++) {
  220. + child = GTK4.gtk_widget_get_first_child(child);
  221. + }
  222. + firstFixedHandle = child != 0 ? child:0;
  223. + }
  224. +
  225. + if(firstFixedHandle !=0 && GTK.gtk_widget_has_focus(firstFixedHandle)) {
  226. + if(event == SWT.FocusIn)sendFocusEvent(SWT.FocusIn);
  227. + else sendFocusEvent(SWT.FocusOut);
  228. + }
  229. +}
  230. +
  231. @Override
  232. long gtk_focus_out_event (long widget, long event) {
  233. // widget could be disposed at this point
  234. @@ -4093,10 +4106,6 @@ long gtk_mnemonic_activate (long widget, long arg1) {
  235.  
  236. @Override
  237. void gtk4_motion_event(long controller, double x, double y, long event) {
  238. - if (mouseDown) {
  239. - dragBegun = true;
  240. - }
  241. -
  242. if (this == display.currentControl && (hooks(SWT.MouseHover) || filters(SWT.MouseHover))) {
  243. display.addMouseHoverTimeout(handle);
  244. }
  245. @@ -4127,9 +4136,6 @@ void gtk4_motion_event(long controller, double x, double y, long event) {
  246. @Override
  247. long gtk_motion_notify_event (long widget, long event) {
  248. int result;
  249. - if (mouseDown) {
  250. - dragBegun = true;
  251. - }
  252.  
  253. double[] eventX = new double[1];
  254. double[] eventY = new double[1];
  255. @@ -4831,7 +4837,13 @@ void destroyWidget() {
  256. if (GTK.GTK4) {
  257. // Remove widget from hierarchy by removing it from parent container
  258. if (parent != null) {
  259. - OS.swt_fixed_remove(parent.parentingHandle(), fixedHandle);
  260. + long currHandle = topHandle();
  261. + if(GTK.GTK_IS_WINDOW(currHandle)) {
  262. + GTK4.gtk_window_destroy(currHandle);
  263. + }
  264. + else {
  265. + OS.swt_fixed_remove(parent.parentingHandle(), fixedHandle);
  266. + }
  267. }
  268. releaseHandle();
  269. } else {
  270. @@ -5007,7 +5019,13 @@ boolean sendMouseEvent (int type, int button, int count, int detail, boolean sen
  271. sendOrPost(SWT.MouseDown, mouseDownEvent);
  272. }
  273. }
  274. - return true;
  275. + /* This checks for Wayland, a previous MouseDown || MouseMove in the
  276. + * dragDetectionQueue and it checks if the current event is MouseMove
  277. + * This will prevent them from not being queued, which caused
  278. + * Bug 576215 - [Wayland] Mouse events not received as on other platforms.
  279. + * In x11 this will always return true as before.
  280. + */
  281. + if( (OS.isX11() || (dragDetectionQueue == null) || (type != SWT.MouseMove)) ) return true;
  282. }
  283. Event event = new Event ();
  284. event.time = time;
  285. @@ -5039,7 +5057,6 @@ boolean sendMouseEvent (int type, int button, int count, int detail, boolean sen
  286.  
  287. /**
  288. * Bug 510446:
  289. - * In the original gtk2 DnD architecture, Drag detection was done in mouseDown.
  290. * For Wayland support, Drag detection is now done in mouseMove (as does gtk internally).
  291. *
  292. * However, traditionally external widgets (e.g StyledText or non-SWT widgets) expect to
  293. @@ -5052,7 +5069,7 @@ boolean sendMouseEvent (int type, int button, int count, int detail, boolean sen
  294. * - To ensure we follow 'send/post' contract as per parameter, we
  295. * temporarily utilize event.data to hold send/post flag.
  296. * There's also logic in place such that mouseDown/mouseMotion is always sent before mouseUp.
  297. - * - On Gtk2, mouseMove is sent during DnD. On Gtk3x11 it's not due to hacky implementation of DnD.
  298. + * - On Gtk3x11 it's not due to hacky implementation of DnD.
  299. * On Wayland mouseMove is once again sent during DnD as per improved architecture.
  300. */
  301. event.data = Boolean.valueOf(send);
  302. @@ -5281,21 +5298,6 @@ public void setBackgroundImage (Image image) {
  303. }
  304.  
  305. void setBackgroundSurface (Image image) {
  306. - if (GTK.GTK_VERSION >= OS.VERSION(3, 22, 0)) {
  307. - // gdk_window_set_background_pattern() deprecated in GTK3.22+
  308. - return;
  309. - }
  310. -
  311. - long window = GTK3.gtk_widget_get_window (paintHandle ());
  312. - if (window != 0) {
  313. - if (image.surface != 0) {
  314. - long pattern = Cairo.cairo_pattern_create_for_surface(image.surface);
  315. - if (pattern == 0) SWT.error(SWT.ERROR_NO_HANDLES);
  316. - Cairo.cairo_pattern_set_extend(pattern, Cairo.CAIRO_EXTEND_REPEAT);
  317. - GDK.gdk_window_set_background_pattern(window, pattern);
  318. - Cairo.cairo_pattern_destroy(pattern);
  319. - }
  320. - }
  321. }
  322.  
  323. /**
  324. @@ -5787,7 +5789,6 @@ void setOrientation (boolean create) {
  325. /**
  326. * Sets the orientation of the receiver, which must be one
  327. * of the constants <code>SWT.LEFT_TO_RIGHT</code> or <code>SWT.RIGHT_TO_LEFT</code>.
  328. - * <p>
  329. *
  330. * @param orientation new orientation style
  331. *
  332. @@ -5875,11 +5876,7 @@ public boolean setParent (Composite parent) {
  333. allocation.y = y;
  334. allocation.width = width;
  335. allocation.height = height;
  336. - if (GTK.GTK4) {
  337. - GTK4.gtk_widget_size_allocate (topHandle, allocation, -1);
  338. - } else {
  339. - GTK3.gtk_widget_size_allocate (topHandle, allocation);
  340. - }
  341. + gtk_widget_size_allocate(topHandle, allocation, -1);
  342. this.parent = parent;
  343. setZOrder (null, false, true);
  344. reskin (SWT.ALL);
  345. @@ -5955,10 +5952,6 @@ public void setRedraw (boolean redraw) {
  346. GDK.GDK_BUTTON_MOTION_MASK | GDK.GDK_BUTTON1_MOTION_MASK |
  347. GDK.GDK_BUTTON2_MOTION_MASK | GDK.GDK_BUTTON3_MOTION_MASK;
  348. GDK.gdk_window_set_events (window, GDK.gdk_window_get_events (window) & ~mouseMask);
  349. - // No gdk_surface_set_background_pattern() on GTK4.
  350. - if (GTK.GTK_VERSION < OS.VERSION(3, 22, 0)) {
  351. - GDK.gdk_window_set_background_pattern(redrawWindow, 0);
  352. - }
  353. GDK.gdk_window_show (redrawWindow);
  354. }
  355. }
  356. @@ -6779,10 +6772,11 @@ boolean traverseMnemonic (char key) {
  357. public void update () {
  358. checkWidget ();
  359. update (false, true);
  360. +
  361. }
  362.  
  363. void update (boolean all, boolean flush) {
  364. -// checkWidget();
  365. + if(GTK.GTK4) GTK.gtk_widget_queue_draw(handle);
  366. if (!GTK.gtk_widget_get_visible (topHandle ())) return;
  367. if (!GTK.gtk_widget_get_realized (handle)) return;
  368. long window = paintWindow ();
  369. diff --git a/Eclipse-R4_21/DPIUtil.java b/Eclipse-R4_26/DPIUtil.java
  370. index f755898..874339b 100644
  371. --- a/Eclipse-R4_21/DPIUtil.java
  372. +++ b/Eclipse-R4_26/DPIUtil.java
  373. @@ -1,5 +1,5 @@
  374. /*******************************************************************************
  375. - * Copyright (c) 2017 IBM Corporation and others.
  376. + * Copyright (c) 2022 IBM Corporation and others.
  377. *
  378. * This program and the accompanying materials
  379. * are made available under the terms of the Eclipse Public License 2.0
  380. @@ -10,6 +10,7 @@
  381. *
  382. * Contributors:
  383. * IBM Corporation - initial API and implementation
  384. + * Daniel Kruegler - #420 - [High DPI] "swt.autoScale" should add new "half" option
  385. *******************************************************************************/
  386. package org.eclipse.swt.internal;
  387.  
  388. @@ -54,6 +55,9 @@ public class DPIUtil {
  389. * generally rounded down (e.g. at 150%, will use 100%), unless close to
  390. * the next integer multiple (currently at 175%, will use 200%).</li>
  391. * <li><b>integer200</b>: like <b>integer</b>, but the maximal zoom level is 200%.</li>
  392. + * <li><b>half</b>: deviceZoom depends on the current display resolution,
  393. + * but only uses integer multiples of 50%. The detected native zoom is
  394. + * rounded to the closest permissible value, with tie-breaker towards even.</li>
  395. * <li><b>quarter</b>: deviceZoom depends on the current display resolution,
  396. * but only uses integer multiples of 25%. The detected native zoom is
  397. * rounded to the closest permissible value.</li>
  398. @@ -456,8 +460,13 @@ public static int getZoomForAutoscaleProperty (int nativeDeviceZoom) {
  399. if (autoScaleValue != null) {
  400. if ("false".equalsIgnoreCase (autoScaleValue)) {
  401. zoom = 100;
  402. + } else if ("half".equalsIgnoreCase (autoScaleValue)) {
  403. + // Math.round rounds 125->150 and 175->200,
  404. + // Math.rint rounds 125->100 and 175->200 matching
  405. + // "integer200"
  406. + zoom = (int) Math.rint(nativeDeviceZoom / 50d) * 50;
  407. } else if ("quarter".equalsIgnoreCase (autoScaleValue)) {
  408. - zoom = (int) (Math.round (nativeDeviceZoom / 25f) * 25);
  409. + zoom = Math.round(nativeDeviceZoom / 25f) * 25;
  410. } else if ("exact".equalsIgnoreCase (autoScaleValue)) {
  411. zoom = nativeDeviceZoom;
  412. } else {
  413. @@ -471,10 +480,6 @@ public static int getZoomForAutoscaleProperty (int nativeDeviceZoom) {
  414. }
  415. if (zoom == 0) { // || "integer".equalsIgnoreCase (value) || "integer200".equalsIgnoreCase (value)
  416. zoom = Math.max ((nativeDeviceZoom + 25) / 100 * 100, 100);
  417. - if (!"integer".equalsIgnoreCase(autoScaleValue)) {
  418. - // integer200, or default
  419. - zoom = Math.min (zoom, 200);
  420. - }
  421. }
  422. return zoom;
  423. }
  424. diff --git a/Eclipse-R4_21/Display.java b/Eclipse-R4_26/Display.java
  425. index 74ea637..1bd1186 100644
  426. --- a/Eclipse-R4_21/Display.java
  427. +++ b/Eclipse-R4_26/Display.java
  428. @@ -1,5 +1,5 @@
  429. /*******************************************************************************
  430. - * Copyright (c) 2000, 2020 IBM Corporation and others.
  431. + * Copyright (c) 2000, 2022 IBM Corporation and others.
  432. *
  433. * This program and the accompanying materials
  434. * are made available under the terms of the Eclipse Public License 2.0
  435. @@ -10,6 +10,7 @@
  436. *
  437. * Contributors:
  438. * IBM Corporation - initial API and implementation
  439. + * Christoph Läubrich - Issue #64 - Integration with java.util.concurrent framework
  440. *******************************************************************************/
  441. package org.eclipse.swt.widgets;
  442.  
  443. @@ -19,6 +20,7 @@ import java.lang.reflect.*;
  444. import java.net.*;
  445. import java.util.*;
  446. import java.util.Map.*;
  447. +import java.util.concurrent.*;
  448. import java.util.function.*;
  449. import java.util.regex.*;
  450. import java.util.regex.Pattern;
  451. @@ -111,7 +113,7 @@ import org.eclipse.swt.internal.gtk4.*;
  452. * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
  453. * @noextend This class is not intended to be subclassed by clients.
  454. */
  455. -public class Display extends Device {
  456. +public class Display extends Device implements Executor {
  457.  
  458. static boolean strictChecks = System.getProperty("org.eclipse.swt.internal.gtk.enableStrictChecks") != null;
  459.  
  460. @@ -127,16 +129,18 @@ public class Display extends Device {
  461. long fds;
  462. int allocated_nfds;
  463. boolean wake;
  464. + boolean windowSizeSet;
  465. int [] max_priority = new int [1], timeout = new int [1];
  466. Callback eventCallback;
  467. long eventProc, windowProc2, windowProc3, windowProc4, windowProc5, windowProc6;
  468. long changeValueProc;
  469. - long snapshotDrawProc, keyPressReleaseProc, focusProc, enterMotionProc, leaveProc,
  470. + long snapshotDrawProc, keyPressReleaseProc, focusProc, windowActiveProc, enterMotionProc, leaveProc,
  471. scrollProc, resizeProc, activateProc, gesturePressReleaseProc;
  472. long notifyProc;
  473. + long computeSizeProc;
  474. Callback windowCallback2, windowCallback3, windowCallback4, windowCallback5, windowCallback6;
  475. Callback changeValue;
  476. - Callback snapshotDraw, keyPressReleaseCallback, focusCallback, enterMotionCallback,
  477. + Callback snapshotDraw, keyPressReleaseCallback, focusCallback, windowActiveCallback, enterMotionCallback, computeSizeCallback,
  478. scrollCallback, leaveCallback, resizeCallback, activateCallback, gesturePressReleaseCallback;
  479. Callback notifyCallback;
  480. EventTable eventTable, filterTable;
  481. @@ -220,19 +224,6 @@ public class Display extends Device {
  482. SessionManagerListener sessionManagerListener;
  483. Runnable [] disposeList;
  484.  
  485. - /*
  486. - * DBus objects to be freed upong Display release. Only public for use in
  487. - * other areas of SWT (i.e. WebKit). See bug 540060.
  488. - */
  489. - /** @noreference */
  490. - public ArrayList<Long> dBusServers = new ArrayList<>();
  491. - /** @noreference */
  492. - public ArrayList<Long> dBusAuthObservers = new ArrayList<>();
  493. - /** @noreference */
  494. - public ArrayList<Long> dBusGUIDS = new ArrayList<>();
  495. - /** @noreference */
  496. - public ArrayList<Long> dBusConnections = new ArrayList<>();
  497. -
  498. /* Deferred Layout list */
  499. Composite[] layoutDeferred;
  500. int layoutDeferredCount;
  501. @@ -507,7 +498,7 @@ public class Display extends Device {
  502.  
  503. /* Multiple Displays. */
  504. static Display Default;
  505. - static Display [] Displays = new Display [4];
  506. + static Display [] Displays = new Display [1];
  507.  
  508. /* Skinning support */
  509. Widget [] skinList = new Widget [GROW_SIZE];
  510. @@ -526,7 +517,7 @@ public class Display extends Device {
  511.  
  512. /* Minimum GTK version requirement */
  513. static final int GTK3_MAJOR = 3;
  514. - static final int GTK3_MINOR = 20;
  515. + static final int GTK3_MINOR = 22;
  516. static final int GTK3_MICRO = 0;
  517.  
  518. /* Latest GTK version support */
  519. @@ -859,7 +850,7 @@ void addPopup (Menu menu) {
  520.  
  521. void addSkinnableWidget (Widget widget) {
  522. if (skinCount >= skinList.length) {
  523. - Widget[] newSkinWidgets = new Widget [skinList.length + GROW_SIZE];
  524. + Widget[] newSkinWidgets = new Widget [(skinList.length + 1) * 3 / 2];
  525. System.arraycopy (skinList, 0, newSkinWidgets, 0, skinList.length);
  526. skinList = newSkinWidgets;
  527. }
  528. @@ -940,6 +931,49 @@ public void asyncExec (Runnable runnable) {
  529. }
  530. }
  531.  
  532. +/**
  533. + * Executes the given runnable in the user-interface thread of this Display.
  534. + * <ul>
  535. + * <li>If the calling thread is the user-interface thread of this display it is
  536. + * executed immediately and the method returns after the command has run, as with
  537. + * the method {@link Display#syncExec(Runnable)}.</li>
  538. + * <li>In all other cases the <code>run()</code> method of the runnable is
  539. + * asynchronously executed as with the method
  540. + * {@link Display#asyncExec(Runnable)} at the next reasonable opportunity. The
  541. + * caller of this method continues to run in parallel, and is not notified when
  542. + * the runnable has completed.</li>
  543. + * </ul>
  544. + * <p>
  545. + * This can be used in cases where one want to execute some piece of code that
  546. + * should be guaranteed to run in the user-interface thread regardless of the
  547. + * current thread.
  548. + * </p>
  549. + *
  550. + * <p>
  551. + * Note that at the time the runnable is invoked, widgets that have the receiver
  552. + * as their display may have been disposed. Therefore, it is advised to check
  553. + * for this case inside the runnable before accessing the widget.
  554. + * </p>
  555. + *
  556. + * @param runnable the runnable to execute in the user-interface thread, never
  557. + * <code>null</code>
  558. + * @throws RejectedExecutionException if this task cannot be accepted for
  559. + * execution
  560. + * @throws NullPointerException if runnable is null
  561. + */
  562. +@Override
  563. +public void execute(Runnable runnable) {
  564. + Objects.requireNonNull(runnable);
  565. + if (isDisposed()) {
  566. + throw new RejectedExecutionException(new SWTException (SWT.ERROR_WIDGET_DISPOSED, null));
  567. + }
  568. + if (thread == Thread.currentThread()) {
  569. + syncExec(runnable);
  570. + } else {
  571. + asyncExec(runnable);
  572. + }
  573. +}
  574. +
  575. /**
  576. * Causes the system hardware to emit a short sound
  577. * (if it supports this capability).
  578. @@ -1156,6 +1190,7 @@ void createDisplay (DeviceData data) {
  579. GDK.gdk_threads_enter ();
  580. }
  581. boolean init;
  582. + windowSizeSet = false;
  583. if (GTK.GTK4) {
  584. init = GTK4.gtk_init_check();
  585. } else {
  586. @@ -1376,7 +1411,7 @@ Image createImage (String name) {
  587. OS.g_object_unref(paintable);
  588. } else {
  589. long iconTheme = GTK3.gtk_icon_theme_get_default();
  590. - pixbuf = GTK3.gtk_icon_theme_load_icon(iconTheme, buffer, 48, GTK.GTK_ICON_LOOKUP_FORCE_SIZE, 0);
  591. + pixbuf = GTK3.gtk_icon_theme_load_icon(iconTheme, buffer, 48, GTK.GTK_ICON_LOOKUP_FORCE_SIZE|GTK.GTK_ICON_LOOKUP_FORCE_REGULAR, 0);
  592. }
  593.  
  594. if (pixbuf == 0) return null;
  595. @@ -1765,45 +1800,29 @@ Rectangle getBoundsInPixels () {
  596. checkDevice ();
  597. Rectangle bounds = new Rectangle(0, 0, 0, 0);
  598. int maxWidth = 0, maxHeight = 0;
  599. - if (GTK.GTK_VERSION >= OS.VERSION(3, 22, 0)) {
  600. - long display = GDK.gdk_display_get_default();
  601. - int monitorCount = 0;
  602. - long monitorList = 0;
  603. - if (GTK.GTK4) {
  604. - monitorList = GDK.gdk_display_get_monitors(display);
  605. - monitorCount = OS.g_list_model_get_n_items(monitorList);
  606. - } else {
  607. - monitorCount = GDK.gdk_display_get_n_monitors(display);
  608. - }
  609. -
  610. - if (monitorCount > 0) {
  611. - for (int i = 0; i < monitorCount; i++) {
  612. - long monitor = GTK.GTK4 ? OS.g_list_model_get_item(monitorList, i) : GDK.gdk_display_get_monitor(display, i);
  613. - GdkRectangle geometry = new GdkRectangle();
  614. - GDK.gdk_monitor_get_geometry(monitor, geometry);
  615. + long display = GDK.gdk_display_get_default();
  616. + int monitorCount = 0;
  617. + long monitorList = 0;
  618. + if (GTK.GTK4) {
  619. + monitorList = GDK.gdk_display_get_monitors(display);
  620. + monitorCount = OS.g_list_model_get_n_items(monitorList);
  621. + } else {
  622. + monitorCount = GDK.gdk_display_get_n_monitors(display);
  623. + }
  624.  
  625. - if ((geometry.x + geometry.width) > maxWidth) maxWidth = geometry.x + geometry.width;
  626. - if ((geometry.y + geometry.height) > maxHeight) maxHeight = geometry.y + geometry.height;
  627. - }
  628. + if (monitorCount > 0) {
  629. + for (int i = 0; i < monitorCount; i++) {
  630. + long monitor = GTK.GTK4 ? OS.g_list_model_get_item(monitorList, i) : GDK.gdk_display_get_monitor(display, i);
  631. + GdkRectangle geometry = new GdkRectangle();
  632. + GDK.gdk_monitor_get_geometry(monitor, geometry);
  633.  
  634. - bounds.width = maxWidth;
  635. - bounds.height = maxHeight;
  636. - return bounds;
  637. - }
  638. - } else {
  639. - long screen = GDK.gdk_screen_get_default();
  640. - int monitorCount = GDK.gdk_screen_get_n_monitors(screen);
  641. - if (monitorCount > 0) {
  642. - for (int i = 0; i < monitorCount; i++) {
  643. - GdkRectangle dest = new GdkRectangle ();
  644. - GDK.gdk_screen_get_monitor_geometry (screen, i, dest);
  645. - if ((dest.x + dest.width) > maxWidth) maxWidth = dest.x + dest.width;
  646. - if ((dest.y + dest.height) > maxHeight) maxHeight = dest.y + dest.height;
  647. - }
  648. - bounds.width = maxWidth;
  649. - bounds.height = maxHeight;
  650. - return bounds;
  651. + if ((geometry.x + geometry.width) > maxWidth) maxWidth = geometry.x + geometry.width;
  652. + if ((geometry.y + geometry.height) > maxHeight) maxHeight = geometry.y + geometry.height;
  653. }
  654. +
  655. + bounds.width = maxWidth;
  656. + bounds.height = maxHeight;
  657. + return bounds;
  658. }
  659.  
  660. if (GTK.GTK4) {
  661. @@ -2574,10 +2593,6 @@ int getLastEventTime () {
  662. return lastEventTime;
  663. }
  664.  
  665. -int getMessageCount () {
  666. - return synchronizer.getMessageCount ();
  667. -}
  668. -
  669. Dialog getModalDialog () {
  670. return modalDialog;
  671. }
  672. @@ -2588,9 +2603,6 @@ Dialog getModalDialog () {
  673. * windows. See http://freedesktop.org/Standards/wm-spec.
  674. */
  675. Rectangle getWorkArea() {
  676. - if (OS.IsWin32) {
  677. - return null;
  678. - }
  679. byte[] name = Converter.wcsToMbcs ("_NET_WORKAREA", true); //$NON-NLS-1$
  680. long atom = GDK.gdk_atom_intern (name, true);
  681. if (atom == GDK.GDK_NONE) return null;
  682. @@ -2604,11 +2616,11 @@ Rectangle getWorkArea() {
  683. Rectangle result = null;
  684. if (data [0] != 0) {
  685. if (actualLength [0] == 16) {
  686. - int values [] = new int [4];
  687. + int[] values = new int [4];
  688. C.memmove (values, data[0], 16);
  689. result = new Rectangle (values [0],values [1],values [2],values [3]);
  690. } else if (actualLength [0] == 32) {
  691. - long values [] = new long [4];
  692. + long[] values = new long [4];
  693. C.memmove (values, data[0], 32);
  694. result = new Rectangle ((int)values [0],(int)values [1],(int)values [2],(int)values [3]);
  695. }
  696. @@ -2628,77 +2640,47 @@ public Monitor[] getMonitors() {
  697. checkDevice();
  698. Monitor[] monitors = null;
  699. Rectangle workArea = DPIUtil.autoScaleDown(getWorkArea ());
  700. - if (GTK.GTK_VERSION >= OS.VERSION(3, 22, 0)) {
  701. - long display = GDK.gdk_display_get_default();
  702. - if (display != 0) {
  703. - int monitorCount;
  704. - long monitorList = 0;
  705. - if (GTK.GTK4) {
  706. - monitorList = GDK.gdk_display_get_monitors(display);
  707. - monitorCount = OS.g_list_model_get_n_items(monitorList);
  708. - } else {
  709. - monitorCount = GDK.gdk_display_get_n_monitors(display);
  710. - }
  711. -
  712. - if (monitorCount > 0) {
  713. - monitors = new Monitor[monitorCount];
  714. - GdkRectangle geometry = new GdkRectangle();
  715. - for (int i = 0; i < monitorCount; i++) {
  716. - long gdkMonitor = GTK.GTK4 ? OS.g_list_model_get_item(monitorList, i) : GDK.gdk_display_get_monitor(display, i);
  717. - GDK.gdk_monitor_get_geometry(gdkMonitor, geometry);
  718. -
  719. - Monitor monitor = new Monitor();
  720. - monitor.handle = gdkMonitor;
  721. - monitor.x = DPIUtil.autoScaleDown(geometry.x);
  722. - monitor.y = DPIUtil.autoScaleDown(geometry.y);
  723. - monitor.width = DPIUtil.autoScaleDown(geometry.width);
  724. - monitor.height = DPIUtil.autoScaleDown(geometry.height);
  725. - if (!OS.isX11()) {
  726. - int scaleFactor = (int) GDK.gdk_monitor_get_scale_factor(gdkMonitor);
  727. - monitor.zoom = scaleFactor * 100;
  728. - } else {
  729. - monitor.zoom = Display._getDeviceZoom(monitor.handle);
  730. - }
  731. -
  732. - /* workarea was defined in GTK 3.4. If present, it will return the best results
  733. - * since it takes into account per-monitor trim. Not available in GTK4.
  734. - */
  735. - if (!GTK.GTK4) GDK.gdk_monitor_get_workarea(gdkMonitor, geometry);
  736. - monitor.clientX = DPIUtil.autoScaleDown(geometry.x);
  737. - monitor.clientY = DPIUtil.autoScaleDown(geometry.y);
  738. - monitor.clientWidth = DPIUtil.autoScaleDown(geometry.width);
  739. - monitor.clientHeight = DPIUtil.autoScaleDown(geometry.height);
  740. -
  741. - monitors[i] = monitor;
  742. - }
  743. - }
  744. + long display = GDK.gdk_display_get_default();
  745. + if (display != 0) {
  746. + int monitorCount;
  747. + long monitorList = 0;
  748. + if (GTK.GTK4) {
  749. + monitorList = GDK.gdk_display_get_monitors(display);
  750. + monitorCount = OS.g_list_model_get_n_items(monitorList);
  751. + } else {
  752. + monitorCount = GDK.gdk_display_get_n_monitors(display);
  753. }
  754. - } else {
  755. - long screen = GDK.gdk_screen_get_default ();
  756. - if (screen != 0) {
  757. - int monitorCount = GDK.gdk_screen_get_n_monitors (screen);
  758. - if (monitorCount > 0) {
  759. - monitors = new Monitor [monitorCount];
  760. - GdkRectangle dest = new GdkRectangle ();
  761. - for (int i = 0; i < monitorCount; i++) {
  762. - GDK.gdk_screen_get_monitor_geometry (screen, i, dest);
  763. - Monitor monitor = new Monitor ();
  764. - monitor.handle = i;
  765. - monitor.x = DPIUtil.autoScaleDown (dest.x);
  766. - monitor.y = DPIUtil.autoScaleDown (dest.y);
  767. - monitor.width = DPIUtil.autoScaleDown (dest.width);
  768. - monitor.height = DPIUtil.autoScaleDown (dest.height);
  769. - monitor.zoom = Display._getDeviceZoom(monitor.handle);
  770.  
  771. - // workarea was defined in GTK 3.4. If present, it will return the best results
  772. - // since it takes into account per-monitor trim
  773. - GDK.gdk_screen_get_monitor_workarea (screen, i, dest);
  774. - monitor.clientX = DPIUtil.autoScaleDown (dest.x);
  775. - monitor.clientY = DPIUtil.autoScaleDown (dest.y);
  776. - monitor.clientWidth = DPIUtil.autoScaleDown (dest.width);
  777. - monitor.clientHeight = DPIUtil.autoScaleDown (dest.height);
  778. - monitors [i] = monitor;
  779. + if (monitorCount > 0) {
  780. + monitors = new Monitor[monitorCount];
  781. + GdkRectangle geometry = new GdkRectangle();
  782. + for (int i = 0; i < monitorCount; i++) {
  783. + long gdkMonitor = GTK.GTK4 ? OS.g_list_model_get_item(monitorList, i) : GDK.gdk_display_get_monitor(display, i);
  784. + GDK.gdk_monitor_get_geometry(gdkMonitor, geometry);
  785. +
  786. + Monitor monitor = new Monitor();
  787. + monitor.handle = gdkMonitor;
  788. + monitor.x = DPIUtil.autoScaleDown(geometry.x);
  789. + monitor.y = DPIUtil.autoScaleDown(geometry.y);
  790. + monitor.width = DPIUtil.autoScaleDown(geometry.width);
  791. + monitor.height = DPIUtil.autoScaleDown(geometry.height);
  792. + if (!OS.isX11()) {
  793. + int scaleFactor = (int) GDK.gdk_monitor_get_scale_factor(gdkMonitor);
  794. + monitor.zoom = scaleFactor * 100;
  795. + } else {
  796. + monitor.zoom = Display._getDeviceZoom(monitor.handle);
  797. }
  798. +
  799. + /* workarea was defined in GTK 3.4. If present, it will return the best results
  800. + * since it takes into account per-monitor trim. Not available in GTK4.
  801. + */
  802. + if (!GTK.GTK4) GDK.gdk_monitor_get_workarea(gdkMonitor, geometry);
  803. + monitor.clientX = DPIUtil.autoScaleDown(geometry.x);
  804. + monitor.clientY = DPIUtil.autoScaleDown(geometry.y);
  805. + monitor.clientWidth = DPIUtil.autoScaleDown(geometry.width);
  806. + monitor.clientHeight = DPIUtil.autoScaleDown(geometry.height);
  807. +
  808. + monitors[i] = monitor;
  809. }
  810. }
  811. }
  812. @@ -2745,7 +2727,7 @@ public Monitor getPrimaryMonitor() {
  813.  
  814. if (GTK.GTK4) {
  815. primaryMonitorIndex = 0;
  816. - } else if (GTK.GTK_VERSION >= OS.VERSION(3, 22, 0)) {
  817. + } else {
  818. //attempt to find actual primary monitor if one is configured:
  819. long display = GDK.gdk_display_get_default();
  820. long monitor = GDK.gdk_display_get_primary_monitor(display);
  821. @@ -2756,12 +2738,6 @@ public Monitor getPrimaryMonitor() {
  822. break;
  823. }
  824. }
  825. - } else {
  826. - long screen = GDK.gdk_screen_get_default();
  827. - if (screen != 0) {
  828. - //if no primary monitor is configured by the user, this returns 0.
  829. - primaryMonitorIndex = GDK.gdk_screen_get_primary_monitor(screen);
  830. - }
  831. }
  832.  
  833. return monitors[primaryMonitorIndex];
  834. @@ -3000,23 +2976,23 @@ public Image getSystemImage (int id) {
  835. switch (id) {
  836. case SWT.ICON_ERROR:
  837. if (errorImage == null) {
  838. - errorImage = createImage ("dialog-error"); //$NON-NLS-1$
  839. + errorImage = createImage ("dialog-error-symbolic"); //$NON-NLS-1$
  840. }
  841. return errorImage;
  842. case SWT.ICON_INFORMATION:
  843. case SWT.ICON_WORKING:
  844. if (infoImage == null) {
  845. - infoImage = createImage ("dialog-information"); //$NON-NLS-1$
  846. + infoImage = createImage ("dialog-information-symbolic"); //$NON-NLS-1$
  847. }
  848. return infoImage;
  849. case SWT.ICON_QUESTION:
  850. if (questionImage == null) {
  851. - questionImage = createImage ("dialog-question"); //$NON-NLS-1$
  852. + questionImage = createImage ("dialog-question-symbolic"); //$NON-NLS-1$
  853. }
  854. return questionImage;
  855. case SWT.ICON_WARNING:
  856. if (warningImage == null) {
  857. - warningImage = createImage ("dialog-warning"); //$NON-NLS-1$
  858. + warningImage = createImage ("dialog-warning-symbolic"); //$NON-NLS-1$
  859. }
  860. return warningImage;
  861. }
  862. @@ -3532,11 +3508,12 @@ void initializeCallbacks () {
  863. signalIds [Widget.MAP_EVENT] = OS.g_signal_lookup (OS.map_event, GTK.GTK_TYPE_WIDGET ());
  864. signalIds [Widget.MNEMONIC_ACTIVATE] = OS.g_signal_lookup (OS.mnemonic_activate, GTK.GTK_TYPE_WIDGET ());
  865. signalIds [Widget.MOTION_NOTIFY_EVENT] = OS.g_signal_lookup (OS.motion_notify_event, GTK.GTK_TYPE_WIDGET ());
  866. + signalIds [Widget.COMPUTE_SIZE] = OS.g_signal_lookup(OS.compute_size, GTK.GTK_TYPE_WIDGET() );
  867. /*
  868. - * Connect to the "popped-up" signal on GTK3.22+ if the user has specified the
  869. + * Connect to the "popped-up" signal if the user has specified the
  870. * SWT_MENU_LOCATION_DEBUGGING environment variable.
  871. */
  872. - if (GTK.GTK_VERSION >= OS.VERSION(3, 22, 0) && OS.SWT_MENU_LOCATION_DEBUGGING) {
  873. + if (OS.SWT_MENU_LOCATION_DEBUGGING) {
  874. long menuType = GTK3.GTK_TYPE_MENU ();
  875. OS.g_type_class_ref (menuType);
  876. signalIds [Widget.POPPED_UP] = OS.g_signal_lookup (OS.popped_up, menuType);
  877. @@ -3569,6 +3546,9 @@ void initializeCallbacks () {
  878. focusCallback = new Callback(this, "focusProc", void.class, new Type[] {long.class, long.class}); //$NON-NLS-1$
  879. focusProc = focusCallback.getAddress();
  880.  
  881. + windowActiveCallback = new Callback(this, "windowActiveProc", void.class, new Type[] {long.class, long.class}); //$NON-NLS-1$
  882. + windowActiveProc = windowActiveCallback.getAddress();
  883. +
  884. enterMotionCallback = new Callback(this, "enterMotionProc", void.class, new Type[] {
  885. long.class, double.class, double.class, long.class}); //$NON-NLS-1$
  886. enterMotionProc = enterMotionCallback.getAddress ();
  887. @@ -3589,6 +3569,9 @@ void initializeCallbacks () {
  888.  
  889. activateCallback = new Callback(this, "activateProc", void.class, new Type[] {long.class, long.class, long.class}); //$NON-NLS-1$
  890. activateProc = activateCallback.getAddress();
  891. +
  892. + computeSizeCallback = new Callback(this, "computeSizeProc", void.class, new Type[] {long.class, long.class, long.class}); //$NON-NLS-1$
  893. + computeSizeProc = computeSizeCallback.getAddress();
  894. }
  895.  
  896. notifyCallback = new Callback(this, "notifyProc", long.class, new Type[] {
  897. @@ -3664,7 +3647,6 @@ void initializeCallbacks () {
  898. closuresProc [Widget.TOGGLED] = windowProc3;
  899. closuresProc [Widget.UNMAP_EVENT] = windowProc3;
  900. closuresProc [Widget.WINDOW_STATE_EVENT] = windowProc3;
  901. - closuresProc [Widget.ROW_DELETED] = windowProc3;
  902. closuresProc [Widget.DIRECTION_CHANGED] = windowProc3;
  903.  
  904. windowCallback4 = new Callback (this, "windowProc", 4); //$NON-NLS-1$
  905. @@ -3679,7 +3661,6 @@ void initializeCallbacks () {
  906. closuresProc [Widget.SWITCH_PAGE] = windowProc4;
  907. closuresProc [Widget.TEST_COLLAPSE_ROW] = windowProc4;
  908. closuresProc [Widget.TEST_EXPAND_ROW] = windowProc4;
  909. - closuresProc [Widget.ROW_INSERTED] = windowProc4;
  910. closuresProc [Widget.ROW_HAS_CHILD_TOGGLED] = windowProc4;
  911. closuresProc [Widget.DELETE_FROM_CURSOR] = windowProc4;
  912. closuresProc [Widget.DELETE_FROM_CURSOR_INVERSE] = windowProc4;
  913. @@ -3808,13 +3789,11 @@ void initializeSubclasses () {
  914. OS.G_OBJECT_CLASS_SET_CONSTRUCTOR (pangoFontFaceClass, OS.pangoFontFaceNewProc_CALLBACK(pangoFontFaceNewProc));
  915. OS.g_type_class_unref (pangoFontFaceClass);
  916.  
  917. - if (!OS.IsWin32) { /* TODO [win32] replace unixprint */
  918. - long printerOptionWidgetType = GTK.gtk_printer_option_widget_get_type();
  919. - long printerOptionWidgetClass = OS.g_type_class_ref (printerOptionWidgetType);
  920. - printerOptionWidgetNewProc = OS.G_OBJECT_CLASS_CONSTRUCTOR (printerOptionWidgetClass);
  921. - OS.G_OBJECT_CLASS_SET_CONSTRUCTOR (printerOptionWidgetClass, OS.printerOptionWidgetNewProc_CALLBACK(printerOptionWidgetNewProc));
  922. - OS.g_type_class_unref (printerOptionWidgetClass);
  923. - }
  924. + long printerOptionWidgetType = GTK.gtk_printer_option_widget_get_type();
  925. + long printerOptionWidgetClass = OS.g_type_class_ref (printerOptionWidgetType);
  926. + printerOptionWidgetNewProc = OS.G_OBJECT_CLASS_CONSTRUCTOR (printerOptionWidgetClass);
  927. + OS.G_OBJECT_CLASS_SET_CONSTRUCTOR (printerOptionWidgetClass, OS.printerOptionWidgetNewProc_CALLBACK(printerOptionWidgetNewProc));
  928. + OS.g_type_class_unref (printerOptionWidgetClass);
  929. }
  930. }
  931.  
  932. @@ -3844,44 +3823,6 @@ void initializeSessionManager() {
  933. sessionManagerDBus.addListener(sessionManagerListener);
  934. }
  935.  
  936. -/**
  937. - * Some parts of SWT (like WebKit) use GDBus for IPC. Some of these objects
  938. - * cannot be disposed of in their own classes due to design challenges.
  939. - * In these instances we release them along with this Display. This ensures
  940. - * no Browser will be using them at disposal time.
  941. - */
  942. -void releaseDBusServices() {
  943. - releaseSessionManager();
  944. - for (long connection : dBusConnections) {
  945. - if (OS.g_dbus_connection_is_closed(connection)) continue;
  946. - long [] error = new long [1];
  947. - boolean closed = OS.g_dbus_connection_close_sync(connection, 0, error);
  948. - if (error[0] != 0) {
  949. - String msg = extractFreeGError(error[0]);
  950. - System.err.println("SWT Display: error closing connection: " + msg);
  951. - }
  952. - if (closed) {
  953. - // Free this as we added a reference to it
  954. - OS.g_object_unref(connection);
  955. - }
  956. - }
  957. - for (long server : dBusServers) {
  958. - OS.g_dbus_server_stop(server);
  959. - OS.g_object_unref(server);
  960. - }
  961. - for (long authObserver : dBusAuthObservers) {
  962. - OS.g_object_unref(authObserver);
  963. - }
  964. - for (long guid : dBusGUIDS) {
  965. - OS.g_free(guid);
  966. - }
  967. - dBusConnections.clear();
  968. - dBusServers.clear();
  969. - dBusAuthObservers.clear();
  970. - dBusGUIDS.clear();
  971. - dBusServers = dBusAuthObservers = dBusGUIDS = dBusConnections = null;
  972. -}
  973. -
  974. /**
  975. * Helper method to extract GError messages. Only call if the pointer is valid (i.e. non-zero).
  976. *
  977. @@ -4665,7 +4606,6 @@ protected void release () {
  978.  
  979. synchronizer.releaseSynchronizer ();
  980. synchronizer = null;
  981. - releaseDBusServices ();
  982. releaseSessionManager ();
  983. releaseDisplay ();
  984. super.release ();
  985. @@ -4696,6 +4636,10 @@ void releaseDisplay () {
  986. focusCallback = null;
  987. focusProc = 0;
  988.  
  989. + windowActiveCallback.dispose();
  990. + windowActiveCallback = null;
  991. + windowActiveProc = 0;
  992. +
  993. enterMotionCallback.dispose();
  994. enterMotionCallback = null;
  995. enterMotionProc = 0;
  996. @@ -5079,12 +5023,7 @@ String dumpWidgetTableInfo() {
  997. for (int i = 0; i < widgetTable.length; i++) {
  998. Widget w = widgetTable[i];
  999. if (w != null && w.isDisposed()) {
  1000. - Collection<Integer> list = disposed.get(w);
  1001. - if (list == null) {
  1002. - list = new ArrayList<>();
  1003. - disposed.put(w, list);
  1004. - }
  1005. - list.add(Integer.valueOf(i));
  1006. + disposed.computeIfAbsent(w, k -> new ArrayList<>()).add(Integer.valueOf(i));
  1007. }
  1008. }
  1009. if (!disposed.isEmpty()) {
  1010. @@ -5249,11 +5188,13 @@ public static String getAppVersion () {
  1011. * to any value other than "SWT" (case insensitive),
  1012. * it is used to set the application user model ID
  1013. * which is used by the OS for taskbar grouping.
  1014. - * @see <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/dd378459%28v=vs.85%29.aspx#HOW">AppUserModelID (Windows)</a>
  1015. - * </p><p>
  1016. + * </p>
  1017. + * <p>
  1018. * Specifying <code>null</code> for the name clears it.
  1019. * </p>
  1020. *
  1021. + * @see <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/dd378459%28v=vs.85%29.aspx#HOW">AppUserModelID (Windows)</a>
  1022. + *
  1023. * @param name the new app name or <code>null</code>
  1024. */
  1025. public static void setAppName (String name) {
  1026. @@ -5287,6 +5228,17 @@ public static void setAppVersion (String version) {
  1027. * @since 2.1
  1028. */
  1029. public void setCursorLocation (int x, int y) {
  1030. + /*
  1031. + * Wayland does not support mouse warping, thus setCursorLocation
  1032. + * is not supported due to gdk_device_warp not being implemented
  1033. + * in Wayland. There currently is no good solution that could be
  1034. + * implemented, so a log entry was determined to be sufficient.
  1035. + *
  1036. + * See Bug 577099
  1037. + */
  1038. + if(!OS.isX11()) {
  1039. + System.err.println("SWT Display.java Error: setCursorLocation only supported on X11. \n");
  1040. + }
  1041. setCursorLocation(new Point (x, y));
  1042. }
  1043.  
  1044. @@ -5652,7 +5604,7 @@ public boolean sleep () {
  1045. runSettings = true;
  1046. return false;
  1047. }
  1048. - if (getMessageCount () != 0) return true;
  1049. + if (!synchronizer.isMessagesEmpty()) return true;
  1050. sendPreExternalEventDispatchEvent ();
  1051. if (!GTK.GTK4) GDK.gdk_threads_leave ();
  1052. /*
  1053. @@ -5692,7 +5644,7 @@ public boolean sleep () {
  1054. OS.g_main_context_check (context, max_priority [0], fds, nfds);
  1055. OS.g_main_context_release (context);
  1056. }
  1057. - } while (!result && getMessageCount () == 0 && !wake);
  1058. + } while (!result && synchronizer.isMessagesEmpty() && !wake);
  1059. wake = false;
  1060. if (!GTK.GTK4) GDK.gdk_threads_enter ();
  1061. sendPostExternalEventDispatchEvent ();
  1062. @@ -5864,6 +5816,25 @@ void saveResources () {
  1063. }
  1064. }
  1065.  
  1066. +private void sendJDKInternalEvent(int eventType) {
  1067. + sendJDKInternalEvent(eventType, 0);
  1068. +}
  1069. +/** does sent event with JDK time**/
  1070. +private void sendJDKInternalEvent(int eventType, int detail) {
  1071. + if (eventTable == null || !eventTable.hooks (eventType)) {
  1072. + return;
  1073. + }
  1074. + Event event = new Event ();
  1075. + event.detail = detail;
  1076. + event.display = this;
  1077. + event.type = eventType;
  1078. + // time is set for debugging purpose only:
  1079. + event.time = (int) (System.nanoTime() / 1000_000L);
  1080. + if (!filterEvent (event)) {
  1081. + sendEvent (eventTable, event);
  1082. + }
  1083. +}
  1084. +
  1085. void sendEvent (int eventType, Event event) {
  1086. if (eventTable == null && filterTable == null) {
  1087. return;
  1088. @@ -5891,11 +5862,7 @@ void sendPreEvent (int eventType) {
  1089. if (eventType != SWT.PreEvent && eventType != SWT.PostEvent
  1090. && eventType != SWT.PreExternalEventDispatch
  1091. && eventType != SWT.PostExternalEventDispatch) {
  1092. - if (eventTable != null && eventTable.hooks (SWT.PreEvent)) {
  1093. - Event event = new Event ();
  1094. - event.detail = eventType;
  1095. - sendEvent (SWT.PreEvent, event);
  1096. - }
  1097. + sendJDKInternalEvent (SWT.PreEvent, eventType);
  1098. }
  1099. }
  1100.  
  1101. @@ -5903,11 +5870,7 @@ void sendPostEvent (int eventType) {
  1102. if (eventType != SWT.PreEvent && eventType != SWT.PostEvent
  1103. && eventType != SWT.PreExternalEventDispatch
  1104. && eventType != SWT.PostExternalEventDispatch) {
  1105. - if (eventTable != null && eventTable.hooks (SWT.PostEvent)) {
  1106. - Event event = new Event ();
  1107. - event.detail = eventType;
  1108. - sendEvent (SWT.PostEvent, event);
  1109. - }
  1110. + sendJDKInternalEvent (SWT.PostEvent, eventType);
  1111. }
  1112. }
  1113.  
  1114. @@ -5917,9 +5880,7 @@ void sendPostEvent (int eventType) {
  1115. * @noreference This method is not intended to be referenced by clients.
  1116. */
  1117. public void sendPreExternalEventDispatchEvent () {
  1118. - if (eventTable != null && eventTable.hooks (SWT.PreExternalEventDispatch)) {
  1119. - sendEvent (SWT.PreExternalEventDispatch, null);
  1120. - }
  1121. + sendJDKInternalEvent (SWT.PreExternalEventDispatch);
  1122. }
  1123.  
  1124. /**
  1125. @@ -5928,9 +5889,7 @@ public void sendPreExternalEventDispatchEvent () {
  1126. * @noreference This method is not intended to be referenced by clients.
  1127. */
  1128. public void sendPostExternalEventDispatchEvent () {
  1129. - if (eventTable != null && eventTable.hooks (SWT.PostExternalEventDispatch)) {
  1130. - sendEvent (SWT.PostExternalEventDispatch, null);
  1131. - }
  1132. + sendJDKInternalEvent (SWT.PostExternalEventDispatch);
  1133. }
  1134.  
  1135. void setCurrentCaret (Caret caret) {
  1136. @@ -6001,6 +5960,54 @@ public void syncExec (Runnable runnable) {
  1137. synchronizer.syncExec (runnable);
  1138. }
  1139.  
  1140. +/**
  1141. + * Calls the callable on the user-interface thread at the next reasonable
  1142. + * opportunity, and returns the its result from this method. The thread which
  1143. + * calls this method is suspended until the callable completes.
  1144. + * <p>
  1145. + * Note that at the time the callable is invoked, widgets that have the receiver
  1146. + * as their display may have been disposed. Therefore, it is necessary to check
  1147. + * for this case inside the callable before accessing the widget.
  1148. + * </p>
  1149. + * <p>
  1150. + * Any exception that is thrown from the callable is re-thrown in the calling
  1151. + * thread. Note: The exception retains its original stack trace from the
  1152. + * throwing thread. The call to {@code syncCall} will not be present in the
  1153. + * stack trace.
  1154. + * </p>
  1155. + *
  1156. + * @param callable the code to call on the user-interface thread
  1157. + *
  1158. + * @exception SWTException <code>ERROR_DEVICE_DISPOSED</code> - if the receiver
  1159. + * has been disposed
  1160. + * @exception E An exception that is thrown by the callable on the
  1161. + * user-interface thread, and re-thrown on the calling
  1162. + * thread
  1163. + *
  1164. + * @see #syncExec(Runnable)
  1165. + * @see SwtCallable#call()
  1166. + * @since 3.118
  1167. + */
  1168. +public <T, E extends Exception> T syncCall(SwtCallable<T, E> callable) throws E {
  1169. + Objects.nonNull(callable);
  1170. + @SuppressWarnings("unchecked")
  1171. + T[] t = (T[]) new Object[1];
  1172. + Object[] ex = new Object[1];
  1173. + syncExec(() -> {
  1174. + try {
  1175. + t[0] = callable.call();
  1176. + } catch (Exception e) {
  1177. + ex[0] = e;
  1178. + }
  1179. + });
  1180. + if (ex[0] != null) {
  1181. + @SuppressWarnings("unchecked")
  1182. + E e = (E) ex[0];
  1183. + throw e;
  1184. + }
  1185. + return t[0];
  1186. +}
  1187. +
  1188. static int translateKey (int key) {
  1189. for (int i=0; i<KeyTable.length; i++) {
  1190. if (KeyTable [i] [0] == key) return KeyTable [i] [1];
  1191. @@ -6071,13 +6078,18 @@ boolean scrollProc(long controller, double dx, double dy, long user_data) {
  1192. return false;
  1193. }
  1194.  
  1195. -void focusProc(long controller, long user_data) {
  1196. +void focusProc(long controller, long user_data) {;
  1197. long handle = GTK.gtk_event_controller_get_widget(controller);
  1198. Widget widget = getWidget(handle);
  1199.  
  1200. if (widget != null) widget.focusProc(controller, user_data);
  1201. }
  1202.  
  1203. +void windowActiveProc(long handle, long user_data) {;
  1204. + Widget widget = getWidget(handle);
  1205. + if (widget != null) widget.windowActiveProc(handle, user_data);
  1206. +}
  1207. +
  1208. boolean keyPressReleaseProc(long controller, int keyval, int keycode, int state, long user_data) {
  1209. long handle = GTK.gtk_event_controller_get_widget(controller);
  1210. Widget widget = getWidget(handle);
  1211. @@ -6100,6 +6112,10 @@ void leaveProc(long controller, long user_data) {
  1212. if (widget != null) widget.leaveProc(controller, handle, user_data);
  1213. }
  1214.  
  1215. +void computeSizeProc(long toplevel, long size, long user_data) {
  1216. + //TODO: GTK4 - Could be needed for minimum Size, signal remains connected
  1217. +}
  1218. +
  1219. void activateProc(long action, long parameter, long user_data) {
  1220. Widget widget = getWidget(user_data);
  1221. if(widget == null) return;
  1222. @@ -6221,18 +6237,11 @@ static int _getDeviceZoom (long monitor_num) {
  1223. * if gdk_screen_set_resolution has not been called.
  1224. */
  1225. int dpi = 96;
  1226. - if (GTK.GTK_VERSION >= OS.VERSION(3, 22, 0)) {
  1227. - long display = GDK.gdk_display_get_default();
  1228. - long monitor = GDK.gdk_display_get_monitor_at_point(display, 0, 0);
  1229. - int scale = GDK.gdk_monitor_get_scale_factor(monitor);
  1230. - dpi = dpi * scale;
  1231. - } else {
  1232. - long screen = GDK.gdk_screen_get_default ();
  1233. - dpi = (int) GDK.gdk_screen_get_resolution (screen);
  1234. - if (dpi <= 0) dpi = 96; // gdk_screen_get_resolution returns -1 in case of error
  1235. - int scale = GDK.gdk_screen_get_monitor_scale_factor (screen, (int) monitor_num);
  1236. - dpi = dpi * scale;
  1237. - }
  1238. + long display = GDK.gdk_display_get_default();
  1239. + long monitor = GDK.gdk_display_get_monitor_at_point(display, 0, 0);
  1240. + int scale = GDK.gdk_monitor_get_scale_factor(monitor);
  1241. + dpi = dpi * scale;
  1242. return DPIUtil.mapDPIToZoom (dpi);
  1243. }
  1244. +
  1245. }
  1246. diff --git a/Eclipse-R4_21/SWT.java b/Eclipse-R4_26/SWT.java
  1247. index 35d5860..9783715 100644
  1248. --- a/Eclipse-R4_21/SWT.java
  1249. +++ b/Eclipse-R4_26/SWT.java
  1250. @@ -1020,6 +1020,20 @@ public class SWT {
  1251. */
  1252. public static final int ZoomChanged = 55;
  1253.  
  1254. + /**
  1255. + * The SWT emptiness change event type (value is 56).
  1256. + *
  1257. + * <p>
  1258. + * This event is sent on <code>Tree</code> when the first <code>TreeItem</code> was
  1259. + * added to it (with the <code>detail</code> field set to 0) or the last
  1260. + * <code>TreeItem</code> was removed from it (with the <code>detail</code> field
  1261. + * set to 1).
  1262. + * </p>
  1263. + *
  1264. + * @since 3.118
  1265. + */
  1266. + public static final int EmptinessChanged = 56;
  1267. +
  1268. /* Event Details */
  1269.  
  1270. /**
  1271. @@ -2261,6 +2275,7 @@ public class SWT {
  1272. * <p><b>Used By:</b></p>
  1273. * <ul>
  1274. * <li><code>FormAttachment</code> in a <code>FormLayout</code></li>
  1275. + * <li><code>BoderData</code> in a <code>BoderLayout</code></li>
  1276. * </ul>
  1277. */
  1278. public static final int TOP = UP;
  1279. @@ -2285,6 +2300,7 @@ public class SWT {
  1280. * <ul>
  1281. * <li><code>FormAttachment</code> in a <code>FormLayout</code></li>
  1282. * <li><code>TabFolder</code></li>
  1283. + * <li><code>BoderData</code> in a <code>BoderLayout</code></li>
  1284. * </ul>
  1285. */
  1286. public static final int BOTTOM = DOWN;
  1287. @@ -2315,6 +2331,10 @@ public class SWT {
  1288. * This constant can also be used to representing the left keyboard
  1289. * location during a key event.
  1290. * </p>
  1291. + * <p><b>Used By:</b></p>
  1292. + * <ul>
  1293. + * <li><code>BoderData</code> in a <code>BoderLayout</code></li>
  1294. + * </ul>
  1295. */
  1296. public static final int LEFT = LEAD;
  1297.  
  1298. @@ -2344,6 +2364,10 @@ public class SWT {
  1299. * This constant can also be used to representing the right keyboard
  1300. * location during a key event.
  1301. * </p>
  1302. + * <p><b>Used By:</b></p>
  1303. + * <ul>
  1304. + * <li><code>BoderData</code> in a <code>BoderLayout</code></li>
  1305. + * </ul>
  1306. */
  1307. public static final int RIGHT = TRAIL;
  1308.  
  1309. @@ -2355,6 +2379,7 @@ public class SWT {
  1310. * <li><code>Label</code></li>
  1311. * <li><code>TableColumn</code></li>
  1312. * <li><code>FormAttachment</code> in a <code>FormLayout</code></li>
  1313. + * <li><code>BoderData</code> in a <code>BoderLayout</code></li>
  1314. * </ul>
  1315. */
  1316. public static final int CENTER = 1 << 24;
  1317.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement