-
-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add linux alert #294
Add linux alert #294
Conversation
#elif __APPLE__ | ||
#include "ReveryCocoa.h" | ||
#include "ReveryCocoa.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
courtesy of clang-format
🤦♂️ (I'm hoping its formatting this how cpp
code should be formatted if not can revert its changes)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, interesting! We should have a code standard for our C/C++ code. I'm OK going with clang-format
for this.
(cxx_names dialog) | ||
(c_flags (:include c_flags.sexp)) | ||
(c_library_flags (:include c_library_flags.sexp)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
separate config opt for c_library
not equivalent to library_flags
or any of the others
see here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, thanks for adding this!
| Linux | ||
| Unknown | ||
module C = Configurator.V1 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Split out the functionality to derive flags so each platform can specify a getter, also ran ocamlformat
on the file as I was having difficulty following its layout especially being new to ocaml syntax
@bryphe @OhadRau if either of you have a linux machine I'd really appreciate some help testing this. Locally I'm getting a segfault with the following error
The only reference I can find anywhere to this is this PR from 2012 I'm trying to figure out whether this error is general or relates to some config option or messing about I've done on my setup, don't think I've messed with my gnome setting too much but I might have done. You should be able to build this locally and run the dialog example just to see what happens. As I mentioned above the crash happens in a completely separate project just trying to draw a dialog on my machine, other stuff like creating a window with buttons etc works fine. |
don't currently have a native Linux machine but I can test in WSL if that helps. |
Having trouble getting this to compile. Still fails when trying to include |
thanks for trying it out @OhadRau, if you run not really familiar with WSL not sure how this would work on it tbh |
Yeah, turns out it was just an issue with a cached build so I just deleted |
@OhadRau that's at least consistent behavior, I think it might be something undocumented/not clearly documented in the API. I think that the example snippets probably miss some important bit of setup I need to do as I've tried some other more complete examples that involve opening a full window and that works. Maybe the style context (gtk's terminology) is gotten from the parent window somehow 🤷♂️ |
Ah think I've got it now, the widgets etc. all have to called inside of a |
Some progress here, this now correctly creates a dialog a few things to note, The issues I was having seemed to be because the dialog wasn't associated with an application +/- window (previously tried creating a window, so think this might be more related to the dialog not being associated with an application but Im really not sure) I v. briefly tried seeing if I could use the window handle that's passed in from glfw but not entirely sure how to convert it to a GTKWindow found this but it didn't exactly work but I only tried very briefly Outstanding
|
@bryphe I've got this working locally and would appreciate you having a look over, two things to note which I've left as TODO comments is the conversion of the window handle to a The second thing is that I narrowed down why this wasn't initially working to having to create a I'm not sure how Re. adding |
Thanks for all the work on this @Akin909 ! Will try it on my Linux machine shortly 👍 I noticed the CI build is failing with these errors:
On Windows / Mac - should it be including that header file? Or should that be Linux only? On Linux - perhaps there is an additional include directory we need? |
src/Native/dialog_gtk.c
Outdated
@@ -0,0 +1,32 @@ | |||
#include <glib/gi18n.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I think we'll need to wrap this in something like:
#ifndef WIN32
#ifndef __APPLE
...
#endif
#endif
Since we don't want this code to be picked up for Windows / Mac builds. This is probably why we're getting that glib/gi18n.h
header file build failure on those environments.
| Some pc -> ( | ||
match C.Pkg_config.query pc ~package:"gtk+-3.0" with | ||
| None -> default | ||
| Some conf -> {libs= conf.libs; cflags= conf.cflags; flags= []} ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this return an include directory to, for the location of the header files? We might need that to fix the issue finding glib/gi18n.h
on Linux in CI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to include libgtk-3-dev
as a dependency in CI?
We have our set of includes here:
Line 21 in be1ca7b
- script: sudo apt-get install -y libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libegl1-mesa-dev mesa-utils mesa-utils-extra ragel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bryphe glib/gi18n
might eventually be necessary but isn't actually needed in this current iteration so I will remove it. re. the function it does return the header locations for the package specified in this case "gtk+-3".
I'll add gtk
to the CI I saw that but thought it might be bundled by default with the distro even in CI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Side note we can continuously call pkg_config.query
if we need to derive the paths for other includes (not that this is always necessary)
* to a GTK window, see (for inspiration): | ||
* https://gist.github.com/mmozeiko/2401933b1fa89e5d5bd238b33eab0465 | ||
* | ||
* 2. Get reference to revery application, is there an existing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like if we can figure out issue 1, we might also be able to get the GtkApplication
associated with the window with the gtk_window_get_application
method: https://developer.gnome.org/gtk3/stable/GtkWindow.html#gtk-window-get-application
I suspect there would already be a Gtk application created. We can track this in a separate issue, though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great progress, @Akin909 ! I ran it on my Manjaro box and saw that native dialog pop-up 👍
Here's the remaining set of work I see that we need:
- Fix CI build error on Windows / Mac machines. This should be fixed by using
#ifndef
to conditionally include the body ofdialog_gtk.c
- we shouldn't be hitting those includes on Windows / Mac. - Fix CI build error on Linux. I think this may be resolved by adding
libgtk-3-dev
as a dependency, but we might also need some help frompkg-config
to make sure the right include paths forglib
andgtk
are provided to the C compiler.
We also should track the work in an issue that was documented in dialog_gtk.c
- figuring out how to convert the X11 window to a GTKWindow
, and from there, getting a GTKApplication
, instead of creating a new one.
Sorry about the CI builds not triggering - following up here: https://twitter.com/bryphe/status/1092806881406406656 Kicked off a manual build w/ the latest to see how it works 🤞 |
CI is green now! 🎉 Awesome work @Akin909 - we have the foundation in-place now for native linux integration! |
Very early WIP implementation of gtk dialog alert to fix revery-ui#278 (please ignore the commented out code etc. just trying to get stuff working) Progress so far: No longer chokes on `#include <gtk/gtk.h>` - currently need to tweak the borrowed snippet from revery-ui#278 as an example to create an alert doesn't work as is, I think Things to note/note to self: - [x] I have to rework the `discover.ml` so it can use the pkg_config functionality on linux but behave as normal on other systems - [x] Fix GTK crash on opening dialog - things compile but the function to open a dialog causes a crash, note this also happens in a separate project when I try and create a dialog with the same function (might be specific to my machine or more likely a bug in the code)
Very early WIP implementation of gtk dialog alert to fix #278 (please ignore the commented out code etc. just trying to get stuff working)
Progress so far:
No longer chokes on
#include <gtk/gtk.h>
- currently need to tweak the borrowed snippet from #278 as an example to create an alert doesn't work as is, I thinkThings to note/note to self:
I have to rework the
discover.ml
so it can use the pkg_config functionality on linux but behave as normal on other systemsFix GTK crash on opening dialog - things compile but the function to open a dialog causes a crash, note this also happens in a separate project when I try and create a dialog with the same function (might be specific to my machine or more likely a bug in the code)