Initial commit
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
/cmake-build-debug
|
||||||
|
/.idea
|
14
CMakeLists.txt
Normal file
14
CMakeLists.txt
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.20)
|
||||||
|
project(ReWindow)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
|
add_library(ReWindow SHARED
|
||||||
|
include/window.h
|
||||||
|
src/window.cpp)
|
||||||
|
|
||||||
|
if(UNIX AND NOT APPLE)
|
||||||
|
target_link_libraries(ReWindow PUBLIC X11)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
endif()
|
22
LICENSE
Normal file
22
LICENSE
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
This is free and unencumbered software released into the public domain.
|
||||||
|
|
||||||
|
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||||
|
distribute this software, either in source code form or as a compiled
|
||||||
|
binary, for any purpose, commercial or non-commercial, and by any
|
||||||
|
means.
|
||||||
|
|
||||||
|
In jurisdictions that recognize copyright laws, the author or authors
|
||||||
|
of this software dedicate any and all copyright interest in the
|
||||||
|
software to the public domain. We make this dedication for the benefit
|
||||||
|
of the public at large and to the detriment of our heirs and
|
||||||
|
successors. We intend this dedication to be an overt act of
|
||||||
|
relinquishment in perpetuity of all present and future rights to this
|
||||||
|
software under copyright law.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||||
|
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||||
|
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
OTHER DEALINGS IN THE SOFTWARE.
|
23
include/window.h
Normal file
23
include/window.h
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#pragma once
|
||||||
|
#if __linux__
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#endif
|
||||||
|
namespace ReWindow {
|
||||||
|
#pragma region linux
|
||||||
|
#if __linux__
|
||||||
|
Display* display = XOpenDisplay(nullptr);
|
||||||
|
int defaultScreen = DefaultScreen(display);
|
||||||
|
Visual* visual = DefaultVisual(display,defaultScreen);
|
||||||
|
int depth = DefaultDepth(display, defaultScreen);
|
||||||
|
XSetWindowAttributes windowAttributes;
|
||||||
|
Window createPrimaryWindow(const char* title, int width, int height);
|
||||||
|
void destroyWindow(Window window);
|
||||||
|
#endif
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region windows
|
||||||
|
#if WIN32
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#pragma endregion windows
|
||||||
|
}
|
20
src/window.cpp
Normal file
20
src/window.cpp
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#include "../include/window.h"
|
||||||
|
|
||||||
|
#pragma region linux
|
||||||
|
#if __linux__
|
||||||
|
Window ReWindow::createPrimaryWindow(const char* title, int width, int height) {
|
||||||
|
windowAttributes.border_pixel = BlackPixel(display, defaultScreen);
|
||||||
|
windowAttributes.background_pixel = WhitePixel(display, defaultScreen);
|
||||||
|
windowAttributes.override_redirect = True;
|
||||||
|
windowAttributes.colormap = XCreateColormap(display, RootWindow(display, defaultScreen), visual, AllocNone);
|
||||||
|
windowAttributes.event_mask = ExposureMask;
|
||||||
|
Window window = XCreateWindow(display, RootWindow(display, defaultScreen), 0, 0, width, height, 0, depth, InputOutput, visual, CWBackPixel | CWColormap | CWBorderPixel | CWEventMask, &windowAttributes);
|
||||||
|
XStoreName(display,window,title);
|
||||||
|
return window;
|
||||||
|
}
|
||||||
|
void ReWindow::destroyWindow(Window window) {
|
||||||
|
XDestroySubwindows(display, window);
|
||||||
|
XDestroyWindow(display, window);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#pragma endregion
|
Reference in New Issue
Block a user