Creating borderless window?

hi everybody
how can i create borderless window (especially kde)
is there any direct way to do it? if no how can i use a window created by xlib (with overrideredirect)??? or any other way… :confused:

try this:

  
#include<stdlib.h>
#include<math.h>
#include<GL/glx.h>
#include<GL/glu.h>

Display                 *dpy    = XOpenDisplay(NULL);
Window                  root    = DefaultRootWindow(dpy);
GLint                   att[]   = {GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, True, None};
XVisualInfo             *vi     = glXChooseVisual(dpy, 0, att);
GLXContext              glc     = glXCreateContext(dpy, vi, NULL, False);
Visual                  *vis    = DefaultVisual(dpy, 0);
Colormap                cmap    = XCreateColormap(dpy, root, vis, AllocNone);
unsigned int            w       = XDisplayWidth(dpy, 0) / 2;
unsigned int            h       = XDisplayHeight(dpy, 0) / 2;
int                     dep     = DefaultDepth(dpy, 0);
int                     cmask   = CWColormap | CWBorderPixel | CWEventMask | CWOverrideRedirect;
XWindowAttributes       gwa;
Window                  win;

int main(int argc, char *argv[]){
 XSetWindowAttributes   swa;
 XEvent                 xev;

 swa.colormap           = cmap;
 swa.border_pixel       = 0;
 swa.event_mask         = ExposureMask;
 swa.override_redirect  = true;
 win = XCreateWindow(dpy, root, 0, 0, w, h, 0, dep, InputOutput, vis, cmask, &swa);
 XMapWindow(dpy, win);

 glXMakeCurrent(dpy, win, glc);
 glClearColor(0.00, 0.00, 0.60, 1.00);

 glMatrixMode(GL_PROJECTION);
 glLoadIdentity();
 glOrtho(-1., 1., -1., 1., 1., 100.);

 glMatrixMode(GL_MODELVIEW);
 glLoadIdentity();
 gluLookAt(0., 0., 10., 0., 0., 0., 0., 1., 0.);

 while(1) {
        XNextEvent(dpy, &xev);

        if(xev.type == Expose) {
                XGetWindowAttributes(dpy, win, &gwa);
                glViewport(0, 0, gwa.width, gwa.height);
                glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
                // DRAW SOMETHING
                glXSwapBuffers(dpy, win); } } }
//
//      gcc -o gl-base gl-base.cc -lX11 -lGL -lGLU -lm
//

for borderless windows you may need to grab keyboard/pointer with XGrabPointer/XGrabKeyboard to receive events.

but you should use these functions very carefully: if you call them with wrong parameters and have a borderless, full-screen window, it may be possible that you cannot stop your app and have to turn off the computer.

to avoid this, set up a frame counter and automatically exit the app when a certain amount of frames (1000, maybe) has been reached.

RigidBody is right, I use the same code in my application.
But don’t worry about having a fullscreen application window. You can still use another terminal (Ctrl-Alt-F1), login and kill your app.

thanks for that
it helped me really so much
by the way thanks for fullscreen
i can handle it :slight_smile:

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.