windowseclipsewinapigtkswt

Which Win32 API is responsible for Multiple Display support in Eclipse SWT


I understand that Eclipse SWT is dependent on Win32 APIs in the Windows operating system and GTK in the Linux operating system. As of now, Eclipse SWT in Windows supports the creation of multiple Display instances (multiple Java threads can create their own Display instances simultaneously), whereas in Linux, this is not the case.

I understand that GTK is not thread-safe and hence does not allow the creation of multiple GTK instances(UI threads) per application, which in turn does not allow SWT to create multiple Displays in a multithreaded environment.

I tried to debug Display.java for SWT Linux where in it instantiates GTK . I tried to debug SWT code in windows but the CreateDisplay method in Display.java is empty in windows SWT implementation.

Note : I checked CreateThread API but is not used in SWT.
I am not talking about multiple windows creation because Window creation is equivalent to Shell creation in SWT not the Display.

Is it SWT that is responsible for multiple Display support, or which underlying win32 APIs ?


Solution

  • I did not get exact API from win32 . But I got a hint from here which says to enhance performance, access to graphics device interface (GDI) objects (such as palettes, device contexts, regions, and the like) is not serialized . Which means Win32 is responsible for allowing SWT to spawn multiple threads to access OS resources like GDIP and SWT have implemented required synchronization to handle multiple Display concept.