Forum

Changing orientation of the screen programmatically


#1

Hello,
We have an app which runs on WebOS and plan to add support for changing screen orientation (using degrees - 0°, 90°, 180°, 270° or at least switching portrait/landscape). I've searched though documentation, LS2 API in particular, and haven't found any appropriate method. The only thing I found is requestedWindowOrientation property on luna-send utility example usage: http://webosose.org/develop/sdk-tools/luna-send/ . But anyway it's no described how to modify this setting.
Would be glad to get any related information.
Kind regards.


#2

See https://github.com/react-tv/node-webos/blob/31207e8804d2ebd42e7f939c7c1dd386ec643076/lib/schema/ApplicationDescription.schema#L156 for possible values. This is also confirmed by the values that were previously existing in Open webOS: https://github.com/webOS-ports/deprecated_webappmanager/blob/a08b4bc8aa68953c6098910518cf7e66b8a9f532/Src/lunaui/cards/CardWebApp.cpp#L195


#3

Hello Herrie,
As I understood these properties are stored in application manifest file (appinfo.json) which contained in packaged application and they cannot be changed dynamically, right?


#4

I don't think there's a luna-send for it, however it seems the following code might still work if you add it to your apps code:
window.PalmSystem.setWindowOrientation("up");

Values that would be accepted are "up", "down", "left", "right".

I got this from the legacy webOS Diagnostics App.


#5

Thanks for your response,
I tried executing this method with different values ("up", "down", "left", "right") but nothing happened i.e. orientation didn't change, and there were no errors.


#6

It does seem to be there in the code as per https://github.com/webosose/chromium53/blob/e71abe77551664c36f50433595fbc06e895219ee/src/injection/palmsystem/palmsystem_injection.cc#L535

Could be you don't need to use window prefix anymore. Otherwise might be good if someone from LG could chip in.


#7

I tried to call setWindowOrientation() without window prefix and it doesn't work either.


#8

Hi,

You should set "screenRotation" using a command below.

luna-send -n 1 -f luna://com.webos.settingsservice/setSystemSettings '{"settings":{"screenRotation":"90"}, "category":"option"}'

You may choose one among "90", "180", "270" and "off" which stands for 0 degree.