Bug 488431 - Provide SWT/GTK3 port on Windows
Summary: Provide SWT/GTK3 port on Windows
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.5   Edit
Hardware: PC Windows All
: P3 enhancement with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
Depends on: 505604
Blocks:
  Show dependency tree
 
Reported: 2016-02-25 02:22 EST by Alexander Kurtakov CLA
Modified: 2022-10-08 15:53 EDT (History)
13 users (show)

See Also:


Attachments
Light example (163.97 KB, image/jpeg)
2016-02-25 05:54 EST, Nobody - feel free to take it CLA
no flags Details
Dark example (121.00 KB, image/jpeg)
2016-02-25 05:54 EST, Nobody - feel free to take it CLA
no flags Details
Screenshot of Snippet10 on gtk-win32 (276.62 KB, image/png)
2016-10-09 08:51 EDT, Rolf Theunissen CLA
no flags Details
File describing steps taken to compile swt againt gtk on windows (3.36 KB, text/plain)
2016-10-31 14:44 EDT, Lothar Lattermann CLA
no flags Details
Screenshot of Eclipse running on gtk-win32 (175.81 KB, image/png)
2018-04-05 16:05 EDT, Rolf Theunissen CLA
no flags Details
First attempt on a swt-gtk-win32 launcher (126.45 KB, application/octet-stream)
2019-06-16 12:15 EDT, Rolf Theunissen CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Kurtakov CLA 2016-02-25 02:22:37 EST
An optional GTK3 port for Windows could be usable for people wanting full styling options(which are not provided by win32)
Comment 1 Alexander Kurtakov CLA 2016-02-25 02:25:16 EST
Should be mostly releng/dynamic loading to be figured as latest SWT on GTK port has X11 conditioned(verified by Wayland/Broadway ports) so no real significant work on widgets expected.
Comment 2 Nobody - feel free to take it CLA 2016-02-25 05:54:20 EST
Created attachment 259920 [details]
Light example
Comment 3 Nobody - feel free to take it CLA 2016-02-25 05:54:47 EST
Created attachment 259921 [details]
Dark example
Comment 4 Nobody - feel free to take it CLA 2016-02-25 05:56:15 EST
The above screenshots were taken after installing a sample genealogy app https://gramps-project.org/wiki/index.php?title=Download#MS_Windows on a pristine Windows 7 machine. It is using GTK 3.18.
Comment 5 Kaloyan Raev CLA 2016-02-25 06:07:23 EST
It looks really promising.
Comment 6 Fabio Zadrozny CLA 2016-02-25 06:40:35 EST
As a note, besides releng, the css theming will probably have to be changed too (because effectively, when on windows/GTK, I think we'd like to use the theming which is used for Linux/GTK in this case and not Windows -- I'm guessing most checks currently check for the OS, not the SWT backend, so, I think a number of assumptions may be broken here).
Comment 7 Alexander Kurtakov CLA 2016-02-25 06:47:28 EST
(In reply to comment #6)
> As a note, besides releng, the css theming will probably have to be changed too
> (because effectively, when on windows/GTK, I think we'd like to use the theming
> which is used for Linux/GTK in this case and not Windows -- I'm guessing most
> checks currently check for the OS, not the SWT backend, so, I think a number of
> assumptions may be broken here).

True, work on the theming engine will have to be done, to make it at least know that the underlying UI toolkit has the notion of Dark/Light itself. Something that GTK has for quite some time and Windows 10 has in a way too.
Comment 8 Eclipse Genie CLA 2016-10-09 08:15:01 EDT
New Gerrit change created: https://git.eclipse.org/r/82800
Comment 9 Rolf Theunissen CLA 2016-10-09 08:22:08 EDT
To get the build environment for the windows port, to build the attached patch:

1) Install msys2:
     https://msys2.github.io/
2) Update msys2:
     pacman -Syuu
3) Install toolchain and dependencies:
      pacman -S mingw-w64-x86_64-toolchain
      pacman -S mingw-w64-x86_64-gtk2
      pacman -S mingw-w64-x86_64-webkitgtk2
      pacman -S mingw-w64-x86_64-gtk3
      pacman -S mingw-w64-x86_64-webkitgtk3
4) Switch to GTK classpath
5) Open a MINGW64 console 
6) Ensure that JAVA_HOME in the console contains unix slashes 'e.g. C:/Java/jdk8'
7) Execute the build in the bin/library folder
     ./build.sh
