From e60ce1f6352911b62f5eaace0726fd74b0c431da Mon Sep 17 00:00:00 2001 From: Redacted Date: Sat, 30 Dec 2023 10:05:49 -0500 Subject: [PATCH] Initial commit --- .gitignore | 2 ++ CMakeLists.txt | 14 ++++++++++++++ LICENSE | 22 ++++++++++++++++++++++ include/window.h | 23 +++++++++++++++++++++++ src/window.cpp | 20 ++++++++++++++++++++ 5 files changed, 81 insertions(+) create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 LICENSE create mode 100644 include/window.h create mode 100644 src/window.cpp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2f88b18 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/cmake-build-debug +/.idea diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..d594a07 --- /dev/null +++ b/CMakeLists.txt @@ -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() \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b3dbff0 --- /dev/null +++ b/LICENSE @@ -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. diff --git a/include/window.h b/include/window.h new file mode 100644 index 0000000..3afd7de --- /dev/null +++ b/include/window.h @@ -0,0 +1,23 @@ +#pragma once +#if __linux__ + #include +#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 +} \ No newline at end of file diff --git a/src/window.cpp b/src/window.cpp new file mode 100644 index 0000000..c0c6b3c --- /dev/null +++ b/src/window.cpp @@ -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