Open maishams opened 3 years ago
I don't think it can be done directly in zathura. But there are probably tools that can do that for all or some MacOS applications.
You may need to install the HEAD
version with the improved osx integration (see #38).
do you know of any tools that can remove the title bar?
I don't. But if it can help: zathura is using the GTK framework for graphics.
If zathura is using GTK would this be applicable? https://developer.gimp.org/api/2.0/gtk/GtkWindow.html#gtk-window-set-decorated
+1 It would be great to not have the title bar :)
The only way to get an effect like this (hide title bar) is to use two applications side by side in full screen mode. Check this article from Apple: https://support.apple.com/en-us/HT204948
I know basically nothing about GTK, GDK, etc, but I think I've jerry-rigged a build of zathura that removes the titlebar. It is only a few lines changed.
The caveat?
I'll try to put more work into this later, but I'm still just scraping code from the GTK docs.
Here's an image of it (without a document opened):
What did I change? zathura/zathura/zathura.c in between line 153 and 154 (as of commit 1222a2a)
GtkWidget *topLevelWidget = gtk_widget_get_toplevel(zathura->ui.session->gtk.view);
if (GTK_IS_WINDOW(topLevelWidget)) {
gtk_window_set_decorated(GTK_WINDOW(topLevelWidget), false);
}
This essentially gets the top level widget and checks if it is a GTKWindow. If it is, we can just use what @typkrft suggested on it and disable the decorators.
If anyone is more knowledgeable about GTK, I would greatly appreciate some guidance in fleshing this idea out.
A quick follow-up, I've gotten the corners to be rounded.
All it takes is changing the CSS that GTK/GDK looks at. Here's an image of it:
What did I change? zathura/data/zathura.css_t at the end of the file (as of commit 8f65183, but it hasn't been changed in 8 years so you probably don't have to worry)
/* Rounded corners for borderless */
window {
border-radius: 10px;
}
#@session@ .statusbar {
border-radius: 0px 0px 10px 10px; /* Rounding only the bottom corners to correlate with the window. */
}
This is just regular CSS that's adding to ".statusbar" (from girara) and "window" (from GTK/GDK). You can edit the border radius to your liking.
Now I'm trying to figure out how to move the window, which I expect to be a lot more complex. Hope this helps!
You're on the ball. I was about to start messing around myself. It looks like https://developer.gimp.org/api/2.0/gtk/GtkWindow.html#gtk-window-set-has-frame might be helpful. My guess is that some kind of frame needs to be set if not already to ensure the objective is able to be interacted with. Just a guess. I also know nothing about GTK.
Using the signal frame_event you can receive all events targeted at the frame.
Thanks for this! I was trying to implement it (as the original resize/move frame is disabled due to the decorators being disabled), but it seems that it's no longer in the most recent GTK4. Was this something only in GTK2?
I found something that helps with the resize issue. Essentially, I've given it an empty title bar so that the frame stays for resizing.
Here's an image of it:
What did I change? I changed the code from earlier. zathura/zathura/zathura.c in between line 153 and 154 (as of commit 1222a2a)
GtkWidget* topLevelWidget = gtk_widget_get_toplevel(zathura->ui.session->gtk.view); // TopLevel is (in zathura) always a GtkWindow, so we just check to see if it is NULL to prevent crashing.
if (topLevelWidget == NULL) {
return;
}
gtk_window_set_titlebar(GTK_WINDOW(topLevelWidget), gtk_header_bar_new()); // Casting GtkWindow to the GtkWidget to fit the function and creating a new (empty) titlebar.
This allows for resizing but not "dragging." Technically you can move the window by resizing it over to the right position, but you can't drag on the empty area. Additionally, it seems that the frame is a little bit larger than zathura appears. I presume this is because we retrieved the top level GtkWindow which contains zathura. It seems that the statusbar also doesn't round the corners correctly, as the outline still appears with an empty background.
I would consider this a minor success, now we just have to figure out dragging on the empty space.
I've made a fork of the tap for testing. You can see it here. I'm not sure how Pull Requests work so once this is "finished," I would greatly appreciate guidance on how to pull request a new branch.
This is the official codebase on gitlab. You might consider reaching out over there on this issue and contributing to the source. The benefit is that you become a contributor potentially and you may get some help on certain issues you are facing. Alternatively just adding this as an option flag to the current formula may be enough. Then you can use with something like brew install zathura --head --no-titlebar
. In which case you can fork the repo, add the option to zathura.rb etc, which it looks like you already did, then Pull Requests -> New Pull Request -> Create Pull Request
from your branch. At the top you'll see something like the picture below which allows you to chose the branch you want to merge with the existing repo.
There also seems to be an issue when I try to use your fork from brew. I haven't looked but maybe the formula needs to explicitly state which tap/formula to use.
EDIT: Just had to untap zegervdv/zathrua first.
❯❯❯ brew install obverser/zathura/zathura
Error: Formulae found in multiple taps:
* obverser/zathura/girara
* zegervdv/zathura/girara
❯❯❯ brew install obverser/zathura/girara
Warning: obverser/zathura/girara 0.3.6 is already installed.
The currently linked version is: HEAD-d99f953
Edit:
yabai -m query --windows --window
states that it cannot be resized. Though it can manually.
@Obverser great work! I do believe trying to merge this upstream is the preferred solution as @typkrft suggested. This way it should always remain supported and we don't need to keep fixing things if something would change after a version upstep. The developers of zathura should also be in a better place to help you integrate this completely.
However, if they are not willing to accept these changes we can integrate them here under a feature flag.
To create a pull request (or merge request as they are called on gitlab):
git checkout -b <branch_name>
)If you run into issues (either on this repo or on the zathura gitlab), feel free to ask here.
Thanks a bunch you guys! I'll definitely look into getting this to the Gitlab source. In terms of the yabai thing, I think that may be the same reason the window's resize frame is slightly larger than the actual window. My theory is that the "decoy" titlebar that I have is actually encasing the entire window, giving it more padding (since I'm getting the 'toplevel' object). I'm going to do some more independent testing, but then I'll look to see if I can get support from the Gitlab.
Did this happen yet?
@Obverser, thanks for all your investigative work and then fix that you published! :)
Did you have any success with your independent testing, or is there anything else we can help with? I noticed there's already an issue in gitlab and they mentioned being in need of a patch (linking here for reference): https://git.pwmt.org/pwmt/zathura/-/issues/239#register-pane
Woah, this is active again! I was still having some bugs before. I'll look more into it now (granted, I'm on Ventura--which may change things). And I'll cross-post any findings onto the gitlab issue.
Got the upstream zathura repo building. Interestingly, though: libmagic on brew installs without the pkgconfig cflags set. I don't know if this is intentional or not (because it still has include/magic.h), but it brings some issues to the latest version.
Haven't done anything to the titlebar just yet. For building, I edited the .pc in /opt/homebrew/Cellar to have cflags and changed meson.build to look for libmagic (I guess just 'magic' doesn't work).
Woah, this is active again!
Yay, @Obverser, it's great to see you back! :D Happy holidays to the tiny macOS zathura userbase :)
Haven't done anything to the titlebar just yet. For building, I edited the .pc in /opt/homebrew/Cellar to have cflags and changed meson.build to look for libmagic (I guess just 'magic' doesn't work).
Noting for anyone following this with an old mac like me: for mac machines not running apple silicon, the Cellar dir is in /usr/local/Cellar/zathura
. I only caught this recently when I was working on another project.
Which cflags in the .pc file (mine was in /usr/local/Cellar/zathura/HEAD-aa5f419/lib/pkgconfig/zathura.pc
, for anyone curious)? When I check mine, I see:
Cflags: -I${includedir}
I'm trying to follow along with your findings, and not let this issue die, but I'm also not familiar with this code base or homebrew development generally.
Either way, thanks for checking back in :)
Happy Holidays! I meant the .pc for libmagic. It only provides Libs: and Libs.private: on my machine (maybe the is apple silicon only?)
After applying similar code from before, we're back to the original issue! Using the custom header bar adds this invisible border around the window. It doesn't seem to be border-width from GtkContainer or margin from GtkWidget in testing. We can't set it to NULL unfortunately, as GTK checks if the object is a header--returns if not.
If you want to recreate where I am, you can clone my repository for zathura. Then, get the dependencies:
brew install cmake meson ninja pkg-config adwaita-icon-theme desktop-file-utils gettext girara glib intltool libmagic sphinx-doc gtk-mac-integration
And build
meson setup build
cd build
ninja
./zathura
Once we get the invisible border removed, we can set up the PR!
Thought it was something with the GTK elements themselves, so I opened the app with the GTK_DEBUG flag set to 'interactive'. Seems like the debugger also has the invisible border. Maybe this is an issue with gtkmacintegration or just gtk on mac in general?
Let me know what y'all think.
hi, is there any update on this?
@csumpasd, @Obverser was looking for feedback on how to proceed, but unfortunately I don't have the expertise to help properly on this issue at this time. Everyone has been really friendly, but this is maintained by volunteers so it gets worked on when individuals have the spare time. If you've got coding experience in this realm, I'm sure the community would love to collaborate 💙
Hello all, and thank you @zegervdv for creating this formula! I wanted to have this implemented as well and did some digging this morning, and found out what the issue is; as well as how to patch it to work, including the correct frame and window management abilities! 🥳
If you want the background:
@Obverser was on the right track early on, as `gtk_window_set_decorated(..., false)` should be the correct call, though I expected more control from the api... Under the hood, it calls `gdk_window_set_decorations(...)` which indeed offers more granular flags as defined by [`WMDecoration`](https://docs.gtk.org/gdk3/flags.WMDecoration.html), e.g.; `GDK_DECOR_TITLE` and `GDK_DECOR_RESIZEH`. This can be patched in relatively easily similary to @Obverser's example above, either in zathura or girara (which I ended doing for easier debugging) along the lines of; ```c ... gdk_window_set_decorations(gtk_widget_get_window(session->gtk.window), GDK_DECOR_ALL | GDK_DECOR_TITLE); ... ``` Except this doesn't work either; it either shows all decorations (i.e., the regular window), or the frameless window but with no resizing & moving. This does not seem like correct behaviour from gtk, so I ended up doing some more digging into the macOS-specific implementation, i.e. `gdk_quartz_window_set_decorations`... https://gitlab.gnome.org/GNOME/gtk/-/blob/gtk-3-24/gdk/quartz/gdkwindow-quartz.c#L2552 ```c else if (decorations == 0) { new_mask = GDK_QUARTZ_BORDERLESS_WINDOW | GDK_QUARTZ_MINIATURIZABLE_WINDOW; } else { /* FIXME: Honor other GDK_DECOR_* flags. */ new_mask = (GDK_QUARTZ_TITLED_WINDOW | GDK_QUARTZ_CLOSABLE_WINDOW | GDK_QUARTZ_MINIATURIZABLE_WINDOW | GDK_QUARTZ_RESIZABLE_WINDOW); } ``` Well there you go. We need to adjust those flags to get our desired behaviour.
Here's a quick summary of how I pached it for myself.
1. Create a local tap if you don't already have, where we'll store the patched formulae. ```sh brew tap-new local ``` 2. Extract (i.e., make local copies) of the necessary formulae; ```sh brew extract gtk+3 local brew extract zegervdv/zathura/girara local brew extract zegervdv/zathura/zathura local ``` 3. Untap this repo to avoid conflicts: ```sh brew untap zegervdv ``` 5. Add patches to the formulae: ```sh brew edit local # this should open your $EDITOR ``` ```ruby # Formulae/gtk+3.rb class Gtkx3 < Formula # ... patch :DATA # ... end __END__ diff --git a/gdk/quartz/gdkwindow-quartz.c b/gdk/quartz/gdkwindow-quartz.c index 5d6d522..d31ee4b 100644 --- a/gdk/quartz/gdkwindow-quartz.c +++ b/gdk/quartz/gdkwindow-quartz.c @@ -2569,7 +2569,9 @@ gdk_quartz_window_set_decorations (GdkWindow *window, new_mask = GDK_QUARTZ_BORDERLESS_WINDOW; } else if (decorations == 0) { - new_mask = GDK_QUARTZ_BORDERLESS_WINDOW | GDK_QUARTZ_MINIATURIZABLE_WINDOW; + new_mask = (GDK_QUARTZ_CLOSABLE_WINDOW | + GDK_QUARTZ_MINIATURIZABLE_WINDOW | + GDK_QUARTZ_RESIZABLE_WINDOW); } else { ``` ```ruby # Formulae/girara.rb class Girara < Formula # ... patch :DATA # ... end __END__ diff --git a/girara/session.c b/girara/session.c index 1dc2fe2..9052926 100644 --- a/girara/session.c +++ b/girara/session.c @@ -445,6 +445,7 @@ girara_session_init(girara_session_t* session, const char* sessionname) .width_inc = 0 }; + gtk_window_set_decorated(GTK_WINDOW(session->gtk.window), false); gtk_window_set_geometry_hints(GTK_WINDOW(session->gtk.window), NULL, &hints, GDK_HINT_MIN_SIZE); /* view */ ``` 6. Install the patched formulae: ``` brew install local/gtk+3 brew install local/girara --HEAD brew install local/zathura --HEAD ``` And you should be good to go, as a quick fix :-)
That's great! Looks like you've solved basically all the issues! It makes sense that we'd have to use some Quartz/MacOS-related tampering to make it work properly.
If you (or other people) would like, I can update my personal forked tap with an option for removing the titlebar, or maybe make a PR soon (would love to get a cask version running so less dependencies are needed). Let me know if you guys are interested!
+ I might look into getting the corners rounded, to make it consistent with other titlebar-less stuff (e.g. Orion Focus mode)
That's great! Looks like you've solved basically all the issues! It makes sense that we'd have to use some Quartz/MacOS-related tampering to make it work properly.
If you (or other people) would like, I can update my personal forked tap with an option for removing the titlebar, or maybe make a PR soon (would love to get a cask version running so less dependencies are needed). Let me know if you guys are interested!
- I might look into getting the corners rounded, to make it consistent with other titlebar-less stuff (e.g. Orion Focus )
Heck yes I'm interested in your tap! And rounded corners would be awesome too, thanks for all the work that you do!
Hello all,
It is possible to add the option "--no-titlebar" to open zathura without title bar in linux?
Thank you
Hello all,
It is possible to add the option "--no-titlebar" to open zathura without title bar in linux?
Thank you
Maybe, but not working for me on MacOS.
hi! is there any way to remove the title bar on the zathura window?
(i.e. the top bar with the dir of the file) thanks!