kmscube: quick hack for fullscreen
authorTomi Valkeinen <tomi.valkeinen@ti.com>
Tue, 19 Apr 2016 14:19:34 +0000 (17:19 +0300)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Tue, 19 Apr 2016 14:19:34 +0000 (17:19 +0300)
kmscube/cube-x11.cpp
kmscube/cube.cpp
kmscube/cube.h

index 7f01ae840827f513e4d744b7fea40eab4bf0af88..648384d484cb5831a55c0461e0d3af999b028a53 100644 (file)
@@ -1,6 +1,7 @@
 
 #include <X11/Xlib-xcb.h>
 
+#include "cube.h"
 #include "cube-egl.h"
 #include "cube-gles2.h"
 
@@ -12,24 +13,32 @@ void main_x11()
 {
        Display* display = XOpenDisplay(NULL);
 
-       xcb_connection_t *connection = XGetXCBConnection(display);
+       xcb_connection_t *c = XGetXCBConnection(display);
 
        /* Get the first screen */
-       const xcb_setup_t      *setup  = xcb_get_setup (connection);
+       const xcb_setup_t      *setup  = xcb_get_setup (c);
        xcb_screen_t           *screen = xcb_setup_roots_iterator (setup).data;
 
        /* Create the window */
 
-       uint32_t width = 600;
-       uint32_t height = 600;
+       uint32_t width;
+       uint32_t height;
+
+       if (s_fullscreen) {
+               width = screen->width_in_pixels;
+               height = screen->height_in_pixels;
+       } else {
+               width = 600;
+               height = 600;
+       }
 
        const uint32_t xcb_window_attrib_mask = XCB_CW_EVENT_MASK;
        const uint32_t xcb_window_attrib_list[] = {
                XCB_EVENT_MASK_EXPOSURE,
        };
 
-       xcb_window_t window = xcb_generate_id (connection);
-       xcb_create_window (connection,                    /* Connection          */
+       xcb_window_t window = xcb_generate_id (c);
+       xcb_create_window (c,                    /* Connection          */
                           XCB_COPY_FROM_PARENT,          /* depth (same as root)*/
                           window,                        /* window Id           */
                           screen->root,                  /* parent window       */
@@ -41,8 +50,22 @@ void main_x11()
                           xcb_window_attrib_mask,
                           xcb_window_attrib_list);
 
-       xcb_map_window (connection, window);
-       xcb_flush (connection);
+
+#if 0 // Doesn't work
+       if (s_fullscreen) {
+
+               xcb_intern_atom_cookie_t cookie = xcb_intern_atom(c, 0, 12, "_NET_WM_STATE");
+               xcb_intern_atom_reply_t* reply = xcb_intern_atom_reply(c, cookie, 0);
+
+               xcb_intern_atom_cookie_t cookie2 = xcb_intern_atom(c, 0, 24, "_NET_WM_STATE_FULLSCREEN");
+               xcb_intern_atom_reply_t* reply2 = xcb_intern_atom_reply(c, cookie2, 0);
+
+               xcb_change_property(c, XCB_PROP_MODE_REPLACE, window, reply->atom, XCB_ATOM_ATOM , 32, 1, (void*)&reply2->atom);
+       }
+#endif
+
+       xcb_map_window (c, window);
+       xcb_flush (c);
 
        EglState egl(display);
        EglSurface surface(egl, (void*)(uintptr_t)window);
@@ -56,12 +79,12 @@ void main_x11()
        surface.swap_buffers();
 
        xcb_generic_event_t *event;
-       while ( (event = xcb_poll_for_event (connection)) ) {
+       while ( (event = xcb_poll_for_event (c)) ) {
 
                surface.make_current();
                scene.draw(framenum++);
                surface.swap_buffers();
        }
 
-       xcb_disconnect (connection);
+       xcb_disconnect (c);
 }
index 14c340aa566c0156295c15c00e796ce706825dbd..eb2f6134676a5074b0be9138e7540c1add2dcf83 100644 (file)
@@ -32,6 +32,7 @@
 using namespace std;
 
 bool s_verbose;
+bool s_fullscreen;
 
 int main(int argc, char *argv[])
 {
@@ -41,6 +42,11 @@ int main(int argc, char *argv[])
                {
                        s_verbose = true;
                }),
+               Option("f|fullscreen",
+               [&]()
+               {
+                       s_fullscreen = true;
+               }),
        };
 
        optionset.parse(argc, argv);
index 8245f0b5dc312c5da49796760c9a14bcb880f1b8..9a2acb7bdbecb0f8b4ef04d18540fb4752c7f90f 100644 (file)
@@ -1,6 +1,7 @@
 #pragma once
 
 extern bool s_verbose;
+extern bool s_fullscreen;
 
 void main_null();
 void main_gbm();