Community
Participate
Working Groups
When scrolling a slider for example, it is not possible to syncExec runnables from any other thread and have them run until the scroll thumb is released. This means users can not write code to respond to slider events during scrolling, nor can they do any other work on widgets created in that thread, assuming that most calls through AWT use syncExec. It appears that the OS creates a separate loop to read and dispatch events during scrolling and our (AWT) readAndDispatch loop waits, as a side effect of waiting runAsyncMessages is not called during this time. We made a quick hack to post a special message to ourselves whenever a new syncExec runnable was added and when the windowProc saw that message it would run one async runnable, this gave acceptable behaviour (we are not saying it is any sort of solution). NOTE: Scrolling is ONE example of this problem. NOTES: SN (5/16/00 3:42:38 PM) There is a problem doing this in VA/Java because "no context switch in call-in" which means that we can't signal the other thread that the work is done. There is no way for me to easily test that my code is working. SN (5/16/00 6:20:08 PM) Can you elaborate on the other cases? SSQ/MVM (5/17/00 11:15:18 AM) - We can test the fix and you could wrap the code in a isVAJava flag or something. In our case, we are not context switching, we are running a async runnable in the call in thread. ANOTHER CASE: If full window drag is ON and you have a window that paints itself (non native widgets), it will not paint. For example, run AwtClock and move it off the screen or move a window created with the same SWT display over it. SN (5/17/00 3:34:32 PM) Ok, I will add a special flag that will default to false in VA/Java that will post a special message to wake up the event loop. I look for this special message and run sync/async messages. SSQ to write a wad of code that shows the problem. SSQ (5/18/00 10:45:02 AM) - The test case below shows the scrolling problem and the redrawing problem. import com.ibm.swt.*; import com.ibm.swt.widgets.*; import com.ibm.swt.graphics.*; public class SyncProblem { public static void main(String[] args) { final Shell shell = new Shell(); shell.setBounds(0, 0, 200, 200); final Slider slider = new Slider(shell, SWT.HORIZONTAL); slider.setBounds(0, 150, 190, 25); final Label label = new Label(shell, SWT.HORIZONTAL); label.setBounds(0, 130, 190, 30); new Thread() { public void run() { while (!shell.isDisposed()) { shell.getDisplay().syncExec(new Runnable() { public void run() { GC gc = new GC(shell); gc.setBackground(new Color(shell.getDisplay(), 255, 0, 0)); gc.fillRectangle(0, 0, 100, 100); gc.dispose(); } }); try { Thread.sleep(200); } catch (InterruptedException e) {} } } }.start(); new Thread() { public void run() { while (!shell.isDisposed()) { shell.getDisplay().syncExec(new Runnable() { public void run() { label.setText("" + slider.getSelection()); } }); try { Thread.sleep(200); } catch (InterruptedException e) {} } } }.start(); shell.setVisible(true); while (!shell.isDisposed()) { if (!shell.getDisplay().readAndDispatch ()) shell.getDisplay().sleep (); } System.exit(0); } } SN (2/1/01 2:44:24 PM) - We can fix this now that we run the C DLLs everwhere. SN to investigate if it is still wanted.
PRODUCT VERSION: SWT 032
Fixed > 20020510.
Are we sure that this is not breaking anyone? Did you describe the change on the mailing list (and newsgroup?)? Is it possible that WSAD, for example, could get burned by this?
I cleared this with Nick. I put print when this was happening and it occurred never when scrolling and rarely when a menu was pulled down. This behavior is already happening on every other platform. The change has also been in for over two weeks now. I case it wasn't clear, this was a dup but the problem still occurs in WinCE so I couldn't close the original.