Howto enable portrait mode support on Fremantle

Re: Howto enable portrait mode support on Fremantle

Aniello Del Sorbo
Karma: 860
2009-08-24 10:45 UTC
Thanks to everyone for clarifying this.
It'll greatly help !

Aniello

2009/8/24 Cornelius Hald <hald@icandy.de>:
> Kimmo, thanks for the clarification! I´ll update the wiki article
> accordingly!
>
> Thanks!
> Conny
>
>
> Kimmo Hämäläinen wrote:
>> On Fri, 2009-08-21 at 15:53 +0200, ext Alberto Garcia wrote:
>>> On Fri, Aug 21, 2009 at 02:53:01PM +0200, Cornelius Hald wrote:
>>>
>>> I'll try to summarize how it works (I'm adding Kimmo to Cc in case I'm
>>> forgetting something, as the rotating itself is done by the desktop,
>>> libhildon only sets a WM hint).
>>>
>>> Let's suppose we open a new window. Before we open that window the
>>> device might already be in portrait mode.
>>>
>>> If the portrait flags of the new window are:
>>>
>>> 1) No flags -> The screen is rotated to landscape mode.
>>
>> Correct.  An example: when you are in portrait mode and suddenly a
>> system-modal dialog pops up without the SUPPORT or REQUEST flag, we go
>> to the landscape mode.
>>
>>> 2) _SUPPORT -> The screen keeps its orientation.
>>
>> Correct ...unless some window has the REQUEST flag. The SUPPORT flag on
>> your window tells that you support the portrait mode, i.e. your window
>> can relayout itself for the portrait mode. The REQUEST flag on your
>> window tells that you want to be in the portrait mode (for whatever
>> reason, not necessarily just because the device is currently in portrait
>> orientation!).  Hildon-desktop is not turning the screen to portrait
>> unless there is at least one visible window with REQUEST and the rest of
>> the visible windows have the SUPPORT (explicit or implicit) flag. These
>> flags are inherited to transient windows, and REQUEST implies the
>> SUPPORT flag.
>>
>>> 3) _SUPPORT + _REQUEST -> The screen is rotated to portrait mode
>>> 4) _REQUEST alone -> I don't think we're using that. Kimmo?
>>
>> REQUEST is the same as REQUEST + SUPPORT. Since there is no sense to
>> request the portrait mode if you don't support it...
>>
>>> To detect whether a device is physically rotated I think you need to
>>> use the DBus API already mentioned in this thread.
>>
>> Correct, the sig_device_orientation_ind signal from MCE.
>>
>>> In other words: using this API alone won't change the orientation of
>>> the screen when the device is physically rotated, am I right Kimmo?
>>
>> Hildon-desktop looks at these flags, it does not listen to the
>> orientation signals, so it does not know how the device is oriented
>> relative to the Earth's crust.  (There is an exception to this, but you
>> are not affected by it.)
>>
>> -Kimmo
>>
>>> Berto
>>
>
>



--

--
anidel
Sent from London, Eng, United Kingdom
  •  Reply

Re: Howto enable portrait mode support on Fremantle

Cornelius Hald
Karma: 573
2009-08-24 17:44 UTC
Hello again :)

Listening to the DBus messages and setting the SUPPORT/REQUEST flags
works and the outcome is as described.

Now the only problem left is the orientation detection during startup.
When doing the call to MCE_DEVICE_ORIENTATION_GET I'm always getting the
following error message:

"The name com.nokia.mce was not provided by any .service files"

Does anyone know what I'm doing wrong? The code is as follows:

DBusError error;
DBusMessage *message, *reply;

message = dbus_message_new_method_call(MCE_SERVICE,
MCE_REQUEST_PATH,
MCE_REQUEST_IF,
MCE_DEVICE_ORIENTATION_GET);

dbus_error_init(&error);
reply = dbus_connection_send_with_reply_and_block(connection, message,
-1, &error);


I hope someone can help, oh and by the way I'm a DBus noob, so it might
be that I'm missing something obvious.

Thanks!
Conny



