IgnorantGuru / spacefm

SpaceFM File Manager
http://ignorantguru.github.com/spacefm/
GNU General Public License v3.0
489 stars 73 forks source link

[FeatureRequest] Wayland support for spacefm-gtk3 #412

Open Hertz642 opened 10 years ago

Hertz642 commented 10 years ago

There are basically no lightweight panel-based filemanagers that support Wayland. Would it be possible to remove or replace the X11 calls in SpaceFM so that it runs under Wayland through GTK3 without having X? What functionality currently requires X?

I am trying to build a Wayland-only system to give Wayland a more rigorous test, like building a system without IPv4 support to make sure IPv6 works.

IgnorantGuru commented 10 years ago

Most of the X11 calls in SpaceFM are in the desktop integration code - the code for SpaceFM's desktop manager. If you build with configure --disable-desktop-integration this code is not included.

There are a few remaining calls eg in src/main-window.c for determining what desktop SpaceFM is running on. These could be hobbled - you'll just lose smart placement of windows on multiple workspaces.

To find remaining x11 calls aside from the desktop code run (from the dir containing 'configure):

grep -r --exclude-dir desktop --exclude-dir .deps [xX]11 src

I think that will point out most of them - not much.

As for what GTK3 can do without X, I can't answer that off-hand. If you get this working in a basic way I'd like to see your changes (maybe in a github fork?) and will consider adding an upstream build option for wayland - thanks.

Hertz642 commented 10 years ago

Okay. I removed the GDKX/X11 code in main-window.c and switch the function there to fall back to "dumb" mode, as described in the code comment. I can now compile that part of the source.

I also had to use "--disable-startup-notification", since there is some GDKX/X11 code that it uses.

However, the code for desktop integration still seems to be built when I run configure with "--disable-desktop-integration". I get a "gdk/gdkx.h: No such file or directory" on "desktop/working-area.c". My coding skills are not that great, so I haven't been able to tell why it is not disabling it. I have tried the 0.9.2 release and the Git master.

The changes so far are tiny: deleting one function and reducing another to a single line. Unless there are some larger changes I could probably just put it in a short patch. You might need to help me with adding "#ifdef" entries for Wayland, because I'm not sure how to do that correctly.

IgnorantGuru commented 10 years ago

Yeah if you put a patch or pull request together I can adjust the build system. Maybe an --enable-wayland configure option which can be tested in ifdefs. Best if you work off the next branch or at least 0.9.3.

You might try a make clean in there for sanity, but I'm not sure why you'd get that error. It builds ok if I run:

./configure --disable-desktop-integration --disable-startup-notification [--with-gtk3]
make clean
make -s

It works with or without the gtk3.

Maybe post a pastebin of your commands and the error.

Hertz642 commented 10 years ago

Well, I am not just building SpaceFM without X11 support; everything on my test machine is built without X11. I used the same configure lines as you on a clean source directory, and it failed, probably because you have some libraries for X11 that I don't. I figured out how to disable them though (looks like a missing ifdef?), and it now compiles and runs! It has a bunch of runtime problems though, like the menubar doesn't work, so I will have to test it out and document everything that is broken.

Here is a patch of the changes I made. I used the ifdefs for X11 from: https://developer.gnome.org/gdk3/unstable/gdk3-Wayland-Interaction.html which I think are the correct ones to use, so it should just be a matter of adding the proper configure hooks. I wouldn't know how to replace the missing functionality though, especially since when comparing "gdk/gdkx.h" and "gdk/gdkwayland.h", it looks like the Wayland part isn't well developed yet.

--- src/main-window.c
+++ src/main-window.c
@@ -19,8 +19,11 @@
 #include <glib-object.h>
 #include <gdk/gdk.h>
 #include <gdk/gdkkeysyms.h>
-#include <gdk/gdkx.h>  // XGetWindowProperty
-#include <X11/Xatom.h> // XA_CARDINAL
+
+#ifdef GDK_WINDOWING_X11
+#  include <gdk/gdkx.h>  // XGetWindowProperty
+#  include <X11/Xatom.h> // XA_CARDINAL
+#endif

 #include <string.h>

@@ -4042,6 +4045,8 @@
     return all_windows;
 }

+#ifdef GTK_WINDOWING_X11
+
 static long get_desktop_index( GtkWindow* win )
 {
     long desktop = -1;
@@ -4125,6 +4130,14 @@
     return invalid ? fm_main_window_get_last_active() : NULL;
 }

+#else
+/* dummy implementation */
+FMMainWindow* fm_main_window_get_on_current_desktop()
+{
+    return fm_main_window_get_last_active();
+}
+#endif
+
 enum {
     TASK_COL_STATUS,
     TASK_COL_COUNT,
--- src/desktop/working-area.c
+++ src/desktop/working-area.c
@@ -23,6 +23,9 @@
 */

 # include <gdk/gdk.h>
+
+#ifdef DESKTOP_INTEGRATION
+
 # include <gdk/gdkx.h>
 # include <X11/Xlib.h>
 # include <X11/Xutil.h>
@@ -135,6 +138,14 @@
    return TRUE;
 }

+#else /* ! DESKTOP_INTEGRATION */
+/* dummy implementation */
+gboolean gf_display_get_workarea( GdkScreen* screen, GdkRectangle* *rect )
+{
+   return FALSE;
+}
+#endif
+
 void get_working_area( GdkScreen* screen, GdkRectangle* area )
 {
    if( !gf_display_get_workarea(screen, area) )
IgnorantGuru commented 10 years ago

Okay I've forked spacefm's next branch into a spacefm-wayland repo and applied your changes.

You are a collaberator on that repo so you should have write access. If you don't want to use git, you can use github's online editor to edit files. Just navigate to the the source file, click the filename, and click Edit. Add a commit summary for each edit, and when you save the edit this will add a commit to the repo automatically.

Or if you want to use git, clone the repo, make changes to file, commit the change, and push back to the repo.

To build from that repo without using git to clone, just follow the BUILD NEXT instructions in SpaceFM's README, substituting "spacefm-wayland" for "spacefm" for the repo name in the URLs.

If you could one way or another add your edits to that repo, that would be the easiest way to track your changes and eventually merge them upstream. And I'll do the build system work in that repo as well. I added "//wayland" (no space) next to the wayland changes so I can find them fast.

There's also an issue tracker there you can use for your issues - just be advised that they will be lost when that repo is merged up and deleted (though they can be archived).

It's a good sign it built and ran - sounds promising.

Hertz642 commented 10 years ago

Thanks for your help! I will try to find some info on how GTK integrates with Wayland, and hopefully I can discover how you would implement some of the functionality that is disabled with the changes. Unfortunately, I think it may not be possible at this point, as the toolkits may be lagging behind Wayland development (GTK only recently got client-side window decorations).

I loaded up SpaceFM on another computer and checked it against the behavior of my Wayland compile. Unfortunately, several thinks seem to be broken in a very major way. Each of the problems seems simple in its behavior though: the functionality is just missing. The menubar does not work, as I mentioned earlier. Also, a right-click does not open the right click menu. Finally, when opening the side-panes the drag bars do not work. In all three cases it is as if the functionality just doesn't exist -- there isn't any crashing or anything, the menus just don't open and the drag bars are just unmovable blank grey bars. Clicking and dragging also doesn't work, but it looks like it is because of how Wayland is working, so I will create another issue for it. Everything else that I can access without the menus seems to work correctly.

I will post separate issues for these in the spacefm-wayland tracker, and put a summary of major things that get reported/fixed here.