GLFW window without titlebar

hi, im trying to find out if there a way to move a OF window position, when decoration is set to false like a normal window in linux
i came a cross with this code but not sure if i can implemented on the main loop of OF

#include <stdio.h>
#include <math.h>
#include <GL/gl.h>
#include <GLFW/glfw3.h>

void cursor_position_callback(GLFWwindow* window, double x, double y);
void mouse_button_callback(GLFWwindow *window, int button, int action, int mods);

int cp_x;
int cp_y;
int offset_cpx;
int offset_cpy;
int w_posx;
int w_posy;
int buttonEvent;

int main(){
    glfwInit();
    glfwWindowHint(GLFW_DECORATED, 0);
    GLFWwindow *window = glfwCreateWindow(640, 480, "Undecorated Resizable", 0, 0);

    int w_width;
    int w_height;
    int ccp_x;
    int ccp_y;

    glfwSetCursorPosCallback(window, cursor_position_callback);
    glfwSetMouseButtonCallback(window, mouse_button_callback);

    glfwMakeContextCurrent(window);


    while(!glfwWindowShouldClose(window)){
        if(buttonEvent == 1){
            glfwGetWindowPos(window, &w_posx, &w_posy);
            glfwSetWindowPos(window, w_posx + offset_cpx, w_posy + offset_cpy);
            offset_cpx = 0;
            offset_cpy = 0;
            cp_x += offset_cpx;
            cp_y += offset_cpy;

        }

        glfwSwapBuffers(window);

        glfwWaitEvents();
     }

    return 0;
}

void cursor_position_callback(GLFWwindow* window, double x, double y){
    if (buttonEvent == 1) {
        offset_cpx = x - cp_x;
        offset_cpy = y - cp_y;
    }
}

void mouse_button_callback(GLFWwindow* window, int button, int action, int mods){
    if(button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_PRESS){
        buttonEvent = 1;
        double x, y;
        glfwGetCursorPos(window, &x, &y);
        cp_x = floor(x);
        cp_y = floor(y);
    }
    if(button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_RELEASE){
        buttonEvent = 0;
        cp_x = 0;
        cp_y = 0;
    }
}

any clues or suggestions of how to do this if it is posible are welcome
thanks

I have done this like so:

main.h

#include "ofMain.h"
#include "ofApp.h"

    int main( ){
    ofGLFWWindowSettings settings;
    //    settings.setGLVersion(3, 2);    // <--- ofxShadertoy NEEDS the GL Programmable Renderer
    //     settings.setGLVersion(4,0);
    //     settings.setGLVersion(2,1); 
    settings.windowMode = OF_WINDOW; //OF_FULLSCREEN;
    //    settings.windowMode = OF_FULLSCREEN;
    settings.decorated = false;
    
    //    settings.decorated = false;
    //    settings.width = 1200;
    //    settings.height = 700;
    settings.setSize(640,1080);
    //    settings.setPosition(ofVec2f(0,0));
    //    settings.resizable = false;
    
    settings.multiMonitorFullScreen = false;
    ofCreateWindow(settings);
    ofRunApp(new ofApp);
    
}

in ofApp.cpp

ofSetFullscreen(true);
ofSetWindowShape(400, 400);
ofSetWindowPosition(10, 10);

Thnks @stephanschulz but what i want its to be able to move or drag the window when the decoration is false , once you put false in decoration the ability to move the window around is lost

2

void ofApp::update(){
    ofSetFullscreen(true);
    ofSetWindowShape(400,400);
    ofSetWindowPosition(400+sin(ofGetElapsedTimef()) * 100, 400+cos(ofGetElapsedTimef())* 100);
}
2 Likes

yes i get that but i want to be able to move the window like set the position of the window at will like a normal window