On Mon, 2009-08-24 at 10:24 +0300, Kimmo Hämäläinen wrote:
> On Fri, 2009-08-21 at 15:53 +0200, ext Alberto Garcia wrote:
> > On Fri, Aug 21, 2009 at 02:53:01PM +0200, Cornelius Hald wrote:
> >
> > I'll try to summarize how it works (I'm adding Kimmo to Cc in case I'm
> > forgetting something, as the rotating itself is done by the desktop,
> > libhildon only sets a WM hint).
> >
> > Let's suppose we open a new window. Before we open that window the
> > device might already be in portrait mode.
> >
> > If the portrait flags of the new window are:
> >
> > 1) No flags -> The screen is rotated to landscape mode.
>
> Correct. An example: when you are in portrait mode and suddenly a
> system-modal dialog pops up without the SUPPORT or REQUEST flag, we go
> to the landscape mode.
>
> > 2) _SUPPORT -> The screen keeps its orientation.
>
> Correct ...unless some window has the REQUEST flag. The SUPPORT flag on
> your window tells that you support the portrait mode, i.e. your window
> can relayout itself for the portrait mode. The REQUEST flag on your
> window tells that you want to be in the portrait mode (for whatever
> reason, not necessarily just because the device is currently in portrait
> orientation!). Hildon-desktop is not turning the screen to portrait
> unless there is at least one visible window with REQUEST and the rest of
> the visible windows have the SUPPORT (explicit or implicit) flag. These
> flags are inherited to transient windows, and REQUEST implies the
> SUPPORT flag.
>
> > 3) _SUPPORT + _REQUEST -> The screen is rotated to portrait mode
> > 4) _REQUEST alone -> I don't think we're using that. Kimmo?
>
> REQUEST is the same as REQUEST + SUPPORT. Since there is no sense to
> request the portrait mode if you don't support it...
>
> > To detect whether a device is physically rotated I think you need to
> > use the DBus API already mentioned in this thread.
>
> Correct, the sig_device_orientation_ind signal from MCE.
>
> > In other words: using this API alone won't change the orientation of
> > the screen when the device is physically rotated, am I right Kimmo?
>
> Hildon-desktop looks at these flags, it does not listen to the
> orientation signals, so it does not know how the device is oriented
> relative to the Earth's crust. (There is an exception to this, but you
> are not affected by it.)
>
> -Kimmo
>
> >
> > Berto
>
  •  Reply

Re: Howto enable portrait mode support on Fremantle

David Weinehall
Karma: 54
2009-08-24 20:07 UTC
On mån, 2009-08-24 at 19:44 +0200, ext Cornelius Hald wrote:
> Hello again :)
>
> Listening to the DBus messages and setting the SUPPORT/REQUEST flags
> works and the outcome is as described.
>
> Now the only problem left is the orientation detection during startup.
> When doing the call to MCE_DEVICE_ORIENTATION_GET I'm always getting the
> following error message:
>
> "The name com.nokia.mce was not provided by any .service files"
>
> Does anyone know what I'm doing wrong? The code is as follows:
>
> DBusError error;
> DBusMessage *message, *reply;
>
> message = dbus_message_new_method_call(MCE_SERVICE,
> MCE_REQUEST_PATH,
> MCE_REQUEST_IF,
> MCE_DEVICE_ORIENTATION_GET);
>
> dbus_error_init(&error);
> reply = dbus_connection_send_with_reply_and_block(connection, message,
> -1, &error);
>
>
> I hope someone can help, oh and by the way I'm a DBus noob, so it might
> be that I'm missing something obvious.

MCE only listens to the system bus, maybe this is your problem?


Regards: David
  •  Reply

Re: Howto enable portrait mode support on Fremantle

Cornelius Hald
Karma: 573
2009-08-24 20:12 UTC
On Mon, 2009-08-24 at 23:07 +0300, David Weinehall wrote:
> MCE only listens to the system bus, maybe this is your problem?

Unfortunately not, I tried both the system bus and the session bus. On
both I get the mentioned error. But thanks for the tip :)

Cheers!
Conny
  •  Reply

Re: Howto enable portrait mode support on Fremantle

David Weinehall
Karma: 54
2009-08-24 20:39 UTC
On mån, 2009-08-24 at 22:12 +0200, ext Cornelius Hald wrote:
> On Mon, 2009-08-24 at 23:07 +0300, David Weinehall wrote:
> > MCE only listens to the system bus, maybe this is your problem?
>
> Unfortunately not, I tried both the system bus and the session bus. On
> both I get the mentioned error. But thanks for the tip :)

Well, everything in your code looks correct (well, you're not doing any
error checking when you call dbus_message_new_method_call(), which means
that you'll miss OOM, but that's unlikely to be the issue here).

I can speculate on three possible issues:

* you're not opening the bus correctly
* mce is not running
* your application doesn't have permission to access the system bus

Without knowing your setup and the rest of your code, I cannot help any
further, I'm afraid :/


Regards: David
  •  Reply

Re: Howto enable portrait mode support on Fremantle

Claudio Saavedra
Karma: 160
2009-08-24 20:52 UTC
El lun, 24-08-2009 a las 23:39 +0300, David Weinehall escribió:
> * mce is not running

I might be missing something, but mce doesn't seem to be running in the
FREMANTLE_X86/ARMEL targets in scratchbox after a simple

af-sb-init.sh start

You probably need to start it by hand.

Feel free to ignore me if you already have it running..

Claudio
  •  Reply

Re: Howto enable portrait mode support on Fremantle

Cornelius Hald
Karma: 573
2009-08-25 07:25 UTC
On Mon, 2009-08-24 at 23:39 +0300, David Weinehall wrote:
> On mån, 2009-08-24 at 22:12 +0200, ext Cornelius Hald wrote:
> > On Mon, 2009-08-24 at 23:07 +0300, David Weinehall wrote:
> > > MCE only listens to the system bus, maybe this is your problem?
> >
> > Unfortunately not, I tried both the system bus and the session bus. On
> > both I get the mentioned error. But thanks for the tip :)
>
> Well, everything in your code looks correct (well, you're not doing any
> error checking when you call dbus_message_new_method_call(), which means
> that you'll miss OOM, but that's unlikely to be the issue here).

Sorry for not providing more information in my last mail, I'll try to do
that now.

First, I'm running Fremantle Beta2 SDK with the X86 target. The DBus
connection I'm getting through libosso. So the call is:
gpointer con = osso_get_sys_dbus_connection(osso_context);

You and Claudio were right, mce was not running at all. I thought it
will be automatically started, but that's not the case. So I now started
it with:
run-standalone.sh /etc/init.d/mce start

The output of 'ps ax|grep -i mce' now is:
8758 ? Ss 0:00 /sbin/mce --daemon

Still the error message I get is the same.

I'm listening on the same DBus connection for orientation-changed
messages and that seems to work. If I send DBus messages using
dbus-send, my callback functions are called. For example my callbacks
are called when I'm doing this:

run-standalone.sh dbus-send --system --type=signal /com/nokia/mce/signal
com.nokia.mce.signal.sig_device_orientation_ind string:'portrait'


Hmm, ok while writing this, I noticed that mce after some time is not
running anymore. So now I started it not using the init script, but
directly with:
run-standalone.sh mce --force-stderr --debug-mode

And voila :) It's working and I'm getting the correct reply when calling
into DBus. So basically my problem is solved. The question now is my
does mce not startup correctly when using the init script?

Thanks David and Claudio for all the help :)
Conny
  •  Reply

Re: Howto enable portrait mode support on Fremantle

David Weinehall
Karma: 54
2009-08-25 08:32 UTC
On tis, 2009-08-25 at 09:25 +0200, ext Cornelius Hald wrote:
> On Mon, 2009-08-24 at 23:39 +0300, David Weinehall wrote:
> > On mån, 2009-08-24 at 22:12 +0200, ext Cornelius Hald wrote:
> > > On Mon, 2009-08-24 at 23:07 +0300, David Weinehall wrote:
> > > > MCE only listens to the system bus, maybe this is your problem?
> > >
> > > Unfortunately not, I tried both the system bus and the session bus. On
> > > both I get the mentioned error. But thanks for the tip :)
> >
> > Well, everything in your code looks correct (well, you're not doing any
> > error checking when you call dbus_message_new_method_call(), which means
> > that you'll miss OOM, but that's unlikely to be the issue here).
>
> Sorry for not providing more information in my last mail, I'll try to do
> that now.
>
> First, I'm running Fremantle Beta2 SDK with the X86 target. The DBus
> connection I'm getting through libosso. So the call is:
> gpointer con = osso_get_sys_dbus_connection(osso_context);
>
> You and Claudio were right, mce was not running at all. I thought it
> will be automatically started, but that's not the case. So I now started
> it with:
> run-standalone.sh /etc/init.d/mce start
>
> The output of 'ps ax|grep -i mce' now is:
> 8758 ? Ss 0:00 /sbin/mce --daemon
>
> Still the error message I get is the same.
>
> I'm listening on the same DBus connection for orientation-changed
> messages and that seems to work. If I send DBus messages using
> dbus-send, my callback functions are called. For example my callbacks
> are called when I'm doing this:
>
> run-standalone.sh dbus-send --system --type=signal /com/nokia/mce/signal
> com.nokia.mce.signal.sig_device_orientation_ind string:'portrait'
>
>
> Hmm, ok while writing this, I noticed that mce after some time is not
> running anymore. So now I started it not using the init script, but
> directly with:
> run-standalone.sh mce --force-stderr --debug-mode
>
> And voila :) It's working and I'm getting the correct reply when calling
> into DBus. So basically my problem is solved. The question now is my
> does mce not startup correctly when using the init script?

