Reply
Thread Tools
Posts: 37 | Thanked: 54 times | Joined on Dec 2009
#1
Can someone please give me some hints on the best way to handle porting a simple old-fashioned X11 application which currently relies only on Xlib? I have it mostly working in landscape mode on the N900, but the application fits much better in portrait mode.

Does hildon_gtk_window_set_portrait_flags ultimately use the X RandR extension, or is it doing something else? I guess I can link in libhildon, and enough of libgtk and friends to make it happy, but will I also have to rotate my objects and bitmaps? Or will I then be presented with a 480x800 display rather than the normal 800x480 display (which would be the case if it uses the RandR to rotate the screen)?

I found some statements implying that application screen rotation might be handled via the X RandR extension on the N900, but nothing that looked authoritative.

I'd just look at the source, but, it seems that source isn't available for libhildon? (Why???!!!)

Thanks for any clues.

--Brad
 

The Following User Says Thank You to brad112358 For This Useful Post:
tuminoid's Avatar
Posts: 188 | Thanked: 185 times | Joined on Dec 2009 @ Finland
#2
I'm not sure about the technology behind the feature (I try to steer myself clear of pure X, et al), but AFAIK you are presented with 480*800 screen when in portrait mode. You also don't need to link against hildon I think, since it looks like window property being set via some atom.
__________________
My wiki: User:Tuminoid
cpumem-applet: home | packages - status: 0.0.3 in Extras

cell-modem-ui: home | packages - status: 0.5.1-1 in Extras
nowplayingd: home | packages - status: 0.1-2 in extras-devel
custom-pwkmenu: home - no packages yet.
 
qwerty12's Avatar
Posts: 4,274 | Thanked: 5,358 times | Joined on Sep 2007 @ Looking at y'all and sighing
#3
Two atoms: _HILDON_PORTRAIT_MODE_SUPPORT and _HILDON_PORTRAIT_MODE_REQUEST. Both are of the type XA_CARDINAL, both should be set to 1 and they both should be viewed as 32-bit.

libhildon is open; the bleeding-edge stuff is to be found on maemo.gitorious.org. But as I'm typing this from bed, I'm reluctant to find the link.
 

The Following User Says Thank You to qwerty12 For This Useful Post:
Posts: 37 | Thanked: 54 times | Joined on Dec 2009
#4
Thanks for the help!

Just in case anyone else needs to do full screen portrait mode at the X11 (libX11) level, the following code is what I ended up with. After I got it working, I checked with xrandr via ssh and the debian chroot, and the window manager is indeed rotating the entire screen using the X RandR extension under the covers.

--Brad

#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);
 

The Following 3 Users Say Thank You to brad112358 For This Useful Post:
too's Avatar
Posts: 122 | Thanked: 135 times | Joined on Dec 2009 @ Helsinki
#5
Thanks

complete function which does this:

Code:
#include <X11/Xlib.h>
#include <X11/Xatom.h>

/* Rotate window into portrat mode and make fullscreen */

void portraitmode(Window win)
{
    unsigned char on = 1;
    Display * dpy = XOpenDisplay(0/*null*/);/* or use toolkit's dpy variable */
    Atom newstate;

    XChangeProperty(dpy, win,
		    XInternAtom(dpy, "_HILDON_PORTRAIT_MODE_SUPPORT", True),
		    XA_CARDINAL, 32, PropModeReplace, &on, 1);

    XChangeProperty(dpy, win,
		    XInternAtom(dpy, "_HILDON_PORTRAIT_MODE_REQUEST", True),
		    XA_CARDINAL, 32, PropModeReplace, &on, 1);

    newstate = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", True);
    XChangeProperty(dpy, win,
		    XInternAtom(dpy, "_NET_WM_STATE", True), XA_ATOM, 32,
		    PropModeReplace, (unsigned char *) &newstate, 1);
}
and, parts from gtk program

Code:
#include <gdk/gdkx.h>
...
GtkWidget * mainwin = hildon_stackable_window_new();
...
gtk_widget_show_all (mainwin);
portraitmode(GDK_WINDOW_XID(mainwin->window));

gtk_main();
 

The Following 3 Users Say Thank You to too For This Useful Post:
qwerty12's Avatar
Posts: 4,274 | Thanked: 5,358 times | Joined on Sep 2007 @ Looking at y'all and sighing
#6
Originally Posted by too View Post
Thanks

complete function which does this:

Code:
#include <X11/Xlib.h>
#include <X11/Xatom.h>

/* Rotate window into portrat mode and make fullscreen */

void portraitmode(Window win)
{
    unsigned char on = 1;
    Display * dpy = XOpenDisplay(0/*null*/);/* or use toolkit's dpy variable */
    Atom newstate;

    XChangeProperty(dpy, win,
		    XInternAtom(dpy, "_HILDON_PORTRAIT_MODE_SUPPORT", True),
		    XA_CARDINAL, 32, PropModeReplace, &on, 1);

    XChangeProperty(dpy, win,
		    XInternAtom(dpy, "_HILDON_PORTRAIT_MODE_REQUEST", True),
		    XA_CARDINAL, 32, PropModeReplace, &on, 1);

    newstate = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", True);
    XChangeProperty(dpy, win,
		    XInternAtom(dpy, "_NET_WM_STATE", True), XA_ATOM, 32,
		    PropModeReplace, (unsigned char *) &newstate, 1);
}
and, parts from gtk program

Code:
#include <gdk/gdkx.h>
...
GtkWidget * mainwin = hildon_stackable_window_new();
...
gtk_widget_show_all (mainwin);
portraitmode(GDK_WINDOW_XID(mainwin->window));

gtk_main();
If this is for a GTK+ application, why not just use hildon_gtk_window_set_portrait_flags()?

http://wiki.maemo.org/Using_Fremantl...creen_Rotation explains it quite well.
 

The Following 3 Users Say Thank You to qwerty12 For This Useful Post:
too's Avatar
Posts: 122 | Thanked: 135 times | Joined on Dec 2009 @ Helsinki
#7
Originally Posted by qwerty12 View Post
If this is for a GTK+ application, why not just use hildon_gtk_window_set_portrait_flags()?

http://wiki.maemo.org/Using_Fremantl...creen_Rotation explains it quite well.
Because I did not find that; I spent quite a while searching
for this information and could not get anything that this

Now the above is replaced with:

Code:
    hildon_gtk_window_set_portrait_flags(GTK_WINDOW (mainwin),
					HILDON_PORTRAIT_MODE_REQUEST);
The call gtk_window_fullscreen (GTK_WINDOW (mainwin));
makes title bar vanish, which I did not want, so not called
(The_NET_WM_STATE_FULLSCREEN in my code above does not do this)

Last edited by too; 2010-01-29 at 08:34.
 

The Following User Says Thank You to too For This Useful Post:
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 18:33.