minor restructure

This commit is contained in:
Will McKinnon 2022-05-16 23:08:55 -04:00
parent 4891c1661c
commit ed98da84bb
6 changed files with 975 additions and 970 deletions

View file

@ -1,11 +1,10 @@
# swaypower: A Beautiful Sway Fork # swaypower: A Beautiful Sway Fork
Sway is an incredible window manager, and certainly one of if the the most well established wayland window managers. However, it is restricted in its feature set to include only what i3 included. This fork expands sway's featureset to include the following: Sway is an incredible window manager, and certainly one of the most well established wayland window managers. However, it is restricted to only include the functionality that existed in i3. This fork ditches the simple wlr_renderer, and replaces it with a fancy GLES2 renderer with functionality borrowed from the original simple renderer and [Hyprland](https://github.com/vaxerski/Hyprland). This, along with a couple of minor changes, expands sway's featureset to include the following:
+ **[Scratchpad treated as minimize](https://github.com/WillPower3309/swaypower/commit/f6aac41efee81c3edfda14be8ddb375827c81d9e)**: Allows docks, or panels with a taskbar, to correctly interpret minimize / unminimize requests ([thanks to LCBCrion](https://github.com/swaywm/sway/issues/6457))
+ **Default to not compiling swaybar**: Many users replace swaybar with the far more capable [waybar](https://github.com/Alexays/Waybar), this repo cuts out the bloat by not including swaybar by default
+ **Add a nix flake to the repo**: Allows nixos users to easily contribute to and test this repo
+ **Scratchpad treated as minimize**: Allows docks, or panels with a taskbar, to correctly interpret minimize / unminimize requests ([thanks to LCBCrion](https://github.com/swaywm/sway/issues/6457))
+ **Default to not compiling swaybar**: Many users replace swaybar with the far more capable [waybar](https://github.com/Alexays/Waybar), swaypower cuts out the bloat by not including swaybar by default
+ **Add a nix flake to the repo**: Allows nixos users to easily contribute to and test this project
## Roadmap: ## Roadmap:
+ fade in / out animations + fade in / out animations

View file

@ -13,9 +13,84 @@
#include <wlr/types/wlr_matrix.h> #include <wlr/types/wlr_matrix.h>
#include <wlr/util/box.h> #include <wlr/util/box.h>
#include "log.h" #include "log.h"
#include "sway/desktop/renderer/opengl.h" #include "sway/desktop/opengl.h"
// TODO: update to hyprland shaders (add sup for rounded corners + add blur shaders // TODO: update to hyprland shaders (add sup for rounded corners + add blur shaders)
/************************
Shaders
*************************/
// Colored quads
const GLchar quad_vertex_src[] =
"uniform mat3 proj;\n"
"uniform vec4 color;\n"
"attribute vec2 pos;\n"
"attribute vec2 texcoord;\n"
"varying vec4 v_color;\n"
"varying vec2 v_texcoord;\n"
"\n"
"void main() {\n"
" gl_Position = vec4(proj * vec3(pos, 1.0), 1.0);\n"
" v_color = color;\n"
" v_texcoord = texcoord;\n"
"}\n";
const GLchar quad_fragment_src[] =
"precision mediump float;\n"
"varying vec4 v_color;\n"
"varying vec2 v_texcoord;\n"
"\n"
"void main() {\n"
" gl_FragColor = v_color;\n"
"}\n";
// Textured quads
const GLchar tex_vertex_src[] =
"uniform mat3 proj;\n"
"attribute vec2 pos;\n"
"attribute vec2 texcoord;\n"
"varying vec2 v_texcoord;\n"
"\n"
"void main() {\n"
" gl_Position = vec4(proj * vec3(pos, 1.0), 1.0);\n"
" v_texcoord = texcoord;\n"
"}\n";
const GLchar tex_fragment_src_rgba[] =
"precision mediump float;\n"
"varying vec2 v_texcoord;\n"
"uniform sampler2D tex;\n"
"uniform float alpha;\n"
"\n"
"void main() {\n"
" gl_FragColor = texture2D(tex, v_texcoord) * alpha;\n"
"}\n";
const GLchar tex_fragment_src_rgbx[] =
"precision mediump float;\n"
"varying vec2 v_texcoord;\n"
"uniform sampler2D tex;\n"
"uniform float alpha;\n"
"\n"
"void main() {\n"
" gl_FragColor = vec4(texture2D(tex, v_texcoord).rgb, 1.0) * alpha;\n"
"}\n";
const GLchar tex_fragment_src_external[] =
"#extension GL_OES_EGL_image_external : require\n\n"
"precision mediump float;\n"
"varying vec2 v_texcoord;\n"
"uniform samplerExternalOES texture0;\n"
"uniform float alpha;\n"
"\n"
"void main() {\n"
" gl_FragColor = texture2D(texture0, v_texcoord) * alpha;\n"
"}\n";
/************************
Matrix Consts
*************************/
static const GLfloat flip_180[] = { static const GLfloat flip_180[] = {
1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
@ -30,6 +105,10 @@ static const GLfloat verts[] = {
0, 1, // bottom left 0, 1, // bottom left
}; };
/************************
General Functions
*************************/
static GLuint compile_shader(GLuint type, const GLchar *src) { static GLuint compile_shader(GLuint type, const GLchar *src) {
GLuint shader = glCreateShader(type); GLuint shader = glCreateShader(type);
glShaderSource(shader, 1, &src, NULL); glShaderSource(shader, 1, &src, NULL);
@ -120,7 +199,7 @@ struct gles2_renderer *gles2_renderer_create(struct wlr_backend *backend) {
// init shaders // init shaders
GLuint prog; GLuint prog;
prog = link_program(renderer, quad_vertex_src, quad_fragment_src); prog = link_program(quad_vertex_src, quad_fragment_src);
renderer->shaders.quad.program = prog; renderer->shaders.quad.program = prog;
if (!renderer->shaders.quad.program) { if (!renderer->shaders.quad.program) {
goto error; goto error;
@ -129,7 +208,7 @@ struct gles2_renderer *gles2_renderer_create(struct wlr_backend *backend) {
renderer->shaders.quad.color = glGetUniformLocation(prog, "color"); renderer->shaders.quad.color = glGetUniformLocation(prog, "color");
renderer->shaders.quad.pos_attrib = glGetAttribLocation(prog, "pos"); renderer->shaders.quad.pos_attrib = glGetAttribLocation(prog, "pos");
prog = link_program(renderer, tex_vertex_src, tex_fragment_src_rgba); prog = link_program(tex_vertex_src, tex_fragment_src_rgba);
renderer->shaders.tex_rgba.program = prog; renderer->shaders.tex_rgba.program = prog;
if (!renderer->shaders.tex_rgba.program) { if (!renderer->shaders.tex_rgba.program) {
goto error; goto error;
@ -140,7 +219,7 @@ struct gles2_renderer *gles2_renderer_create(struct wlr_backend *backend) {
renderer->shaders.tex_rgba.pos_attrib = glGetAttribLocation(prog, "pos"); renderer->shaders.tex_rgba.pos_attrib = glGetAttribLocation(prog, "pos");
renderer->shaders.tex_rgba.tex_attrib = glGetAttribLocation(prog, "texcoord"); renderer->shaders.tex_rgba.tex_attrib = glGetAttribLocation(prog, "texcoord");
prog = link_program(renderer, tex_vertex_src, tex_fragment_src_rgbx); prog = link_program(tex_vertex_src, tex_fragment_src_rgbx);
renderer->shaders.tex_rgbx.program = prog; renderer->shaders.tex_rgbx.program = prog;
if (!renderer->shaders.tex_rgbx.program) { if (!renderer->shaders.tex_rgbx.program) {
goto error; goto error;
@ -151,7 +230,7 @@ struct gles2_renderer *gles2_renderer_create(struct wlr_backend *backend) {
renderer->shaders.tex_rgbx.pos_attrib = glGetAttribLocation(prog, "pos"); renderer->shaders.tex_rgbx.pos_attrib = glGetAttribLocation(prog, "pos");
renderer->shaders.tex_rgbx.tex_attrib = glGetAttribLocation(prog, "texcoord"); renderer->shaders.tex_rgbx.tex_attrib = glGetAttribLocation(prog, "texcoord");
prog = link_program(renderer, tex_vertex_src, tex_fragment_src_external); prog = link_program(tex_vertex_src, tex_fragment_src_external);
renderer->shaders.tex_ext.program = prog; renderer->shaders.tex_ext.program = prog;
if (!renderer->shaders.tex_ext.program) { if (!renderer->shaders.tex_ext.program) {
goto error; goto error;
@ -209,8 +288,7 @@ static void gles2_render_rect(struct gles2_renderer *renderer, const struct wlr_
wlr_matrix_multiply(gl_matrix, renderer->projection, matrix); wlr_matrix_multiply(gl_matrix, renderer->projection, matrix);
wlr_matrix_multiply(gl_matrix, flip_180, gl_matrix); wlr_matrix_multiply(gl_matrix, flip_180, gl_matrix);
// OpenGL ES 2 requires the glUniformMatrix3fv transpose parameter to be set // OpenGL ES 2 requires the glUniformMatrix3fv transpose parameter to be set to GL_FALSE
// to GL_FALSE
wlr_matrix_transpose(gl_matrix, gl_matrix); wlr_matrix_transpose(gl_matrix, gl_matrix);
if (color[3] == 1.0) { if (color[3] == 1.0) {
@ -224,8 +302,7 @@ static void gles2_render_rect(struct gles2_renderer *renderer, const struct wlr_
glUniformMatrix3fv(renderer->shaders.quad.proj, 1, GL_FALSE, gl_matrix); glUniformMatrix3fv(renderer->shaders.quad.proj, 1, GL_FALSE, gl_matrix);
glUniform4f(renderer->shaders.quad.color, color[0], color[1], color[2], color[3]); glUniform4f(renderer->shaders.quad.color, color[0], color[1], color[2], color[3]);
glVertexAttribPointer(renderer->shaders.quad.pos_attrib, 2, GL_FLOAT, GL_FALSE, glVertexAttribPointer(renderer->shaders.quad.pos_attrib, 2, GL_FLOAT, GL_FALSE, 0, verts);
0, verts);
glEnableVertexAttribArray(renderer->shaders.quad.pos_attrib); glEnableVertexAttribArray(renderer->shaders.quad.pos_attrib);

File diff suppressed because it is too large Load diff

View file

@ -1,68 +0,0 @@
#include <GLES2/gl2.h>
// Colored quads
const GLchar quad_vertex_src[] =
"uniform mat3 proj;\n"
"uniform vec4 color;\n"
"attribute vec2 pos;\n"
"attribute vec2 texcoord;\n"
"varying vec4 v_color;\n"
"varying vec2 v_texcoord;\n"
"\n"
"void main() {\n"
" gl_Position = vec4(proj * vec3(pos, 1.0), 1.0);\n"
" v_color = color;\n"
" v_texcoord = texcoord;\n"
"}\n";
const GLchar quad_fragment_src[] =
"precision mediump float;\n"
"varying vec4 v_color;\n"
"varying vec2 v_texcoord;\n"
"\n"
"void main() {\n"
" gl_FragColor = v_color;\n"
"}\n";
// Textured quads
const GLchar tex_vertex_src[] =
"uniform mat3 proj;\n"
"attribute vec2 pos;\n"
"attribute vec2 texcoord;\n"
"varying vec2 v_texcoord;\n"
"\n"
"void main() {\n"
" gl_Position = vec4(proj * vec3(pos, 1.0), 1.0);\n"
" v_texcoord = texcoord;\n"
"}\n";
const GLchar tex_fragment_src_rgba[] =
"precision mediump float;\n"
"varying vec2 v_texcoord;\n"
"uniform sampler2D tex;\n"
"uniform float alpha;\n"
"\n"
"void main() {\n"
" gl_FragColor = texture2D(tex, v_texcoord) * alpha;\n"
"}\n";
const GLchar tex_fragment_src_rgbx[] =
"precision mediump float;\n"
"varying vec2 v_texcoord;\n"
"uniform sampler2D tex;\n"
"uniform float alpha;\n"
"\n"
"void main() {\n"
" gl_FragColor = vec4(texture2D(tex, v_texcoord).rgb, 1.0) * alpha;\n"
"}\n";
const GLchar tex_fragment_src_external[] =
"#extension GL_OES_EGL_image_external : require\n\n"
"precision mediump float;\n"
"varying vec2 v_texcoord;\n"
"uniform samplerExternalOES texture0;\n"
"uniform float alpha;\n"
"\n"
"void main() {\n"
" gl_FragColor = texture2D(texture0, v_texcoord) * alpha;\n"
"}\n";

View file

@ -14,15 +14,13 @@ sway_sources = files(
'desktop/desktop.c', 'desktop/desktop.c',
'desktop/idle_inhibit_v1.c', 'desktop/idle_inhibit_v1.c',
'desktop/layer_shell.c', 'desktop/layer_shell.c',
'desktop/opengl.c',
'desktop/output.c', 'desktop/output.c',
'desktop/render.c', 'desktop/render.c',
'desktop/surface.c', 'desktop/surface.c',
'desktop/transaction.c', 'desktop/transaction.c',
'desktop/xdg_shell.c', 'desktop/xdg_shell.c',
'desktop/renderer/opengl.c',
'desktop/renderer/shaders.c',
'input/input-manager.c', 'input/input-manager.c',
'input/cursor.c', 'input/cursor.c',
'input/keyboard.c', 'input/keyboard.c',