Howto enable portrait mode support on Fremantle

Howto enable portrait mode support on Fremantle

Cornelius Hald
Karma: 573
2009-08-21 07:07 UTC
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

Re: Howto enable portrait mode support on Fremantle

daniel wilms
Karma: 597
2009-08-21 07:36 UTC
Hi Conny,

omweather used the orientation switch and it works fine. Perhaps it would
help you to have a look at the sources there:

https://garage.maemo.org/plugins/scmsvn/viewcvs.php/trunk/omweather/src/weather-portrait.c?revision=2951&root=omweather&view=markup

Cheers Daniel

2009/8/21 Cornelius Hald <hald@icandy.de>

> 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

Re: Howto enable portrait mode support on Fremantle

Alberto Garcia
Karma: 702
2009-08-21 12:04 UTC
On Fri, Aug 21, 2009 at 09:07:15AM +0200, Cornelius Hald wrote:

> hildon_gtk_window_set_portrait_flags(GTK_WINDOW(win),
> HILDON_PORTRAIT_MODE_SUPPORT);

Use HILDON_PORTRAIT_MODE_SUPPORT | HILDON_PORTRAIT_MODE_REQUEST

> 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?

Exactly.

_SUPPORT means that e.g. if the device is in portrait mode and your
app comes up, it won't be rotated to landscape.

Berto
  •  Reply

Re: Howto enable portrait mode support on Fremantle

Cornelius Hald
Karma: 573
2009-08-21 12:53 UTC
On Fri, 2009-08-21 at 14:04 +0200, Alberto Garcia wrote:
> On Fri, Aug 21, 2009 at 09:07:15AM +0200, Cornelius Hald wrote:
>
> > hildon_gtk_window_set_portrait_flags(GTK_WINDOW(win),
> > HILDON_PORTRAIT_MODE_SUPPORT);
>
> Use HILDON_PORTRAIT_MODE_SUPPORT | HILDON_PORTRAIT_MODE_REQUEST
>
> > 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?
>
> Exactly.
>
> _SUPPORT means that e.g. if the device is in portrait mode and your
> app comes up, it won't be rotated to landscape.

Ok, so _SUPPORT does _not_ mean that the desktop is automatically
rotated once the device is rotated? I'm still confused sorry...

Maybe you could just write what the expected outcome is when we have one
window open. An on this window we call
hildon_gtk_window_set_portrait_flags().

1) We call it with HILDON_PORTRAIT_MODE_SUPPORT
2) We call it with HILDON_PORTRAIT_MODE_REQUEST
3) We call it with HILDON_PORTRAIT_MODE_SUPPORT|
HILDON_PORTRAIT_MODE_REQUEST

Sorry for being so slow, but I really don't get it :(
Conny
  •  Reply

Re: Howto enable portrait mode support on Fremantle

Andre Klapper
Karma: 891
2009-08-21 12:59 UTC
Am Freitag, den 21.08.2009, 14:04 +0200 schrieb Alberto Garcia:
> On Fri, Aug 21, 2009 at 09:07:15AM +0200, Cornelius Hald wrote:
>
> > hildon_gtk_window_set_portrait_flags(GTK_WINDOW(win),
> > HILDON_PORTRAIT_MODE_SUPPORT);
>
> Use HILDON_PORTRAIT_MODE_SUPPORT | HILDON_PORTRAIT_MODE_REQUEST

Maybe you could add a few lines / example code to
http://wiki.maemo.org/Using_Fremantle_Widgets#Marking_Your_App_As_Portrait_Capable if you find some time?

andre
--
Andre Klapper (maemo.org bugmaster)
  •  Reply

Re: Howto enable portrait mode support on Fremantle

Alberto Garcia
Karma: 702
2009-08-21 13:53 UTC
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.
2) _SUPPORT -> The screen keeps its orientation.
3) _SUPPORT + _REQUEST -> The screen is rotated to portrait mode
4) _REQUEST alone -> I don't think we're using that. Kimmo?

To detect whether a device is physically rotated I think you need to
use the DBus API already mentioned in this thread.

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?

Berto
  •  Reply

Re: Howto enable portrait mode support on Fremantle

Alberto Garcia
Karma: 702
2009-08-21 13:55 UTC
On Fri, Aug 21, 2009 at 02:59:38PM +0200, Andre Klapper wrote:

> > > hildon_gtk_window_set_portrait_flags(GTK_WINDOW(win),
> > > HILDON_PORTRAIT_MODE_SUPPORT);
> >
> > Use HILDON_PORTRAIT_MODE_SUPPORT | HILDON_PORTRAIT_MODE_REQUEST
>
> Maybe you could add a few lines / example code to
> http://wiki.maemo.org/Using_Fremantle_Widgets#Marking_Your_App_As_Portrait_Capable if you find some time?

Sure :) I'd appreciate if you or someone could file a bug about that
(at this moment I'm very busy with other things).

Berto
  •  Reply

Re: Howto enable portrait mode support on Fremantle

Cornelius Hald
Karma: 573
2009-08-21 13:59 UTC
On Fri, 2009-08-21 at 15:55 +0200, Alberto Garcia wrote:
> On Fri, Aug 21, 2009 at 02:59:38PM +0200, Andre Klapper wrote:
>
> > > > hildon_gtk_window_set_portrait_flags(GTK_WINDOW(win),
> > > > HILDON_PORTRAIT_MODE_SUPPORT);
> > >
> > > Use HILDON_PORTRAIT_MODE_SUPPORT | HILDON_PORTRAIT_MODE_REQUEST
> >
> > Maybe you could add a few lines / example code to
> > http://wiki.maemo.org/Using_Fremantle_Widgets#Marking_Your_App_As_Portrait_Capable if you find some time?
>
> Sure :) I'd appreciate if you or someone could file a bug about that
> (at this moment I'm very busy with other things).

Don't worry, I'll add this information once we have confirmed
information how everything works and what the best practice is.

Conny
  •  Reply

Re: Howto enable portrait mode support on Fremantle

2009-08-24 07:24 UTC
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

Cornelius Hald
Karma: 573
2009-08-24 10:43 UTC
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
>
  •  Reply
1 2 3 next »