Comment 10 Alexander Kurtakov CLA 2016-10-09 08:29:00 EDT
(In reply to Rolf Theunissen from comment #9)
> To get the build environment for the windows port, to build the attached
> patch:
> 
> 1) Install msys2:
>      https://msys2.github.io/
> 2) Update msys2:
>      pacman -Syuu
> 3) Install toolchain and dependencies:
>       pacman -S mingw-w64-x86_64-toolchain
>       pacman -S mingw-w64-x86_64-gtk2
>       pacman -S mingw-w64-x86_64-webkitgtk2
>       pacman -S mingw-w64-x86_64-gtk3
>       pacman -S mingw-w64-x86_64-webkitgtk3
> 4) Switch to GTK classpath
> 5) Open a MINGW64 console 
> 6) Ensure that JAVA_HOME in the console contains unix slashes 'e.g.
> C:/Java/jdk8'
> 7) Execute the build in the bin/library folder
>      ./build.sh

That's awesome. Do you have screenshots? I'll dig into the patch during the week.
Comment 11 Alexander Kurtakov CLA 2016-10-09 08:38:11 EDT
(In reply to Rolf Theunissen from comment #9)
> To get the build environment for the windows port, to build the attached
> patch:
> 
> 1) Install msys2:
>      https://msys2.github.io/
> 2) Update msys2:
>      pacman -Syuu
> 3) Install toolchain and dependencies:
>       pacman -S mingw-w64-x86_64-toolchain
>       pacman -S mingw-w64-x86_64-gtk2
>       pacman -S mingw-w64-x86_64-webkitgtk2
>       pacman -S mingw-w64-x86_64-gtk3
>       pacman -S mingw-w64-x86_64-webkitgtk3
> 4) Switch to GTK classpath
> 5) Open a MINGW64 console 
> 6) Ensure that JAVA_HOME in the console contains unix slashes 'e.g.
> C:/Java/jdk8'
> 7) Execute the build in the bin/library folder
>      ./build.sh

Have you tried webkitgtk4? We are working towards making it fully supported as webkitgtk project no longer provides security updates for webkitgtk2 and webkitgtk3. Also I would rather see new work like that not include gtk2 (AFAIK LnF on windows is not good for it) and obsolete things like mozilla/xulrunner which are known to not work on any non-ancient system.
Comment 12 Eclipse Genie CLA 2016-10-09 08:44:32 EDT
New Gerrit change created: https://git.eclipse.org/r/82801
Comment 13 Rolf Theunissen CLA 2016-10-09 08:50:32 EDT
Another note, to run the code ensure that MINGW64 is on the PATH environmental variable. E.g.:

