ForceRotation: Difference between revisions

From Maemo Wiki
Jump to navigationJump to search
imported>aapo
force rotate screen orientaion of N900
 
imported>amigadave
wikify, use <source>
Line 1: Line 1:
If you need the way to force some rotation of your N900 screen, this is for you.
If you need the way to force some rotation of your [[Nokia N900|N900]] screen, this is for you.


/*
<source lang="c">
gcc rotate.c -lX11 -lXrandr
/*
*/
gcc rotate.c -lX11 -lXrandr
#include <X11/Xlib.h>
*/
#include <X11/extensions/Xrandr.h>
#include <X11/Xlib.h>
#include <X11/extensions/Xrandr.h>
static void set_rotation (Rotation r_to) {
 
    Rotation r;
static void set_rotation (Rotation r_to) {
    int screen = -1;
  Rotation r;
    XRRScreenConfiguration* config;
  int screen = -1;
    int current_size=0;
  XRRScreenConfiguration* config;
  int current_size=0;
    Display* display;
 
    Window rootWindow;
  Display* display;
   
  Window rootWindow;
        display = XOpenDisplay(":0");
 
        if (display == NULL) {
      display = XOpenDisplay(":0");
        return;
      if (display == NULL) {
        }
        return;
      }
        screen = DefaultScreen(display);
 
        rootWindow = RootWindow(display, screen);
      screen = DefaultScreen(display);
        XRRRotations(display, screen, &r);
      rootWindow = RootWindow(display, screen);
        config = XRRGetScreenInfo(display, rootWindow);
      XRRRotations(display, screen, &r);
        current_size = XRRConfigCurrentConfiguration (config, &r);
      config = XRRGetScreenInfo(display, rootWindow);
        XRRSetScreenConfig(display, config, rootWindow, current_size, r_to, CurrentTime);
      current_size = XRRConfigCurrentConfiguration (config, &r);
}
      XRRSetScreenConfig(display, config, rootWindow, current_size, r_to, CurrentTime);
}
int main (int argc, char *argv[]) {
 
  set_rotation(RR_Rotate_90);
int main (int argc, char *argv[]) {
  //set_rotation(RR_Rotate_270);
set_rotation(RR_Rotate_90);
  //set_rotation(RR_Rotate_180);
//set_rotation(RR_Rotate_270);
  //set_rotation(RR_Rotate_0);
//set_rotation(RR_Rotate_180);
}
//set_rotation(RR_Rotate_0);
}
</source>
 
[[Category:Development]]
[[Category:N900]]

Revision as of 07:56, 4 May 2011

If you need the way to force some rotation of your N900 screen, this is for you.

<source lang="c"> /* gcc rotate.c -lX11 -lXrandr

  • /
  1. include <X11/Xlib.h>
  2. include <X11/extensions/Xrandr.h>

static void set_rotation (Rotation r_to) {

  Rotation r;
  int screen = -1;
  XRRScreenConfiguration* config;
  int current_size=0;
  Display* display;
  Window rootWindow;
  
      display = XOpenDisplay(":0");
      if (display == NULL) {
       return;
      }
      screen = DefaultScreen(display);
      rootWindow = RootWindow(display, screen);
      XRRRotations(display, screen, &r);
      config = XRRGetScreenInfo(display, rootWindow);
      current_size = XRRConfigCurrentConfiguration (config, &r);
      XRRSetScreenConfig(display, config, rootWindow, current_size, r_to, CurrentTime);

}

int main (int argc, char *argv[]) {

set_rotation(RR_Rotate_90);
//set_rotation(RR_Rotate_270);
//set_rotation(RR_Rotate_180);
//set_rotation(RR_Rotate_0);

} </source>