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(){
    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);


        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;




    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

I have done this like so:


#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.setPosition(ofVec2f(0,0));
    //    settings.resizable = false;
    settings.multiMonitorFullScreen = false;
    ofRunApp(new ofApp);

in ofApp.cpp

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


void ofApp::update(){
    ofSetWindowPosition(400+sin(ofGetElapsedTimef()) * 100, 400+cos(ofGetElapsedTimef())* 100);

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

1 Like

I want to do the same thing: Create a window without the titlebar and move the window around while dragging on it. Is there a way to do this?

Plus, when I enter and then exit fullscreen mode, the titlebar appears again, how do I keep it gone?


Hey on mac >? or linux i was trying for linux but never got to do it i did found some example for mac

You can try somthing like this:

void ofApp::mouseDragged(int x, int y, int button){
    ofSetWindowPosition(ofGetWindowPositionX() + x - windowX, ofGetWindowPositionY() + y - windowY);

void ofApp::mousePressed(int x, int y, int button){
    windowX = x;
    windowY = y;