Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration window #64

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
resource.rc
.DS_Store

compile_commands.json

.cache

data/
build/
*.res
Expand Down
59 changes: 41 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
cmake_minimum_required(VERSION 3.13)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

project(lwp
LANGUAGES C)

Expand Down Expand Up @@ -35,13 +37,17 @@ if(NOT DEFINED PROGRAM_VERSION)
message(WARNING "Can't determine Layered WallPaper version")
endif()

set(_SOURCE_FILES
main.c
debug.c
parser.c
wallpaper.c
window.c
set(_CORE_SOURCE_FILES
core/main.c
core/debug.c
core/parser.c
core/wallpaper.c
core/window.c
)

set(_CONTROL_SOURCE_FILES
control_panel/main.c
)

# Windows resource file
if(_UNAME STREQUAL "WIN32")
Expand All @@ -54,24 +60,29 @@ if(_UNAME STREQUAL "WIN32")

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resource.template.rc ${CMAKE_CURRENT_SOURCE_DIR}/resource.rc
@ONLY)
list(APPEND _SOURCE_FILES "resource.rc")
list(APPEND _CORE_SOURCE_FILES "resource.rc")
endif()

# SDL2 dependency
find_package(SDL2 REQUIRED CONFIG)
set(_INCLUDE_DIRS ${SDL2_INCLUDE_DIRS})
set(_LIBS ${SDL2_LIBRARIES})
set(_CORE_INCLUDE_DIRS ${SDL2_CORE_INCLUDE_DIRS})
set(_CORE_LIBS ${SDL2_LIBRARIES})

# GTK4 depenency
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK4 REQUIRED IMPORTED_TARGET gtk4)
set(_CONTROL_LIBS PkgConfig::GTK4)

if (_UNAME STREQUAL "DARWIN")
# MacOSX framework dependencies
list(APPEND _LIBS "-framework CoreGraphics" "-framework Foundation")
list(APPEND _CORE_LIBS "-framework CoreGraphics" "-framework Foundation")
endif()

if (_UNAME STREQUAL "LINUX")
# X11 dependency
find_package(X11 REQUIRED)
list(APPEND _INCLUDE_DIRS ${X11_INCLUDE_DIR})
list(APPEND _LIBS ${X11_LIBRARIES})
list(APPEND _CORE_INCLUDE_DIRS ${X11_INCLUDE_DIR})
list(APPEND _CORE_LIBS ${X11_LIBRARIES})
endif()

option(LWP_INSTALL_LAUNCHD "Launch lwp on login (MacOSX only)" OFF)
Expand All @@ -85,13 +96,16 @@ if (_UNAME STREQUAL "DARWIN")
set(_DEFAULT_CONFIG_FILE defaultMac.cfg)
endif()

# Main executable
# Core executable
if (_UNAME STREQUAL "DARWIN")
add_executable(lwp MACOSX_BUNDLE ${_SOURCE_FILES})
add_executable(lwpwlp MACOSX_BUNDLE ${_CORE_SOURCE_FILES})
else()
add_executable(lwp ${_SOURCE_FILES})
add_executable(lwpwlp ${_CORE_SOURCE_FILES})
endif()

# Control executable
add_executable(lwp ${_CONTROL_SOURCE_FILES})

# Windows specific properties for executable
if(_UNAME STREQUAL "WIN32")
set_property(TARGET lwp PROPERTY VS_DPI_AWARE "PerMonitor")
Expand All @@ -101,14 +115,19 @@ if(MSVC)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS")
endif()

target_compile_definitions(lwp PUBLIC __${_UNAME})
target_include_directories(lwp PUBLIC ${_INCLUDE_DIRS})
target_link_libraries(lwp PRIVATE ${_LIBS})
target_compile_definitions(lwpwlp PUBLIC __${_UNAME} VER="${PROGRAM_VERSION}")
target_include_directories(lwpwlp PUBLIC ${_CORE_INCLUDE_DIRS})
target_link_libraries(lwpwlp PRIVATE ${_CORE_LIBS})

target_compile_definitions(lwp PUBLIC __${_UNAME} VER="${PROGRAM_VERSION}")
target_link_libraries(lwp PRIVATE ${_CONTROL_LIBS})

