diff mbox

[Branch,~glmark2-dev/glmark2/trunk] Rev 223: CanvasX11, Doc: Support running in fullscreen mode (--fullscreen).

Message ID 20120619095310.15926.37538.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

alexandros.frantzis@linaro.org June 19, 2012, 9:53 a.m. UTC
------------------------------------------------------------
revno: 223
committer: Alexandros Frantzis <alexandros.frantzis@linaro.org>
branch nick: x11-fullscreen
timestamp: Fri 2012-06-15 12:03:04 +0300
message:
  CanvasX11,Doc: Support running in fullscreen mode (--fullscreen).
modified:
  README.android
  doc/glmark2.1.in
  src/canvas-x11.cpp
  src/canvas-x11.h
  src/options.cpp


--
lp:glmark2
https://code.launchpad.net/~glmark2-dev/glmark2/trunk

You are subscribed to branch lp:glmark2.
To unsubscribe from this branch go to https://code.launchpad.net/~glmark2-dev/glmark2/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'README.android'
--- README.android	2012-05-15 13:10:28 +0000
+++ README.android	2012-06-15 09:03:04 +0000
@@ -36,6 +36,7 @@ 
 --frame-end
 --off-screen
 --reuse-context
+--fullscreen
 -l,--list-scenes
 
 The default visual config used on Android is:

=== modified file 'doc/glmark2.1.in'
--- doc/glmark2.1.in	2012-05-24 10:11:54 +0000
+++ doc/glmark2.1.in	2012-06-15 09:03:04 +0000
@@ -39,6 +39,9 @@ 
 \fB\-s\fR, \fB\-\-size\fR WxH
 Size of the output window (default: 800x600)
 .TP
+\fB\-\-fullscreen\fR
+Run in fullscreen mode (equivalent to --size -1x-1)
+.TP
 \fB\-l\fR, \fB\-\-list\-scenes\fR
 Display information about the available scenes
 and their options

=== modified file 'src/canvas-x11.cpp'
--- src/canvas-x11.cpp	2012-05-11 11:02:37 +0000
+++ src/canvas-x11.cpp	2012-06-15 09:03:04 +0000
@@ -26,6 +26,7 @@ 
 #include "util.h"
 
 #include <X11/keysym.h>
+#include <X11/Xatom.h>
 #include <fstream>
 #include <sstream>
 
@@ -232,6 +233,8 @@ 
 bool
 CanvasX11::ensure_x_window()
 {
+    static const char *win_name("glmark2 "GLMARK_VERSION);
+
     if (xwin_)
         return true;
 
@@ -272,19 +275,28 @@ 
     }
 
     /* set hints and properties */
-    {
-        static const char *name("glmark2 "GLMARK_VERSION);
+    if (fullscreen_) {
+        Atom atom = XInternAtom(xdpy_, "_NET_WM_STATE_FULLSCREEN", True);
+        XChangeProperty(xdpy_, xwin_,
+                        XInternAtom(xdpy_, "_NET_WM_STATE", True),
+                        XA_ATOM, 32, PropModeReplace,
+                        reinterpret_cast<unsigned char*>(&atom),  1);
+    }
+    else {
         XSizeHints sizehints;
         sizehints.min_width  = width_;
         sizehints.min_height = height_;
         sizehints.max_width  = width_;
         sizehints.max_height = height_;
         sizehints.flags = PMaxSize | PMinSize;
-        XSetNormalHints(xdpy_, xwin_, &sizehints);
-        XSetStandardProperties(xdpy_, xwin_, name, name,
-                               None, NULL, 0, &sizehints);
+
+        XSetWMProperties(xdpy_, xwin_, NULL, NULL,
+                         NULL, 0, &sizehints, NULL, NULL);
     }
 
+    /* Set the window name */
+    XStoreName(xdpy_ , xwin_,  win_name);
+
     /* Gracefully handle Window Delete event from window manager */
     Atom wmDelete = XInternAtom(xdpy_, "WM_DELETE_WINDOW", True);
     XSetWMProtocols(xdpy_, xwin_, &wmDelete, 1);
@@ -295,19 +307,36 @@ 
 void
 CanvasX11::resize_no_viewport(int width, int height)
 {
+    bool request_fullscreen = (width == -1 || height == -1);
+
     /* Recreate an existing window only if it has actually been resized */
     if (xwin_) {
-        if (width_ != width || height_ != height) {
+        if (width_ != width || height_ != height ||
+            fullscreen_ != request_fullscreen)
+        {
             XDestroyWindow(xdpy_, xwin_);
             xwin_ = 0;
         }
-        else {
+        else
+        {
             return;
         }
     }
 
-    width_ = width;
-    height_ = height;
+    fullscreen_ = request_fullscreen;
+
+    if (fullscreen_) {
+        /* Get the screen (root window) size */
+        XWindowAttributes window_attr;
+        XGetWindowAttributes(xdpy_, RootWindow(xdpy_, DefaultScreen(xdpy_)), 
+                             &window_attr);
+        width_ = window_attr.width;
+        height_ = window_attr.height;
+    }
+    else {
+        width_ = width;
+        height_ = height;
+    }
 
     if (!ensure_x_window())
         Log::error("Error: Couldn't create X Window!\n");

=== modified file 'src/canvas-x11.h'
--- src/canvas-x11.h	2012-05-11 11:02:37 +0000
+++ src/canvas-x11.h	2012-06-15 09:03:04 +0000
@@ -48,7 +48,7 @@ 
 
 protected:
     CanvasX11(int width, int height) :
-        Canvas(width, height), xwin_(0), xdpy_(0),
+        Canvas(width, height), xwin_(0), xdpy_(0), fullscreen_(false),
         gl_color_format_(0), gl_depth_format_(0),
         color_renderbuffer_(0), depth_renderbuffer_(0), fbo_(0) {}
 
@@ -120,6 +120,7 @@ 
 
     const char *get_gl_format_str(GLenum f);
 
+    bool fullscreen_;
     GLenum gl_color_format_;
     GLenum gl_depth_format_;
     GLuint color_renderbuffer_;

=== modified file 'src/options.cpp'
--- src/options.cpp	2012-05-10 09:18:53 +0000
+++ src/options.cpp	2012-06-15 09:03:04 +0000
@@ -56,6 +56,7 @@ 
     {"reuse-context", 0, 0, 0},
     {"run-forever", 0, 0, 0},
     {"size", 1, 0, 0},
+    {"fullscreen", 0, 0, 0},
     {"list-scenes", 0, 0, 0},
     {"show-all-options", 0, 0, 0},
     {"debug", 0, 0, 0},
@@ -133,6 +134,7 @@ 
            "      --reuse-context    Use a single context for all scenes\n"
            "                         (by default, each scene gets its own context)\n"
            "  -s, --size WxH         Size of the output window (default: 800x600)\n"
+           "      --fullscreen       Run in fullscreen mode (equivalent to --size -1x-1)\n"
            "  -l, --list-scenes      Display information about the available scenes\n"
            "                         and their options\n"
            "      --show-all-options Show all scene option values used for benchmarks\n"
@@ -181,6 +183,8 @@ 
             Options::reuse_context = true;
         else if (c == 's' || !strcmp(optname, "size"))
             parse_size(optarg, Options::size);
+        else if (!strcmp(optname, "fullscreen"))
+            Options::size = std::pair<int,int>(-1, -1);
         else if (c == 'l' || !strcmp(optname, "list-scenes"))
             Options::list_scenes = true;
         else if (!strcmp(optname, "show-all-options"))