I suspect it's because if you're not running it in --debug-mode, it
exits when it notices that it fails to connect to dsme. Check if dsme
is running too... That's the only difference --debug-mode should make
at least.

> Thanks David and Claudio for all the help :)

You're welcome :)


Regards: David
  •  Reply

Re: Howto enable portrait mode support on Fremantle

Cornelius Hald
Karma: 573
2009-08-25 09:16 UTC
On Tue, 2009-08-25 at 11:32 +0300, David Weinehall wrote:
> I suspect it's because if you're not running it in --debug-mode, it
> exits when it notices that it fails to connect to dsme. Check if dsme
> is running too... That's the only difference --debug-mode should make
> at least.

Ok I see, so I tried to run dsme first. It turns out that it's not part
of the default installation of the SDK. Doing 'apt-get install dsme'
installs it without problems. And 'run-standalone.sh /etc/init.d/dsme
start' runs it without problems.

If I now start mce on the command line with the command
'run-standalone.sh mce' it works as expected. Using the init script to
start it still does not work. If I read it correctly the init script is
calling mce like this: 'dsmetool -n 1 -t "/sbin/mce --force-syslog".
If I'm using this command (also with run-standalone.sh) directly on the
terminal nothing happens as well. No error messages as well.

So the bottom line seems to be that mce can be started directly, but
there's a problem when starting it using dsmetool. Maybe something else
is missing?

I think I'll stop here as starting mce with 'mce --debug-mode' is ok for
me. Still, I'm willing to try out a few suggestions or to file a bug
against the SDK if it makes sense...

Cheers!
Conny
  •  Reply

Re: Howto enable portrait mode support on Fremantle

Cornelius Hald
Karma: 573
2009-08-31 09:32 UTC
I´ve updated the wiki page with all the information that was provided in
this thread. If something is not clear, please feel free to update the page.

http://wiki.maemo.org/Using_Fremantle_Widgets#Automatic_Screen_Rotation

Thanks again to everyone who answered on this thread, especially Vlad
who was the first with a working solution. Also the source code of
omweather was very helpful. Big thanks to Kimmo too for the final
clarification :)

Cheers!
Conny


Cornelius Hald wrote:
> Hi all!
>
> For some time already Conboy has the ability to relayout it´s widget
> when switched from landscape into portrait mode.
>
> Now I wanted to know whether or not the window is actually rotated when
> the device is rotated, so I asked on tmo and Andre was so kind and did
> the test. It looks like it is not working[1].
>
> What I did is I added the following line to all windows of my application:
>
> hildon_gtk_window_set_portrait_flags(GTK_WINDOW(win),
> HILDON_PORTRAIT_MODE_SUPPORT);
>
> I assume that HILDON_PORTRAIT_MODE_SUPPORT means that this window is
> supporting the portrait mode and thus can be rotated. And that
> HILDON_PORTRAIT_MODE_REQUEST means that the UI should be switched to
> portrait mode no matter what the orientation of the device is, right?
>
> Is there something else I need to do? Did I do something wrong?
>
> Help would be very welcome :)
>
> Thanks!
> Conny
>
>
> [1] http://talk.maemo.org/showthread.php?t=30883

  •  Reply