# Installation rules
if(_UNAME STREQUAL "WIN32")
install(TARGETS lwp
DESTINATION .)
install(TARGETS lwpwlp
DESTINATION .)
install(DIRECTORY wallpapers
DESTINATION .)
install(FILES LICENSE.txt
Expand All @@ -122,6 +141,8 @@ if(_UNAME STREQUAL "WIN32")
elseif(_UNAME STREQUAL "LINUX")
install(TARGETS lwp
DESTINATION usr/local/bin)
install(TARGETS lwpwlp
DESTINATION usr/local/bin)
install(DIRECTORY wallpapers
DESTINATION usr/local/share/lwp)
install(FILES LICENSE.txt
Expand All @@ -132,6 +153,8 @@ elseif(_UNAME STREQUAL "LINUX")
else()
install(TARGETS lwp
DESTINATION Layered_WallPaper)
install(TARGETS lwpwlp
DESTINATION Layered_WallPaper)
install(DIRECTORY wallpapers
DESTINATION Layered_WallPaper)
install(FILES LICENSE.txt
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<div align="center">

# LWP
# Layered WallPaper

LWP allows You to create multi-layered parallax wallpapers.<br />
Layered WallPaper allows You to create multi-layered parallax wallpapers.<br />
Each layer moves with Your mouse cursor, creating this beautiful effect.

[![](https://img.shields.io/github/v/release/jszczerbinsky/lwp?style=for-the-badge)](https://github.com/jszczerbinsky/lwp/releases/latest)
[![](https://img.shields.io/github/downloads/jszczerbinsky/lwp/total?style=for-the-badge)](https://github.com/jszczerbinsky/lwp/releases/latest)
[![](https://img.shields.io/github/actions/workflow/status/jszczerbinsky/lwp/build.yml?style=for-the-badge)](https://github.com/jszczerbinsky/lwp)
[![](https://img.shields.io/discord/1077955077974794322?label=DISCORD&style=for-the-badge)](https://discord.gg/gHpbkXJD)
[![](https://img.shields.io/discord/1077955077974794322?label=DISCORD&style=for-the-badge)](https://discord.gg/JmkCqjYFQa)

[Installation](#installation) •
[Configuration](#configuration) •
Expand All @@ -34,9 +34,9 @@ https://user-images.githubusercontent.com/38699473/220888934-09788a6b-873c-469b-
```shell
sudo tar -o -xvf [archive name].tar.gz --directory /
```
- Test lwp by running `lwp`
- Test Layered WallPaper by running `lwp`
- Setting `reload_rootwindow=1` in config file may be necessary on some distributions for Layered WallPaper to work properly (see [configuration](#configuration))
- To make lwp run on startup, add `lwp &` command to Your desktop enviroment `.rc` file
- To make Layered WallPaper run on startup, add `lwp &` command to Your desktop enviroment `.rc` file

#### Build from source instead
- Install `SDL2` using Your package manager. On some distributions `SDL2` doesn't contain development files, so it may be also necessary to install development version of `SDL2`
Expand All @@ -60,9 +60,9 @@ https://user-images.githubusercontent.com/38699473/220888934-09788a6b-873c-469b-
```shell
sudo tar -o -xvf [archive name].tar.gz --directory /
```
- Test lwp by running `lwp`
- Test Layered WallPaper by running `lwp`
- Setting `reload_rootwindow=1` in config file may be necessary on some distributions for Layered WallPaper to work properly (see [configuration](#configuration))
- To make lwp run on startup, add `lwp &` command to Your desktop enviroment `.rc` file
- To make Layered WallPaper run on startup, add `lwp &` command to Your desktop enviroment `.rc` file

</details>

Expand Down Expand Up @@ -196,11 +196,11 @@ https://user-images.githubusercontent.com/38699473/220888934-09788a6b-873c-469b-

## Creating Wallpapers

Want to share Your wallpaper? Join our [discord](https://discord.gg/gHpbkXJD)!
Want to share Your wallpaper? Join our [discord](https://discord.gg/JmkCqjYFQa)!

Parallax wallpapers are not popular. Because of this if You want some cool parallax wallpaper, You have to either find a parallax game background on the internet and use it as a wallpaper or cut some real wallpaper into layers using Gimp or Photoshop.

#### How to create a wallpaper for lwp
#### How to create a wallpaper for Layered WallPaper
- Create a directory for Your wallpaper
- Save each layer to this directory as `.bmp` file and name them `1.bmp`, `2.bmp` ... (`1.bmp` is bottom most layer)
- Create a wallpaper config file and name it `wallpaper.cfg` (You can make a copy from `C:\Program Files\lwp\wallpapers\default-fullhd\wallpaper.cfg`)
Expand Down
67 changes: 67 additions & 0 deletions control_panel/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#include <gtk/gtk.h>
#include <stdio.h>

static FILE *proc;
static GtkWidget *window = NULL;

static void apply_btn_click(GtkWidget *widget, gpointer data)
{
pclose(proc);
proc = popen("./lwpwlp", "r");
}
static void close_btn_click(GtkWidget *widget, gpointer data) {}

static void startup(GtkApplication *app, gpointer user_data)
{
GtkWidget *box;
GtkWidget *btn_box;
GtkWidget *version_label;
GtkWidget *apply_btn;
GtkWidget *close_btn;

window = gtk_application_window_new(app);
gtk_window_set_title(GTK_WINDOW(window), "LayeredWallpaper Control Panel");
gtk_window_set_default_size(GTK_WINDOW(window), 800, 600);
gtk_window_set_hide_on_close(GTK_WINDOW(window), TRUE);

char version_label_str[1024];
sprintf(version_label_str, "Layered WallPaper version: %s", VER);

version_label = gtk_label_new(version_label_str);
box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
btn_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_window_set_child(GTK_WINDOW(window), box);

gtk_box_append(GTK_BOX(box), version_label);

apply_btn = gtk_button_new_with_label("Apply");
close_btn = gtk_button_new_with_label("Close");
g_signal_connect(apply_btn, "clicked", G_CALLBACK(apply_btn_click), NULL);
g_signal_connect(close_btn, "clicked", G_CALLBACK(close_btn_click), app);
gtk_box_append(GTK_BOX(btn_box), apply_btn);
gtk_box_append(GTK_BOX(btn_box), close_btn);

gtk_box_append(GTK_BOX(box), btn_box);

gtk_window_present(GTK_WINDOW(window));

gtk_widget_hide(window);

proc = popen("./lwpwlp", "r");
}

static void activate(GtkApplication *app, gpointer user_data) { gtk_widget_show(window); }

int main(int argc, char *argv[])
{
GtkApplication *app;
int status;

app = gtk_application_new("com.github.jszczerbinsky.lwp", G_APPLICATION_DEFAULT_FLAGS);
g_signal_connect(app, "startup", G_CALLBACK(startup), NULL);
g_signal_connect(app, "activate", G_CALLBACK(activate), NULL);
status = g_application_run(G_APPLICATION(app), argc, argv);
g_object_unref(app);

return status;
}
File renamed without changes.
File renamed without changes.
Loading