Linux 'Native' Library

Organizing tasks to work on, New Features Ideas, Building LCS & LCB Libraries & Widgets, Redecorating and Modifying the IDE, Hacking / Editing Tools, Compiling the Engine from Source, etc.
User avatar
OpenXTalkPaul
Posts: 2633
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: Linux 'Native' Widgets

Post by OpenXTalkPaul »

Unfortunately it also exhibits the strange behavior I had trying it on macOS, that is the button is clickable once and only once, and then it's as if the button is disabled (although it doesn't render in the disabled, gray appearance). That is probably a result of me stumbling around in the dark trying to find my way with GTK (which I've never used before).

To be clear, I don't think that we need another way to make buttons, this isn't about a button 'widget ', it's about binding our xTalk to GTK libraries so that they may do things for us. The button is a GTK 'Widget' and 'Plug' (weird naming for a 'view'), a Webkit 'WebView' is also a Widget, and a lot more interesting (and slightly more complicated) than a button.
User avatar
OpenXTalkPaul
Posts: 2633
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: Linux 'Native' Widgets

Post by OpenXTalkPaul »

OK so for a GTK 4, Webview2 I asked GPT what's involved in making a GTK window and putting a webview2 view into it.

I cleaned it up a little bit (because ChatGPT AI still just makes up crap), I haven't tested it at all (weekend project):

Code: Select all


To create a window with a WebView using GTK and WebKitGTK, you need to use the WebKitGTK library, 
which provides the WebKit engine as a GTK widget. Below is a step-by-step guide for setting up a simple 
GTK window containing a WebView.

1. Install WebKitGTK
Ensure you have WebKitGTK installed on your system. On most Linux systems, you can install it via:

sudo apt install libwebkit2gtk-4.0-dev

2. Code Example in C
#include <gtk/gtk.h>
#include <webkit2/webkit2.h>

static void on_activate(GtkApplication *app) {
    // Create a new GTK window
    GtkWidget *window = gtk_application_window_new(app);
    gtk_window_set_title(GTK_WINDOW(window), "WebView Example");
    gtk_window_set_default_size(GTK_WINDOW(window), 800, 600);

    // Create a WebKit WebView widget
    WebKitWebView *webview = WEBKIT_WEB_VIEW(webkit_web_view_new());

    // Load a webpage into the WebView
    webkit_web_view_load_uri(webview, "https://www.example.com");

    // Add the WebView to the window
    gtk_window_set_child(GTK_WINDOW(window), GTK_WIDGET(webview));

    // Show the window
    gtk_window_present(GTK_WINDOW(window));
}

int main(int argc, char **argv) {
    // Create a new GTK application
    GtkApplication *app = gtk_application_new("com.example.WebViewApp", G_APPLICATION_FLAGS_NONE);
    g_signal_connect(app, "activate", G_CALLBACK(on_activate), NULL);

    // Run the application
    int status = g_application_run(G_APPLICATION(app), argc, argv);
    g_object_unref(app);

    return status;
}

3. Compilation
Compile the code using gcc, ensuring you link against GTK and WebKitGTK libraries:

gcc -o webview_example webview_example.c `pkg-config --cflags --libs gtk4 webkit2gtk-4.0`
Run the resulting executable:

./webview_example

Key Functions and Components

webkit_web_view_new():
Creates a new WebKitWebView widget.

webkit_web_view_load_uri(WebKitWebView *webview, const gchar *uri):
Loads the specified URI (webpage) into the WebView.

gtk_window_set_child(GtkWindow *window, GtkWidget *child):
Sets the WebView as the child of the GTK window.

4. Dependencies
Ensure the following libraries are installed:

libwebkit2gtk-4.0
libgtk-4.0
You can verify availability with:

pkg-config --modversion webkit2gtk-4.0 gtk4

5. Features of WebKitGTK
Custom URI Loading: You can load HTML strings, local files, or remote web pages.
JavaScript Execution: Use webkit_web_view_run_javascript() to execute JavaScript in the loaded page.
Event Handling: You can connect signals like load-changed to handle page load events.
Would you like to explore advanced features such as:


Creating LiveCode Builder bindings for WebKitGTK?

Example: WebKitGTK Bindings in LCB
Here’s a simple example of LCB bindings for creating a window with a WebView and loading a webpage.

1. LCB Library Structure

library WebKitGTKBindings

use com.LiveCode.FFI
use com.LiveCode.Unicode

metadata title is "WebKitGTK Example"
metadata author is "OpenXTalk"
metadata version is "1.0"

-- Load Libraries
private variable gtkLibrary as external library
private variable webkitLibrary as external library
put "libgtk-4.so" into gtkLibrary
put "libwebkit2gtk-4.0.so" into webkitLibrary

-- Bindings for GTK
private foreign handler gtk_application_new(app_id as Unicode string, flags as Integer) returns Pointer binds to "c:libgtk-4.so:gtk_application_new"
private foreign handler gtk_application_window_new(app_pointer as Pointer) returns Pointer binds to "c:libgtk-4.so:gtk_application_window_new"
private foreign handler gtk_window_set_child(window as Pointer, child as Pointer) binds to "c:libgtk-4.so:gtk_window_set_child"
private foreign handler gtk_window_present(window as Pointer) binds to "c:libgtk-4.so:gtk_window_present"
private foreign handler g_application_run(app_pointer as Pointer, argc as Integer, argv as Pointer) returns Integer binds to "c:libgtk-4.so:g_application_run"
private foreign handler g_signal_connect(instance as Pointer, detailed_signal as Unicode string, callback as Pointer, data as Pointer) returns Integer binds to "c:libgtk-4.so:g_signal_connect"

-- Bindings for WebKitGTK
private foreign handler webkit_web_view_new() returns Pointer binds to "c:libwebkit2gtk-4.0.so:webkit_web_view_new"
private foreign handler webkit_web_view_load_uri(webview as Pointer, uri as Unicode string) binds to "c:libwebkit2gtk-4.0.so:webkit_web_view_load_uri"

-- Public Handler: Run a WebKitGTK App
public handler RunWebKitApp()

--- MAYBE NOT NEEDED -- The Engine probably already inited
    -- Create a new GTK application
    variable app as Pointer
    put gtk_application_new("com.example.WebKitGTKApp", 0) into app
---

    -- Create a GTK application window
    variable window as Pointer
    put gtk_application_window_new(app) into window

    -- Create a WebKit WebView
    variable webview as Pointer
    put webkit_web_view_new() into webview

    -- Load a webpage
    webkit_web_view_load_uri(webview, "https://www.example.com")

    -- Add WebView to the window
    gtk_window_set_child(window, webview)

    -- Show the window
    gtk_window_present(window)

    -- Run the application
    g_application_run(app, 0, empty)
end handler

end library

Once compiled, include the extension in a LiveCode stack and call the handler:


GTK Integration:
You use GTK to create the application window and manage layout.
The WebView is added to the window as a child.
Signal Connections (Optional):
For handling WebView events (e.g., page loaded), use g_signal_connect.

Advanced Features to Explore
JavaScript Execution: Bind webkit_web_view_run_javascript() for executing JavaScript in the WebView.
Signal Handling: Add support for load-changed or other WebKit signals for event-driven functionality.
Custom Content: Bind webkit_web_view_load_html() for loading HTML strings directly.
File Loading: Bind webkit_web_view_load_uri() to load local files using the file:// URI scheme.

Includes a simple C application, and an .lcb library that (allegedly) does the same.
Doesn't seem to difficult to use, we shall see if it works out that way.

I would want to include the binary for libwebkit2gtk-4.0 because I'm not sure that library is installed with GTK 4 by default.
User avatar
OpenXTalkPaul
Posts: 2633
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: Linux 'Native' Widgets

Post by OpenXTalkPaul »

Well I had some inclimate weather things to take care of over the past few days so I didn't get as much play time as I'd have liked.

Additionally GDK, GTK+2+3+4, GTKmm, etc. etc. is very different OOP than the one I've had most experience with (Objective C), so I'm doing a lot of reading up on the whole GNOME/GDK/GTK/etc. ecosystem (25+ years worth of catching up to do)

It's quite confusing the sheer number of libraries, and the fact that GTK2 was still being widely used while GTK3 was out, and it seems the same goes For GTK 3 to GTK 4. Learning about it makes me appreciate the elegance of Objective C even more. GTK is written in C so I guess it is more comparable to Apple/GNUstep's underlying CoreFoundation.

That ChatGTP output I posted above was not very helpful. It just makes up b.s. that it thinks will make you like it. Slap some orange paint on it and it could be President of the US.

However, none of that stopped me from taking a few stabs in the dark :lol: I'll continue to do that as I'm learning until I can do something relevant to OXT with it.

Anyway, I just wanted to put this bookmark here for later.
MCNativeLayerX11::doAttach() is the C++ Engine code that attaches (or tries to attach :| ) a 'Native Layer', so far only used by Browser Widget, on Linux OS (X11)
https://github.com/OpenXTalk-org/OpenXT ... 11.cpp#L99

Note that the Engine on Linux is using the now quite old GTK2 so that might be part of casue for problems like Native Layer issues. Things using GTK 2 should probably be updated to use GTK 3 or GTK 4 ( GTK 5 is in development now too). I'm guessing (hoping) there was some effort to maintain backwards compatibly between these major versions.
User avatar
tperry2x
Posts: 3209
Joined: Tue Dec 21, 2021 9:10 pm
Location: Somewhere in deepest darkest Norfolk, England
Contact:

Re: Linux 'Native' Widgets

Post by tperry2x »

OpenXTalkPaul wrote: Tue Jan 21, 2025 3:14 am That ChatGTP output I posted above was not very helpful. It just makes up b.s. that it thinks will make you like it. Slap some orange paint on it and it could be President of the US.
hahahah, this ^ brilliant :lol:
OpenXTalkPaul wrote: Tue Jan 21, 2025 3:14 amNote that the Engine on Linux is using the now quite old GTK2 so that might be part of casue for problems like Native Layer issues. Things using GTK 2 should probably be updated to use GTK 3 or GTK 4 ( GTK 5 is in development now too). I'm guessing (hoping) there was some effort to maintain backwards compatibly between these major versions.
Yes, which makes perfect sense - and I think that's why when you switch themes that might be a GTK3 or GTK4 - that's when the IDE (engine) crashes - and I'm pretty sure that's the underlying reason.
User avatar
richmond62
Posts: 4831
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: Linux 'Native' Widgets

Post by richmond62 »

Unlike ChatGPT: Mr 'Orange Paint', at least as far as I can see, has done an awful lot of damaging things inside of 24 hours.

If only he were as easy to dismiss as some daft 'bot on the internet: at the flick of a switch.

https://youtu.be/1fk68Wqs4Qg
https://richmondmathewson.owlstown.net/
User avatar
OpenXTalkPaul
Posts: 2633
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: Linux 'Native' Widgets

Post by OpenXTalkPaul »

richmond62 wrote: Tue Jan 21, 2025 8:33 am Unlike ChatGPT: Mr 'Orange Paint', at least as far as I can see, has done an awful lot of damaging things inside of 24 hours.

If only he were as easy to dismiss as some daft 'bot on the internet: at the flick of a switch.

https://youtu.be/1fk68Wqs4Qg
Yes the orange ogre has made me completely disgusted all over again starting with his inaugural speech which was entirely full of propaganda lies, and basically the same sort of insane non-sense ("windmill cancer") from his campaigns and from 1.0 and then pardoning all of the rubes that attacked the capital for him because he's a sore loser and were rightly convicted (some of them already served their sentences, with special 'J6' treatment which investigations showed was better than other prisoners conditions), who like him are traitors, It's not like he's capable of change, or any sort of critical thinking. What is worse this time is he has even more power thanks to the far-right tilted supreme court that he helped put there granting presidents broad immunity to do crimes while in office...

But I'm going to try to ignore mango-Mussolini as much as possible and distract myself by learning GTK/GDK/GIO etc.
User avatar
OpenXTalkPaul
Posts: 2633
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: Linux 'Native' Widgets

Post by OpenXTalkPaul »

'Linux Native widget' is now a GTK library (GTK isn't just for Linuxes)

One of the things that helped me learn what I know about Objective C and Core Foundation has been trying to actually use it to do things (that is the whole point to programming right?), and then fumbling around with it for a bit until it gets closer to what I'm trying to get it to do.

There are several libraries that are intertwined with GTK or built to work in conjunction with it. I've made this reference list of links to all of the documentation for these various libraries to help me look up functions more quickly, along with some notes on the scope of each library:

GLib is the library for data types, macros, type conversions, string utilities, file utilities, a mainloop abstraction, etc.. That's like the Foundation library.
https://docs.gtk.org/glib/
OS Specific GLib docs:
https://docs.gtk.org/glib-unix/
https://docs.gtk.org/glib-win32/

GIO, as you could probably guess, is for abstracting hardware I/O, networking, IPC, settings, and other functionality
https://docs.gtk.org/gio/overview.html

GDK (not to be mixed up with GTK) is abstraction for a bunch of mostly lower level stuff, event handling, canvas drawing/pixel buffers, hooks into lib pango for text layout, multithreading, etc.
https://docs.gtk.org/gdk3/
Cairo is already rolled into and used by the engine, but there's much more to the cairo library than is currently exposed for us to use:
https://www.cairographics.org/manual/
Pango the unicode Internationalized text layout and rendering:
https://docs.gtk.org/Pango/
GDK Pixel Buffer API is for dealing with Pixel image data
https://docs.gtk.org/gdk-pixbuf/

GSK library is "an intermediate layer which provides a rendering API implemented using Cairo, OpenGL or Vulkan"
https://docs.gtk.org/gsk4/
It has some nice things like Bézier curved paths with 'handle-bars' and can use SVG path stings (just like OXT's canvas drawn widgets)
https://docs.gtk.org/gsk4/paths.html#creating-paths

GTK is the GUI 'widgets' toolkit for making windows, menu bars, buttons, hierarchical lists, etc.
GTK 4 (current) Docs:
https://docs.gtk.org/gtk4/
and GTK 3 (older but still newer than GTK 2 currently used in the Linux engine.

ATK Accessibility toolkit is the assistive technology API for helping people with disabilities to operate computers.
https://docs.gtk.org/atk/
User avatar
OpenXTalkPaul
Posts: 2633
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: Linux 'Native' Widgets

Post by OpenXTalkPaul »

There's several libraries available for embedding web stuff in GTK (and other toolkits), I will try to collect reference links to all of them here:

I'm very interested in WebKit since that is the web engine used by Apple's Safari and it's now also the preferred engine for GNOME project, so let's start with that.
Webkit has three branches:

- Webkit works as a single process
https://webkit.org
https://webkitgtk.org

- Webkit2 can use multiple processes (so that should be faster)
https://trac.webkit.org/wiki/WebKit2
https://docs.webkit.org/Deep%20Dive/Arc ... bKit2.html
https://webkitgtk.org/reference/webkit2gtk/2.38.4/
May need to use version 1.x for with GTK2, which that package is here:
https://launchpad.net/ubuntu/bionic/amd ... 1-3ubuntu3

- WPE which is webkit for embedded devices (System-on-chip project boards RPi, Rock Chip, etc.) and designed to be platform agnostic, independent from back-ends like GTK (but has backend support that includes GTK)
https://webkit.org/wpe/
https://wpewebkit.org/reference/stable/wpe-webkit-2.0/
https://wpewebkit.org/blog/02-overview-of-wpe.html
Cog is a small single “window” launcher for the WebKit WPE port:
https://github.com/Igalia/cog

If you've already got Webkit libraries installed, it should include a mini- web browser located here (API version specific):
/usr/lib/x86_64-linux-gnu/webkitgtk-6.0/MiniBrowser
For Webkit2 (current version) should be located here:
/usr/lib/x86_64-linux-gnu/webkit2gtk-4.1/MiniBrowser
previous version 4:
/usr/lib/x86_64-linux-gnu/webkit2gtk-4.0/MiniBrowser

Code: Select all

#include <gtk/gtk.h>
#include <webkit2/webkit2.h>

int main(int argc, char *argv[]) {
    gtk_init(&argc, &argv);

    GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    WebKitWebView *web_view = WEBKIT_WEB_VIEW(webkit_web_view_new());

    gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(web_view));
    webkit_web_view_load_uri(web_view, "https://www.example.com"); 

    gtk_widget_show_all(window);
    gtk_main();

    return 0;
}

Explanation:
	•	Includes: 
	◦	gtk/gtk.h: Header file for the GTK+ toolkit, used to create the window and UI elements.
	◦	webkit2/webkit2.h: Header file for the WebKitGTK library, which provides the web view functionality.

	•	Initialization: 
	◦	gtk_init(&argc, &argv): Initializes the GTK+ toolkit, required before creating any GTK widgets.

	•	Creating the window: 
	◦	GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL): Creates a new top-level window.

	•	Creating the web view: 
	◦	WebKitWebView *web_view = WEBKIT_WEB_VIEW(webkit_web_view_new()): Creates a new WebKit web view widget.

	•	Adding the web view to the window: 
	◦	gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(web_view)): Adds the web view widget to the window as its only child.

	•	Loading a webpage: 
	◦	webkit_web_view_load_uri(web_view, "https://www.example.com"): Loads the specified URL into the web view.

	•	Displaying the window: 
	◦	gtk_widget_show_all(window): Makes the window and all its child widgets visible.

	•	Running the main loop: 
	◦	gtk_main(): Starts the GTK+ event loop, which handles user interactions and keeps the application running until the window is closed.

Key points:
	•	This example creates a simple window with a WebKitGTK web view and loads a webpage into it.
	•	You need to have the necessary libraries installed (libgtk-3-dev and libwebkit2gtk-4.0-dev) to compile and run this code.
	•	For more complex applications, you would typically add event handlers to interact with the web view (like navigation, loading progress, etc.) using GObject signals.
	
User avatar
tperry2x
Posts: 3209
Joined: Tue Dec 21, 2021 9:10 pm
Location: Somewhere in deepest darkest Norfolk, England
Contact:

Re: Linux 'Native' Widgets

Post by tperry2x »

Yes, that is indeed there already. :D
So I suppose the next task is getting a widget to use an instance of this, while being non-blocking, interactive, and in-stack (rather than a floating window)
2025-01-22-17-42-21.png
2025-01-22-17-42-21.png (378.99 KiB) Viewed 19874 times
User avatar
OpenXTalkPaul
Posts: 2633
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: Linux 'Native' Widgets

Post by OpenXTalkPaul »

tperry2x wrote: Wed Jan 22, 2025 5:44 pm Yes, that is indeed there already. :D
So I suppose the next task is getting a widget to use an instance of this, while being non-blocking, interactive, and in-stack (rather than a floating window)
2025-01-22-17-42-21.png
Would be best to use pkg config or 'if there is a file' to check that one of them exists before trying to use it. (I put a stack in colab mega folder that uses the later method).

The thing is Webkit's MiniBrowser cli tool, works fine as a basic browser, you can launch it with some settings switches and a URI, but it doesn't have a IAC or 'server' mode socket communications AFAICT, or interactive shell mode where you could pipe instructions in, so you can't pass it new commands once it is running, As I understand it that is mostly used for debugging Webkit itself.

WPE (Webkit 'Embedded') has a cli browser tool called 'cog'/libcog which I think would be more usable as a slave-process browser.

But right now I'm just trying to figure out how to cast a number (CLong integer) from a script (the windowID of a stack) to a Pointer type in extension builder, then we should be able to have some real fun with stack windows on Linux! It's easy to do on macOS using Objective C methods that do that for NSWindows obj IDs. But for C/C++ pointers I can't find any examples of casting a long-int Number type into a Pointer type. Probably have to build the Pointer struct using 'foreign type' bindings. The windowID of a stack is already like a Pointer (XID) but a 'de-referenced' one (converted to a decimal number). It's the same number you'd get for a window if using a function in a Window Manager tool (like wmctrl).

It's frustrating because what I do find on the net that is related is mostly posts from me! :lol:
User avatar
OpenXTalkPaul
Posts: 2633
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: Linux 'Native' Widgets

Post by OpenXTalkPaul »

OpenXTalkPaul wrote: Thu Jan 23, 2025 5:20 pm how to cast a number (CLong integer) from a script (the windowID of a stack) to a Pointer type in extension builder, then we should be able to have some real fun with stack windows on Linux!
So I asked an AI about X-Window ID from wmctrl (window manager tool), which is the same ID number as our stacks windowID property, converting into a GTK Window (or pointer to) and it had this to say:
Converting a wmctrl window ID to a GTK window involves retrieving the window's XID (X Window ID) using wmctrl and then using that XID within a GTK application to interact with the window.
First, obtain the XID of the desired window using wmctrl -l. This command lists all open windows with their XIDs. Identify the target window and its XID. Then, within a GTK application (e.g., in Python using gi.repository.Gtk), use the Gdk.window_foreign_new() method to create a Gdk.Window object from the XID. Finally, use Gtk.Window.get_window() to get the Gtk.Window.
Then Googled AI overview says:
Gdk.window_foreign_new() is a function in the GTK library that creates a Gdk.Window corresponding to a window that already exists, but was created outside of GTK. It takes a native window handle (an integer representing the window) as an argument and returns a new Gdk.Window object. If the native window does not exist or is invalid, the function returns None.

This function is useful when integrating GTK applications with other applications or libraries that create their own windows. It allows GTK to interact with and manage these external windows as if they were created by GTK itself. For example, it can be used to embed a window created by another application within a GTK window or to receive events from an external window.

It's important to note that the exact type of the window handle argument depends on the underlying windowing system. On X11, it's an XID, on Windows it's an HWND, and on macOS it's an NSWindow pointer. You'll need to use the appropriate type for your platform.
That sounds like just the thing I'm looking for.
gdk_window_foreign_new()
https://refspecs.linuxbase.org/gtk/2.6/ ... oreign-new
Note that function lives in GDK library and not GTK.
Ooo... this one looks like it may be even more appropriate:
gpointer = gdk_xid_table_lookup(XID xid)

https://eccentric.one/misc/pygtk/pygtk2 ... indow.html
https://refspecs.linuxbase.org/gtk/2.6/ ... tiveWindow

We'll see what happens when I get a minute to test this.
User avatar
OpenXTalkPaul
Posts: 2633
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: Linux 'Native' Library

Post by OpenXTalkPaul »

Probably worth looking into what using X11 Xib stuff directly provides us with.
I know X11 is not specific to Linux, but we don't have a working OXT BSD UNIX engine (unless you count macOS X as BSD).

The nice thing about X11 / Xib is that it's still widely used, 40+ years old and still see plenty of use (Wayland is compatible with much of it, but still not yet all of X), and it's unlikely to change in any significant way since it's been frozen / 'maintainence only' development for about a decade!

https://www.x.org/releases/X11R7.6/doc/ ... ibX11.html
https://docs.rs/x11/latest/x11/index.html
https://docs.rs
User avatar
tperry2x
Posts: 3209
Joined: Tue Dec 21, 2021 9:10 pm
Location: Somewhere in deepest darkest Norfolk, England
Contact:

Re: Linux 'Native' Library

Post by tperry2x »

OpenXTalkPaul wrote: Fri Jan 24, 2025 3:05 am ...we don't have a working OXT BSD UNIX engine (unless you count macOS X as BSD)...
I don't, not anymore anyway. I used to, but it's been so heavily altered by Apple now that it's a completely different thing altogether.
OpenXTalkPaul wrote: Fri Jan 24, 2025 3:05 am The nice thing about X11 / Xib is that it's still widely used, 40+ years old and still see plenty of use (Wayland is compatible with much of it, but still not yet all of X), and it's unlikely to change in any significant way since it's been frozen / 'maintainence only' development for about a decade!
Absolutely - I know it's old and moves at a glacial pace, but that's kind of intentional I'm led to believe. They take the mentality of 'fools rush in' with OS updates. But then, a lot of BSD stuff powers network infrastructure (routers and suchlike) where stability is key and things have to run 24-7, 365 days a year without so much as a blip. So I do get why they are reluctant to make sweeping changes.
User avatar
OpenXTalkPaul
Posts: 2633
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: Linux 'Native' Library

Post by OpenXTalkPaul »

I think it's more that people have moved on to Wayland (or they're trying to anyway), which as I understand it works towards being a 1:1 X11 replacement (not there yet, some things should probably be left back in the 1980s), but without some of the technical limitations, adding newer things like support for GPU acceleration ( built into its core, not as an extension with X11).