${env_var:PATH};C:\msys64\mingw64\bin
Comment 14 Rolf Theunissen CLA 2016-10-09 08:51:20 EDT
Created attachment 264752 [details]
Screenshot of Snippet10 on gtk-win32
Comment 15 Alexander Kurtakov CLA 2016-10-10 04:54:05 EDT
(In reply to Rolf Theunissen from comment #14)
> Created attachment 264752 [details]
> Screenshot of Snippet10 on gtk-win32

Great, I've reviewed the patch, there are some issues with it. Overall, try to push smaller patches to make it easier for review. All of them can refer to this bug so you don't open bugs for each patch.
Comment 16 Lothar Lattermann CLA 2016-10-31 14:44:20 EDT
Created attachment 265122 [details]
File describing steps taken to compile swt againt gtk on windows

Hi,

I tried to follow the steps as described in the patch. However, I get stuck execution ./build.sh -gtk3 with the followin result:
$ ./build.sh -gtk3
Cairo found, compiling SWT support for the cairo graphics library.
*** None of the following libraries were found:  Mozilla/XPCOM, Firefox/XPCOM, or XULRunner/XPCOM:
***    >> Mozilla embedding support will not be compiled.
*** libjawt.so not found, the SWT/AWT integration library will not be compiled.
Building SWT/GTK+ for Architectures: win32 x86_64
Building GTK3 bindings:
make_win32.mak:14: make_common.mak: No such file or directory
make: *** No rule to make target 'make_common.mak'.  Stop.
*** GTK3 Build failed, aborting further actions..

From what I can gather the ./build.sh should be run from /eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library
make_common.mak however resides at /eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT/common/library with the required swt.c and swt.h files.

--> Not sure what I am doing wrong or which step I missed.


Please note: I don't mean to clutter your bug report so I gladly post this somewhere else. Furthermore, let more know if me trying to get this to run is of any help to you or if I can help in some other way that is of more benefit to you.


Anyways, fantastic work!!
Comment 17 Rolf Theunissen CLA 2016-11-01 04:55:13 EDT
The build instruction that I used are part of the SWT FAQ:

https://www.eclipse.org/swt/faq.php#howbuilddll

paragraph: 'Building the SWT JNI libraries from the eclipse GIT repository'

Make sure that Eclipse has compiled the project first, then execute the build.sh script in the 'org.eclipse.swt/bin/library' directory.
Comment 18 Lothar Lattermann CLA 2016-11-01 10:51:48 EDT
(In reply to Rolf Theunissen from comment #17)
> The build instruction that I used are part of the SWT FAQ:
> 
> https://www.eclipse.org/swt/faq.php#howbuilddll
> 
> paragraph: 'Building the SWT JNI libraries from the eclipse GIT repository'
> 
> Make sure that Eclipse has compiled the project first, then execute the
> build.sh script in the 'org.eclipse.swt/bin/library' directory.

Thank you very much - that worked for me:
GTK3 Build succeeded

I successfully ran some of the SWT examples.

Please let me know if there is anything I can contribute. Maybe there is some testing I can do you guys, for example.


This looks really great!


Cheers
Comment 19 Eclipse Genie CLA 2017-01-30 12:41:29 EST
New Gerrit change created: https://git.eclipse.org/r/89885
Comment 20 Eclipse Genie CLA 2017-01-30 12:41:39 EST
New Gerrit change created: https://git.eclipse.org/r/89884
Comment 21 Eclipse Genie CLA 2017-01-30 12:41:45 EST
New Gerrit change created: https://git.eclipse.org/r/89883
Comment 22 Eclipse Genie CLA 2017-01-30 12:41:51 EST
New Gerrit change created: https://git.eclipse.org/r/89882
Comment 23 Eclipse Genie CLA 2017-01-30 12:41:57 EST
New Gerrit change created: https://git.eclipse.org/r/89886
Comment 24 Rolf Theunissen CLA 2017-01-30 14:03:58 EST
with the patches in gerrit:

At least the following know issues remain due to X11 and platform restrictions: 
- OpenGL integration: GTK OpenGL dependency depends on GLX (X11 only)
- AWT integration: GTK-SWT-AWT depends on X11
- Mozilla delegate: GTK implementation assumes *nix Mozilla
- Printing: GTK-SWT printing depends on gtkunixprint

Know issues; All testcases run, however the following failures occur: 
- Cut/Copy/Past of styled test (3) 
- Printer related test (11) 
- GTK3: some failures related to the size of widgets (4) 
- All browser test fail (9)
Comment 30 Eclipse Genie CLA 2018-03-10 14:57:49 EST
New Gerrit change created: https://git.eclipse.org/r/119158
Comment 31 Eclipse Genie CLA 2018-03-10 15:13:08 EST
New Gerrit change created: https://git.eclipse.org/r/119159
Comment 32 Eclipse Genie CLA 2018-03-10 15:34:25 EST
New Gerrit change created: https://git.eclipse.org/r/119160
Comment 33 Eclipse Genie CLA 2018-03-11 06:06:21 EDT
New Gerrit change created: https://git.eclipse.org/r/119169
Comment 34 Eclipse Genie CLA 2018-03-11 06:16:38 EDT
New Gerrit change created: https://git.eclipse.org/r/119170
Comment 39 Eclipse Genie CLA 2018-04-05 15:42:39 EDT
New Gerrit change created: https://git.eclipse.org/r/120802
Comment 40 Rolf Theunissen CLA 2018-04-05 16:05:26 EDT
Created attachment 273463 [details]
Screenshot of Eclipse running on gtk-win32

After the previous Gerrit change is applied, it is possible to launch Eclipse on the gtk-win32 port, see the attached screenshot.

Current status of the port:

Unsupported features:
 - Printing
 - Browser
 - GLCanvas (needs port to GtkGLArea, see Bug 519114)
 - SWT_AWT (I have a prototype running)

Failing test-case with GTK3 (Something with UTF in Pango):
  - org.eclipse.swt.tests.junit.Test_org_eclipse_swt_graphics_TextLayout test_getNextOffset(org.eclipse.swt.tests.junit.Test_org_eclipse_swt_graphics_TextLayout)
      java.lang.AssertionError: expected:<8> but was:<9>

Additional failing test-case with GTK2 (Bug 404946):
  - org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Display test_getActiveShell(org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Display)
      java.lang.AssertionError: expected same:<Shell {test_getActiveShell}> was not:<null>
Comment 41 Leo Ufimtsev CLA 2018-04-05 16:31:34 EDT
(In reply to Rolf Theunissen from comment #40)
> Created attachment 273463 [details]
> Screenshot of Eclipse running on gtk-win32

Wow, that's pretty cool.
 
> Unsupported features:
>  - Browser

I did the Webkit2 port. Is there something I can do to get SWT-Gtk-Win to work with Webkit on Windows?
Is the Gtk-webkit (webkitgtk) available on windows like gtk?

> Additional failing test-case with GTK2 (Bug 404946):
I think we can ignore gtk2 altogether since we'll be dropping gtk2 support anyway. But good to know.
Comment 42 Rolf Theunissen CLA 2018-04-06 03:00:38 EDT
(In reply to Leo Ufimtsev from comment #41)
> (In reply to Rolf Theunissen from comment #40)
> > Unsupported features:
> >  - Browser
> 
> I did the Webkit2 port. Is there something I can do to get SWT-Gtk-Win to
> work with Webkit on Windows?
> Is the Gtk-webkit (webkitgtk) available on windows like gtk?
> 

Webkitgtk is currently not supported on windows, see [1]: [GTK] Add back the Win32 target. I have been looking to get it compile again, but I seem to run in problems with code-generators in webkit. So I won't expect webkitgtk on windows soon.

Another browser backend is needed.


[1] https://bugs.webkit.org/show_bug.cgi?id=137488
Comment 45 Eclipse Genie CLA 2018-10-18 16:15:02 EDT
New Gerrit change created: https://git.eclipse.org/r/131155
Comment 46 Rolf Theunissen CLA 2018-10-18 16:19:26 EDT
It has been a while, but I wanted to give an update on some thing I worked on before, but ran into problems to complete them.

1. Printing; GTK offers an portable API based on callbacks. SWT uses a job based printing system. For Unix, GTK offers a Job based printing system too. Therefore, it is pretty hard to use portable GTK code here. Either the GTK job based system should be ported to win32, or SWT/gtk/win32 should use its own backend.

2. Equinox Launcher; The launcher used by GTK is (partly) not written in portable GTK code, therefore, it won't compile (easily) on win32. Here, either the win32 launcher can be adapted to launch the GTK version, or the GTK launcher can be ported to GTK code.

3. Code sharing; Some win32 specific parts are not offered by GTK. They are supported by SWT/win32, it seems natural to share some code between SWT/win32 and SWT/gtk/win32. However, this would impact SWT/win32 quite a bit, for instance by splitting out OS and platform dependent things, to make SWT/win32 and SWT/gtk compatible.
Comment 48 Rolf Theunissen CLA 2019-06-16 12:15:13 EDT
Created attachment 278954 [details]
First attempt on a swt-gtk-win32 launcher

I was going over my old code, and I still have a prototype laying around for trying to make a launcher that can launch the gtk-win32 port directly.
I have not looked into the code for a while now, and some clean up would be needed. But I don't think I will finish any of it soon.
Anyhow, the code becomes quite messy as the current GTK launcher assumes a *nix environment.

The easiest way to get a launcher, is to use the existing win32 launcher and provide '-ws gtk -noSplash' as an options. After bootstrapping an installation that includes the win32-gtk fragments.
Comment 49 Alexander Kurtakov CLA 2020-01-08 09:10:09 EST
I'm going to mark this one as wontfix. With recent developments of WSL/WSL2 it's better suited for using swt/gtk on windows.
Comment 50 Alexandr Miloslavskiy CLA 2022-10-08 15:14:57 EDT
Shall we maybe removed the bundle from SWT ?

I understand that the work was never finished, and it just stays there, confusing me once in a while - whenever I change something about win32 build settings, I wonder if I should or should not apply them to win32/gtk as well.

I understand that this took quite some hours to try to implement and I offer my apologies for suggesting to forget all of this. Still, I think that it would be best
Comment 51 Alexandr Miloslavskiy CLA 2022-10-08 15:17:21 EDT
Reading between the lines, I understand that the goal was to have dark theme in SWT for Windows. But now it's already implemented for Win10.
Comment 52 Alexander Kurtakov CLA 2022-10-08 15:20:00 EDT
Feel free to do it. This one didn't manage to fly (although I believe it could serve SWT well).
Comment 53 Alexandr Miloslavskiy CLA 2022-10-08 15:53:39 EDT
Will be removed in https://github.com/eclipse-platform/eclipse.platform.swt/issues/425