💾 Archived View for bbs.geminispace.org › s › Lagrange-Issues › 87 captured on 2024-08-19 at 00:56:35. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
so, adding these lines to code won't harm if the code runs on any linux/x11, but will mark the app as rotatable in hildon desktop (maemo leste).
(in theory hildon doesn't work only in maemo, it was working in postmarketos, but there is no maintainer now, and recently someone was porting it to... debian? mobian? i don't remember).
(another background reminder is that i build lagrange with mobile interface and package it for maemo, and i very much suffes that it is not available in postmarketos in mobile form, but only in desktop form)
the code in C:
int value = True; Atom atom = XInternAtom(app->dpy, "_HILDON_PORTRAIT_MODE_SUPPORT", False); if (atom != None) XChangeProperty(dpy, win, atom, XA_ATOM, 32, PropModeReplace, (unsigned char*)&value, 1);
it sets the flag to the window, which makes the app rotatable. as i understand on window size change, lagrange will rearrange its controls. so the only thing that needs to be is to tell the hildon desktop that this window is actually rotatable, so it will try to rotate it, and lagrange will later handle the change.
oh, i found EXACT code which works by only using Xlib:
#include <X11/Xatom.h> long on = 1; /* Rotate window into portrat mode and make fullscreen */ XChangeProperty(dpy, mainW, XInternAtom(dpy, "_HILDON_PORTRAIT_MODE_SUPPORT", True), XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &on, 1); XChangeProperty(dpy, mainW, XInternAtom(dpy, "_HILDON_PORTRAIT_MODE_REQUEST", True), XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &on, 1); Atom newstate = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", True); XChangeProperty(dpy, mainW, XInternAtom(dpy, "_NET_WM_STATE", True), XA_ATOM, 32, PropModeReplace, (unsigned char *) &newstate, 1);
i did this in my pascal app even, but by using gdk calls.
pascal code:
procedure TForm1.FormActivate(Sender: TObject); var widget: PGtkWidget; atom: TGdkAtom; value: cardinal; begin widget := PGtkWidget(Handle); if (widget <> nil) and (widget^.window <> nil) and (not FWinPropertySet) then begin FWinPropertySet := True; atom := gdk_atom_intern('_HILDON_PORTRAIT_MODE_SUPPORT', True); value := 1; if atom <> 0 then begin gdk_property_change(widget^.window, atom, gdk_x11_xatom_to_atom(XA_CARDINAL), 32, GDK_PROP_MODE_REPLACE, @value, 1); end; end; end;
another article on how to make a rotatable window:
see the automatic screen rotation part
in short, that part says:
------------------------------
Whether or not your application is rotated depends on a couple of things:
There are two X window properties which you can set on your windows.
Those tell the system what to do. The type of the value of the properties is XA_CARDINAL where 0 means "off", and 1 stands for "on". Other values may get other meaning in the future.
HILDON_PORTRAIT_MODE_SUPPORT tells the system that your application can be rotated, so it won't prevent any other application from rotating.
HILDON_PORTRAIT_MODE_REQUEST tells the system that your application wants to be rotated.
---------------------------------
this addition does not affect how the app works under regular linux/x11, but it becomes rotatable under hildon desktop / maemo.
🐞 Issue #87 in s/Lagrange-Issues
Jul 30 · 3 weeks ago