How to make window centered in GTK4? - gtk

In GTK3 there was a property on the Gtk.Window class called window-position. By setting this property to Gtk.WindowPosition.CENTER it was possible to tell the window to render in the center of the screen.
In GTK4 this property has been removed. How to achieve the same behavior in GTK4, i.e. how to make the main window of my application to be rendered in the center of the screen?
I checked the migration guide but I couldn't find the solution.

There is no replacement API, since it can't possibly work cross-platform, so it is broken API by definition. As such, it was removed.
For example: this is impossible to implement when running on top of a Wayland session, since the protocol doesn't allow getting/setting global coordinates. If you still want to have something similar working, you'll have to call the specific platform API (for example, X11) for those platforms that you want to support.

Related

How do I customize cursor in MRTK?

I'm struggling to find documentation on cursor customization in MRTK. Consider a plain simple scenario - I want custom cursor when I focus on certain object in the scene.
If you look into this official sample -- EyeTracking, the visual effects of the “cursor” when a user is looking at an object is simply switching the state of the background object (enable/disable). You may refer to the sample to customize the visual effects.
EyeTracking sample is not of much help, MRTK in fact does not provide available tools to customize cursor visuals. I see two options available:
Implement custom BaseCursor similarly to how e.g. AnimatedCursor is implemented and create your own context info class similarly to how CursorContextInfo is done. This is how MRTK modifies cursor when focusing on resize and scale handles.
Modify available pointer prefab, add your custom visuals into it and add a custom singleton script there. Use available focus on/off events on your content objects to modify cursor via singleton methods.

What is the platform renderer for StackLayout?

I have been grepping through Xamarin's source all morning and can't find out what renderer / VisualElement is responsible for either platform's StackLayout. What is the source that converts a LinearLayout to a platform specific view?
Yes, StackLayoutRenderer is what everyone expects Xamarin to do the trick. However, there is no such in Xamarin.
Xamarin handles the native conversion of certain layouts in the ViewRenderer<TView, TNativeView> itself. They are mapped to the corresponding NativeViews. As you mentioned there are no explicit files that I could either see to be sure or claim on it. Ever since I started working in Xamarin, am also not sure about this.
However, I believe the StackLayout is internally mapped to either the RelativeLayout or ViewGroup which I could confirm by seeing the below VisualTree. I got this tree when loading an entry and a label inside a StackLayout.
Maybe, have a look at the ViewRenderer and VisualElementRenderer class files in each native renderers to have an idea.
according to the docs, Android uses View and iOS uses UIView

Weston : Customize composition to duplicate window display

I want to be able to duplicate a window at the compositor/window manager level.
That is, when the user open a weston-terminal, I want to display it as 2 windows, and be able to apply movement/rotation to those windows.
To emphasize, I don't want to have 2 weston-terminal open, I really need to duplicate the window's content on screen.
Is that possible with weston and where should I look in the code?
I already compiled it and learned to rotate/move windows using weston-shell.c but don't know where to look after.
This isn't possible with the Weston implementation, in the manner you've described. You'd have to hack your own Weston implementation to do this, such that one client can bind to multiple surfaces.
An alternative to consider is to have a surface and subsurface, and have you client render to both the main surface and the subsurface.

is it okay to use loadOverlay() in a restartless addon?

Firefox addon. I'm porting an existing addon to a restartless one. I have a panel with a lot of UI elements (mostly boxes/description and images) in it, and it is very convenient for me to define the panel elements in an XUL overlay file. I will have lots of bloated js code if I don't.
The panel element (parent) itself is created in code dynamically, and then I use loadOverlay, wait for the 'merged' event and then append the panel element's children from the overlayed document. I also make sure that the elements are cleaned up upon a remove.
However, using overlays will most probably won't pass an AMO review. And some of the reasons I think are :
In most cases overlay elements will cause problems while removing (eg: toolbar buttons remembering their positions etc.)
There are problems with attaching js/css files in an overlay file.
loadOverlay is buggy (496320, 330458)
And here are my inferences :
loadOverlay() API itself is not deprecated - in fact it is 'not frozen and may change later' - which means possibly it will be use-able in future.
The bug that a second overlay load fails, is not applicable in my case, as I don't initialize without an overlay merge.
Using static overlay for preference windows etc. is perfectly acceptable as of now.
The panel in my case behaves a lot like a preference window (which is brought up on demand and cleaned up upon addon removal)
I don't have any js/css attached to the overlay, nor any event listeners for the elements. The overlay is only used to define boxes and description text - nothing more.
So considering these, is it acceptable to use overlays and loadOverlay() for a restartless addon ? If not, is there an alternative ?
About overlays, by checking source code of restartless addon that extend existing addon (like ehh), I see the overlay.xul is auto merged with the existing addon's. So it shouldn't be a problem to use overlay.

Persistent Logging in Gnome-Shell-Extension development?

I'm trying around with the Javascript-based bindings to build an own Gnome-Shell-Extension which just embeds an webkitview.
But the following 3 lines let completely crash the gnome-shell (top panel disappears, need to re-login to start it again). therefore no way to look into the "Errors"-tab of LookingGlass to figure out, what was wrong.
WebKit = imports.gi.WebKit;
GtkClutter = imports.gi.GtkClutter;
Main.panel._rightBox.add(new GtkClutter.Actor({contents: new WebKit.WebView()}));
Is there any way to get some infos what's going wrong?
you cannot embed a WebKitGtk WebView inside gnome-shell, or any other GTK widget, include GtkClutterEmbed; this is actually a limitation of GTK.
if you want to embed a WebKitGtk WebView one option is to use a separate process, get the XID of the GtkWindow and use a ClutterX11TexturePixmap actor to display it inside an extension. you'll have to pass events from the Clutter actor to your application as well. you can use some form of IPC, like D-Bus, to pass the XID and the events.