GTK/GDK is making me a little crazy with this stuff (emphasis mine):
GdkWindow;
An opaque structure representing an onscreen drawable. Pointers to structures of type GdkPixmap, GdkBitmap, and GdkWindow, can often be used interchangeably. The type GdkDrawable refers generically to any of these types.
Anyway, using GDK_window_foreign_new() to wrap a foreign window (XID of the stack window) gives us a pointer to a GDK window as expected. I'm still not sure how to get a GTK window from that ( or attached to that), which is not the same thing ( https://stackoverflow.com/questions/275 ... -gdkwindow ). But just getting it to a GDK window gives us access to some window-managing control. As a test I used GDK_window_iconify() to minimize the test stack via scripting 'directly', without using shell() at all. Now we're getting somewhere! (Yeah, I know there was already syntax in the engine that could do 'iconify', that's not the point).
User avatar
OpenXTalkPaul
Posts: 2633
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: Linux 'Native' Library

Post by OpenXTalkPaul »

OpenXTalkPaul wrote: Fri Jan 24, 2025 11:59 am (Yeah, I know there was already syntax in the engine that could do 'iconify', that's not the point).
I guess 'the point' here is that with this your scripts can iconify ANY window, not just the ones created by the Engine :lol:

I just added a bunch more GDK window management methods, it was mostly cut and paste and changing one word in the binding strings.

WARNING: if you full-screen your XFCE panel menu, it might be difficult to do anything else there after :oops:

One thing is I've been binding them to the earliest version of GTK+ (GTK2) available in the package repos. To change to GTK3 or 4 it should be a simple matter of doing a mass-search and replace of the library name. So far I've avoided any methods that are deprecated in newer versions of GTK (and there's quite a few, it's not just Apple that does that ;) ).
User avatar
tperry2x
Posts: 3209
Joined: Tue Dec 21, 2021 9:10 pm
Location: Somewhere in deepest darkest Norfolk, England
Contact:

Re: Linux 'Native' Library

Post by tperry2x »

OpenXTalkPaul wrote: Fri Jan 24, 2025 11:59 am ..just getting it to a GDK window gives us access to some window-managing control. As a test I used GDK_window_iconify() to minimize the test stack via scripting 'directly', without using shell() at all...
That in itself is very cool (in my opinion). Can you share that stack with me? We can add it to the "Linux Native Library" stack (which works fine btw) - but I'm probably on MX-linux like you :lol:
User avatar
tperry2x
Posts: 3209
Joined: Tue Dec 21, 2021 9:10 pm
Location: Somewhere in deepest darkest Norfolk, England
Contact:

Re: Linux 'Native' Library

Post by tperry2x »

OpenXTalkPaul wrote: Fri Jan 24, 2025 6:05 pm ...I've avoided any methods that are deprecated in newer versions of GTK (and there's quite a few, it's not just Apple that does that ;) ).
That's cool. Yes, Microsoft are prone to constantly changing their names for registry keys and shortcodes for certain sections of the Settings program - so you write a script and it doesn't work as soon as the user does a incremental update.
User avatar
richmond62
Posts: 4831
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: Linux 'Native' Library

Post by richmond62 »

I wonder what 'market'-share MX-Linux holds of the desktop world:
-
MX.png
MX.png (22.63 KiB) Viewed 19669 times
-
https://richmondmathewson.owlstown.net/
User avatar
tperry2x
Posts: 3209
Joined: Tue Dec 21, 2021 9:10 pm
Location: Somewhere in deepest darkest Norfolk, England
Contact:

Re: Linux 'Native' Library

Post by tperry2x »

richmond62 wrote: Fri Jan 24, 2025 6:30 pm I wonder what 'market'-share MX-Linux holds of the desktop world:
I'm sure it doesn't even cast a shadow on the usage charts, however I kind of like that. :D
I mean - the entire usage for Linux is only about 6% at the moment (but it's a 2% increase over last year, so I'll take that as a win).
User avatar
OpenXTalkPaul
Posts: 2633
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: Linux 'Native' Library

Post by OpenXTalkPaul »

tperry2x wrote: Fri Jan 24, 2025 6:10 pm That in itself is very cool (in my opinion). Can you share that stack with me? We can add it to the "Linux Native Library" stack (which works fine btw) - but I'm probably on MX-linux like you :lol:
I am using MX Linux currently, specifically because you are using that.

It's a Library Extension with a testing stack in it's 'samples' sub-folder (where demo stacks go), it's on mega collab in the 'other' folder. So if you sync that, it should be there. It probably will likely only work if you have installed GTK2. I have 2.4.something that I installed from Synaptic, along with GTK 3 and 4 (plus GStreamer, WebKitGTK, and a bunch of other packages). I don't think the '-dev' packages are really needed for our purposes, most of that sort of .h header stuff can be looked at on the web anyway.

I could embed the compiled extension module (.lcm) into a demo stack and load it from there, so that it could work without installing the module, but that would still needs GTK2 installed to do its tricks (the Engine itself binds to GTK2 for some things anyway).

Since I currently haven't included any of the GTK libraries in the Extension's 'code' folder (and that would make the compiled module very large), it expects to have them available already in the system, which is unlikely to be the case for GTK for Windows or macOS, which would need to bind to GTK a Win .dll and Mac .dynlib respectively anyway (see examples in the .lcb source which are linked to 'libgtk2-x11-quartz.dynlib' for MacOS).
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests