mirror of
https://github.com/swaywm/sway.git
synced 2024-12-28 07:56:31 +01:00
Move everything to sway/old/
This commit is contained in:
parent
0c8491f7d0
commit
733993a651
128 changed files with 76 additions and 430 deletions
|
@ -116,7 +116,8 @@ add_subdirectory(wayland)
|
|||
add_subdirectory(sway)
|
||||
if(enable-swaybg)
|
||||
if(CAIRO_FOUND AND PANGO_FOUND)
|
||||
add_subdirectory(swaybg)
|
||||
# TODO WLR
|
||||
#add_subdirectory(swaybg)
|
||||
else()
|
||||
message(WARNING "Not building swaybg - cairo, and pango are required.")
|
||||
endif()
|
||||
|
@ -125,18 +126,21 @@ if(enable-swaymsg)
|
|||
add_subdirectory(swaymsg)
|
||||
endif()
|
||||
if(enable-swaygrab)
|
||||
add_subdirectory(swaygrab)
|
||||
# TODO WLR
|
||||
#add_subdirectory(swaygrab)
|
||||
endif()
|
||||
if(enable-swaybar)
|
||||
if(CAIRO_FOUND AND PANGO_FOUND)
|
||||
add_subdirectory(swaybar)
|
||||
# TODO WLR
|
||||
#add_subdirectory(swaybar)
|
||||
else()
|
||||
message(WARNING "Not building swaybar - cairo, and pango are required.")
|
||||
endif()
|
||||
endif()
|
||||
if(enable-swaylock)
|
||||
if(CAIRO_FOUND AND PANGO_FOUND AND PAM_FOUND)
|
||||
add_subdirectory(swaylock)
|
||||
# TODO WLR
|
||||
#add_subdirectory(swaylock)
|
||||
else()
|
||||
message(WARNING "Not building swaylock - cairo, pango, and PAM are required.")
|
||||
endif()
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include "log.h"
|
||||
#include "sway.h"
|
||||
#include "readline.h"
|
||||
|
||||
static int colored = 1;
|
||||
|
@ -117,6 +116,7 @@ void _sway_log(const char *filename, int line, log_importance_t verbosity, const
|
|||
va_end(args);
|
||||
}
|
||||
|
||||
void sway_terminate(int code);
|
||||
|
||||
void _sway_abort(const char *filename, int line, const char* format, ...) {
|
||||
va_list args;
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
#ifndef _SWAY_SWAY_H
|
||||
#define _SWAY_SWAY_H
|
||||
|
||||
void sway_terminate(int exit_code);
|
||||
|
||||
#endif
|
|
@ -1,11 +0,0 @@
|
|||
#ifndef _SWAY_HANDLERS_H
|
||||
#define _SWAY_HANDLERS_H
|
||||
#include "container.h"
|
||||
#include <stdbool.h>
|
||||
#include <wlc/wlc.h>
|
||||
|
||||
void register_wlc_handlers();
|
||||
|
||||
extern uint32_t keys_pressed[32];
|
||||
|
||||
#endif
|
|
@ -1,8 +1,5 @@
|
|||
#ifndef _SWAY_IPC_SERVER_H
|
||||
#define _SWAY_IPC_SERVER_H
|
||||
|
||||
#include <wlc/wlc.h>
|
||||
|
||||
#include "container.h"
|
||||
#include "config.h"
|
||||
#include "ipc.h"
|
||||
|
@ -33,9 +30,4 @@ void ipc_event_modifier(uint32_t modifier, const char *state);
|
|||
void ipc_event_binding_keyboard(struct sway_binding *sb);
|
||||
const char *swayc_type_string(enum swayc_types type);
|
||||
|
||||
/**
|
||||
* Send pixel data to registered clients.
|
||||
*/
|
||||
void ipc_get_pixels(wlc_handle output);
|
||||
|
||||
#endif
|
36
include/sway/old/output.h
Normal file
36
include/sway/old/output.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
#ifndef _SWAY_OUTPUT_H
|
||||
#define _SWAY_OUTPUT_H
|
||||
#include <time.h>
|
||||
#include <wayland-server.h>
|
||||
#include <wlr/types/wlr_output.h>
|
||||
#include "container.h"
|
||||
#include "focus.h"
|
||||
|
||||
struct sway_server;
|
||||
|
||||
struct sway_output {
|
||||
struct wlr_output *wlr_output;
|
||||
struct wl_listener frame;
|
||||
struct sway_server *server;
|
||||
struct timespec last_frame;
|
||||
};
|
||||
|
||||
// Position is absolute coordinates on the edge where the adjacent output
|
||||
// should be searched for.
|
||||
swayc_t *output_by_name(const char* name, const struct wlc_point *abs_pos);
|
||||
swayc_t *swayc_opposite_output(enum movement_direction dir, const struct wlc_point *abs_pos);
|
||||
swayc_t *swayc_adjacent_output(swayc_t *output, enum movement_direction dir, const struct wlc_point *abs_pos, bool pick_closest);
|
||||
|
||||
// Place absolute coordinates for given container into given wlc_point.
|
||||
void get_absolute_position(swayc_t *container, struct wlc_point *point);
|
||||
|
||||
// Place absolute coordinates for the center point of given container into
|
||||
// given wlc_point.
|
||||
void get_absolute_center_position(swayc_t *container, struct wlc_point *point);
|
||||
|
||||
// stable sort workspaces on this output
|
||||
void sort_workspaces(swayc_t *output);
|
||||
|
||||
void output_get_scaled_size(wlc_handle handle, struct wlc_size *size);
|
||||
|
||||
#endif
|
|
@ -3,34 +3,14 @@
|
|||
#include <time.h>
|
||||
#include <wayland-server.h>
|
||||
#include <wlr/types/wlr_output.h>
|
||||
#include "container.h"
|
||||
#include "focus.h"
|
||||
|
||||
struct sway_server;
|
||||
|
||||
struct sway_output {
|
||||
struct wlr_output *wlr_output;
|
||||
struct wl_listener frame;
|
||||
struct sway_server *server;
|
||||
struct timespec last_frame;
|
||||
struct wl_listener frame;
|
||||
};
|
||||
|
||||
// Position is absolute coordinates on the edge where the adjacent output
|
||||
// should be searched for.
|
||||
swayc_t *output_by_name(const char* name, const struct wlc_point *abs_pos);
|
||||
swayc_t *swayc_opposite_output(enum movement_direction dir, const struct wlc_point *abs_pos);
|
||||
swayc_t *swayc_adjacent_output(swayc_t *output, enum movement_direction dir, const struct wlc_point *abs_pos, bool pick_closest);
|
||||
|
||||
// Place absolute coordinates for given container into given wlc_point.
|
||||
void get_absolute_position(swayc_t *container, struct wlc_point *point);
|
||||
|
||||
// Place absolute coordinates for the center point of given container into
|
||||
// given wlc_point.
|
||||
void get_absolute_center_position(swayc_t *container, struct wlc_point *point);
|
||||
|
||||
// stable sort workspaces on this output
|
||||
void sort_workspaces(swayc_t *output);
|
||||
|
||||
void output_get_scaled_size(wlc_handle handle, struct wlc_size *size);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
include_directories(
|
||||
${PROTOCOLS_INCLUDE_DIRS}
|
||||
${WLC_INCLUDE_DIRS}
|
||||
${WLR_INCLUDE_DIRS}
|
||||
${PCRE_INCLUDE_DIRS}
|
||||
${JSONC_INCLUDE_DIRS}
|
||||
|
@ -11,37 +10,12 @@ include_directories(
|
|||
${WAYLAND_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
file(GLOB cmds
|
||||
"commands/*.c"
|
||||
"commands/bar/*.c"
|
||||
"commands/input/*.c"
|
||||
)
|
||||
|
||||
add_executable(sway
|
||||
desktop/output.c
|
||||
desktop/xdg_shell_v6.c
|
||||
|
||||
tree/container.c
|
||||
tree/criteria.c
|
||||
tree/focus.c
|
||||
tree/output.c
|
||||
tree/workspace.c
|
||||
tree/layout.c
|
||||
|
||||
input/input.c
|
||||
|
||||
commands.c
|
||||
${cmds}
|
||||
|
||||
base64.c
|
||||
config.c
|
||||
debug_log.c
|
||||
input_state.c
|
||||
ipc-json.c
|
||||
ipc-server.c
|
||||
main.c
|
||||
border.c
|
||||
security.c
|
||||
server.c
|
||||
)
|
||||
|
||||
|
@ -53,7 +27,6 @@ target_link_libraries(sway
|
|||
sway-common
|
||||
sway-protocols
|
||||
sway-wayland
|
||||
${WLC_LIBRARIES}
|
||||
${WLR_LIBRARIES}
|
||||
${XKBCOMMON_LIBRARIES}
|
||||
${PCRE_LIBRARIES}
|
||||
|
|
103
sway/debug_log.c
103
sway/debug_log.c
|
@ -1,103 +0,0 @@
|
|||
#include "log.h"
|
||||
#include "sway.h"
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <libgen.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stringop.h>
|
||||
#include "sway/workspace.h"
|
||||
|
||||
/* XXX:DEBUG:XXX */
|
||||
static void container_log(const swayc_t *c, int depth) {
|
||||
fprintf(stderr, "focus:%c",
|
||||
c == get_focused_view(&root_container) ? 'K':
|
||||
c == get_focused_container(&root_container) ? 'F' : // Focused
|
||||
c == swayc_active_workspace() ? 'W' : // active workspace
|
||||
c == &root_container ? 'R' : // root
|
||||
'X');// not any others
|
||||
for (int i = 6; i > depth; i--) { fprintf(stderr, " "); }
|
||||
fprintf(stderr,"|(%p)",c);
|
||||
fprintf(stderr,"(p:%-8p)",c->parent);
|
||||
fprintf(stderr,"(f:%-8p)",c->focused);
|
||||
fprintf(stderr,"(h:%2" PRIuPTR ")",c->handle);
|
||||
fprintf(stderr,"Type:%-4s|",
|
||||
c->type == C_ROOT ? "root" :
|
||||
c->type == C_OUTPUT ? "op" :
|
||||
c->type == C_WORKSPACE ? "ws" :
|
||||
c->type == C_CONTAINER ? "cont" :
|
||||
c->type == C_VIEW ? "view" : "?");
|
||||
fprintf(stderr,"layout:%-5s|",
|
||||
c->layout == L_NONE ? "-" :
|
||||
c->layout == L_HORIZ ? "Horiz":
|
||||
c->layout == L_VERT ? "Vert":
|
||||
c->layout == L_STACKED ? "Stack":
|
||||
c->layout == L_TABBED ? "Tab":
|
||||
c->layout == L_FLOATING ? "Float":
|
||||
c->layout == L_AUTO_LEFT ? "A_lft":
|
||||
c->layout == L_AUTO_RIGHT ? "A_rgt":
|
||||
c->layout == L_AUTO_TOP ? "A_top":
|
||||
c->layout == L_AUTO_BOTTOM ? "A_bot":
|
||||
"Unknown");
|
||||
fprintf(stderr, "w:%4.f|h:%4.f|", c->width, c->height);
|
||||
fprintf(stderr, "x:%4.f|y:%4.f|", c->x, c->y);
|
||||
fprintf(stderr, "g:%3d|",c->gaps);
|
||||
fprintf(stderr, "vis:%c|", c->visible?'t':'f');
|
||||
fprintf(stderr, "children:%2d|",c->children?c->children->length:0);
|
||||
fprintf(stderr, "name:%.16s\n", c->name);
|
||||
}
|
||||
void layout_log(const swayc_t *c, int depth) {
|
||||
if (L_DEBUG > get_log_level()) return;
|
||||
int i, d;
|
||||
int e = c->children ? c->children->length : 0;
|
||||
container_log(c, depth);
|
||||
if (e) {
|
||||
for (i = 0; i < e; ++i) {
|
||||
fputc('|',stderr);
|
||||
for (d = 0; d < depth; ++d) fputc('-', stderr);
|
||||
layout_log(c->children->items[i], depth + 1);
|
||||
}
|
||||
}
|
||||
if (c->type == C_WORKSPACE) {
|
||||
e = c->floating?c->floating->length:0;
|
||||
if (e) {
|
||||
for (i = 0; i < e; ++i) {
|
||||
fputc('|',stderr);
|
||||
for (d = 0; d < depth; ++d) fputc('=', stderr);
|
||||
layout_log(c->floating->items[i], depth + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const char *swayc_type_string(enum swayc_types type) {
|
||||
return type == C_ROOT ? "ROOT" :
|
||||
type == C_OUTPUT ? "OUTPUT" :
|
||||
type == C_WORKSPACE ? "WORKSPACE" :
|
||||
type == C_CONTAINER ? "CONTAINER" :
|
||||
type == C_VIEW ? "VIEW" :
|
||||
"UNKNOWN";
|
||||
}
|
||||
|
||||
// Like sway_log, but also appends some info about given container to log output.
|
||||
void swayc_log(log_importance_t verbosity, swayc_t *cont, const char* format, ...) {
|
||||
sway_assert(cont, "swayc_log: no container ...");
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
char *txt = malloc(128);
|
||||
vsprintf(txt, format, args);
|
||||
va_end(args);
|
||||
|
||||
char *debug_txt = malloc(32);
|
||||
snprintf(debug_txt, 32, "%s '%s'", swayc_type_string(cont->type), cont->name);
|
||||
|
||||
sway_log(verbosity, "%s (%s)", txt, debug_txt);
|
||||
free(txt);
|
||||
free(debug_txt);
|
||||
}
|
||||
|
||||
/* XXX:DEBUG:XXX */
|
|
@ -4,11 +4,9 @@
|
|||
#include <wayland-server.h>
|
||||
#include <wlr/types/wlr_output.h>
|
||||
#include <wlr/render.h>
|
||||
#include "sway/server.h"
|
||||
#include "sway/container.h"
|
||||
#include "sway/workspace.h"
|
||||
#include "sway/output.h"
|
||||
#include "log.h"
|
||||
#include "sway/output.h"
|
||||
#include "sway/server.h"
|
||||
|
||||
static void output_frame_notify(struct wl_listener *listener, void *data) {
|
||||
struct sway_output *soutput = wl_container_of(
|
||||
|
@ -37,19 +35,10 @@ void output_add_notify(struct wl_listener *listener, void *data) {
|
|||
output->wlr_output = wlr_output;
|
||||
output->server = server;
|
||||
|
||||
swayc_t *node = new_output(output);
|
||||
if (!sway_assert(node, "Failed to allocate output")) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Switch to workspace if we need to
|
||||
if (swayc_active_workspace() == NULL) {
|
||||
swayc_t *ws = node->children->items[0];
|
||||
workspace_switch(ws);
|
||||
}
|
||||
|
||||
output->frame.notify = output_frame_notify;
|
||||
wl_signal_add(&wlr_output->events.frame, &output->frame);
|
||||
|
||||
// TODO: Add to tree
|
||||
}
|
||||
|
||||
void output_remove_notify(struct wl_listener *listener, void *data) {
|
||||
|
|
|
@ -1,49 +1,10 @@
|
|||
#include <stdlib.h>
|
||||
#include <wayland-server.h>
|
||||
#include <wlr/types/wlr_xdg_shell_v6.h>
|
||||
#include "sway/commands.h"
|
||||
#include "sway/container.h"
|
||||
#include "sway/focus.h"
|
||||
#include "sway/ipc-server.h"
|
||||
#include "sway/server.h"
|
||||
#include "sway/view.h"
|
||||
#include "log.h"
|
||||
|
||||
// TODO: move elsewhere
|
||||
static void temp_ws_cleanup() {
|
||||
swayc_t *op, *ws;
|
||||
int i = 0, j;
|
||||
if (!root_container.children)
|
||||
return;
|
||||
while (i < root_container.children->length) {
|
||||
op = root_container.children->items[i++];
|
||||
if (!op->children)
|
||||
continue;
|
||||
j = 0;
|
||||
while (j < op->children->length) {
|
||||
ws = op->children->items[j++];
|
||||
if (ws->children->length == 0 && ws->floating->length == 0 && ws != op->focused) {
|
||||
if (destroy_workspace(ws)) {
|
||||
j--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: move elsewhere
|
||||
static swayc_t *move_focus_to_tiling(swayc_t *focused) {
|
||||
if (focused->is_floating) {
|
||||
if (focused->parent->children->length == 0) {
|
||||
return focused->parent;
|
||||
}
|
||||
// TODO find a better way of doing this
|
||||
// Or to focused container
|
||||
return get_focused_container(focused->parent->children->items[0]);
|
||||
}
|
||||
return focused;
|
||||
}
|
||||
|
||||
static const char *get_prop(struct sway_view *view, enum sway_view_prop prop) {
|
||||
if (!sway_assert(view->type == SWAY_XDG_SHELL_V6_VIEW,
|
||||
"xdg get_prop for non-xdg view!")) {
|
||||
|
@ -88,30 +49,10 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
|
|||
sway_surface->view = sway_view;
|
||||
|
||||
// TODO:
|
||||
// - Consolodate common logic between shells
|
||||
// - Add to tree
|
||||
// - Wire up listeners
|
||||
// - Handle popups
|
||||
// - Look up pid and open on appropriate workspace
|
||||
// - Set new view to maximized so it behaves nicely
|
||||
// - Criteria
|
||||
|
||||
suspend_workspace_cleanup = true;
|
||||
//swayc_t *current_ws = swayc_active_workspace();
|
||||
swayc_t *prev_focus = get_focused_container(&root_container);
|
||||
swayc_t *focused = move_focus_to_tiling(prev_focus);
|
||||
|
||||
// TODO: fix new_view
|
||||
swayc_t *view = new_view(focused, sway_view);
|
||||
ipc_event_window(view, "new");
|
||||
set_focused_container(view);
|
||||
|
||||
swayc_t *output = swayc_parent_by_type(view, C_OUTPUT);
|
||||
arrange_windows(output, -1, -1);
|
||||
|
||||
swayc_t *workspace = swayc_parent_by_type(focused, C_WORKSPACE);
|
||||
if (workspace && workspace->fullscreen) {
|
||||
set_focused_container(workspace->fullscreen);
|
||||
}
|
||||
suspend_workspace_cleanup = false;
|
||||
temp_ws_cleanup();
|
||||
}
|
||||
|
|
54
sway/main.c
54
sway/main.c
|
@ -1,30 +1,24 @@
|
|||
#define _XOPEN_SOURCE 700
|
||||
#define _POSIX_C_SOURCE 200112L
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/un.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <getopt.h>
|
||||
#include <signal.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/un.h>
|
||||
#include <unistd.h>
|
||||
#ifdef __linux__
|
||||
#include <sys/capability.h>
|
||||
#include <sys/prctl.h>
|
||||
#endif
|
||||
#include "sway/layout.h"
|
||||
#include "sway/config.h"
|
||||
#include "sway/security.h"
|
||||
#include "sway/handlers.h"
|
||||
#include "sway/input.h"
|
||||
#include "sway/ipc-server.h"
|
||||
#include "sway/server.h"
|
||||
#include "ipc-client.h"
|
||||
#include "readline.h"
|
||||
#include "stringop.h"
|
||||
#include "sway.h"
|
||||
#include "log.h"
|
||||
#include "util.h"
|
||||
|
||||
|
@ -39,7 +33,7 @@ void sway_terminate(int exit_code) {
|
|||
}
|
||||
|
||||
void sig_handler(int signal) {
|
||||
close_views(&root_container);
|
||||
//close_views(&root_container);
|
||||
sway_terminate(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
|
@ -442,17 +436,17 @@ int main(int argc, char **argv) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
init_layout();
|
||||
ipc_init();
|
||||
//init_layout();
|
||||
//ipc_init();
|
||||
|
||||
if (validate) {
|
||||
bool valid = load_main_config(config_path, false);
|
||||
return valid ? 0 : 1;
|
||||
}
|
||||
//if (validate) {
|
||||
// bool valid = load_main_config(config_path, false);
|
||||
// return valid ? 0 : 1;
|
||||
//}
|
||||
|
||||
if (!load_main_config(config_path, false)) {
|
||||
sway_terminate(EXIT_FAILURE);
|
||||
}
|
||||
//if (!load_main_config(config_path, false)) {
|
||||
// sway_terminate(EXIT_FAILURE);
|
||||
//}
|
||||
|
||||
if (config_path) {
|
||||
free(config_path);
|
||||
|
@ -466,11 +460,11 @@ int main(int argc, char **argv) {
|
|||
|
||||
server_fini(&server);
|
||||
|
||||
ipc_terminate();
|
||||
//ipc_terminate();
|
||||
|
||||
if (config) {
|
||||
free_config(config);
|
||||
}
|
||||
//if (config) {
|
||||
// free_config(config);
|
||||
//}
|
||||
|
||||
return exit_value;
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue