mirror of
https://github.com/swaywm/sway.git
synced 2025-11-26 06:59:59 -05:00
Move everything to sway/old/
This commit is contained in:
parent
0c8491f7d0
commit
733993a651
128 changed files with 76 additions and 430 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -998,6 +998,7 @@ static void invoke_swaybar(struct bar_config *bar) {
|
|||
}
|
||||
|
||||
static void terminate_swaybar(pid_t pid) {
|
||||
return; // TODO WLR
|
||||
int ret = kill(pid, SIGTERM);
|
||||
if (ret != 0) {
|
||||
sway_log(L_ERROR, "Unable to terminate swaybar [pid: %d]", pid);
|
||||
|
|
@ -1066,143 +1067,6 @@ void load_swaybars() {
|
|||
list_free(bars);
|
||||
}
|
||||
|
||||
void apply_input_config(struct input_config *ic, struct libinput_device *dev) {
|
||||
if (!ic) {
|
||||
return;
|
||||
}
|
||||
|
||||
sway_log(L_DEBUG, "apply_input_config(%s)", ic->identifier);
|
||||
|
||||
if (ic->accel_profile != INT_MIN) {
|
||||
sway_log(L_DEBUG, "apply_input_config(%s) accel_set_profile(%d)", ic->identifier, ic->accel_profile);
|
||||
libinput_device_config_accel_set_profile(dev, ic->accel_profile);
|
||||
}
|
||||
if (ic->click_method != INT_MIN) {
|
||||
sway_log(L_DEBUG, "apply_input_config(%s) click_set_method(%d)", ic->identifier, ic->click_method);
|
||||
libinput_device_config_click_set_method(dev, ic->click_method);
|
||||
}
|
||||
if (ic->drag_lock != INT_MIN) {
|
||||
sway_log(L_DEBUG, "apply_input_config(%s) tap_set_drag_lock_enabled(%d)", ic->identifier, ic->click_method);
|
||||
libinput_device_config_tap_set_drag_lock_enabled(dev, ic->drag_lock);
|
||||
}
|
||||
if (ic->dwt != INT_MIN) {
|
||||
sway_log(L_DEBUG, "apply_input_config(%s) dwt_set_enabled(%d)", ic->identifier, ic->dwt);
|
||||
libinput_device_config_dwt_set_enabled(dev, ic->dwt);
|
||||
}
|
||||
if (ic->left_handed != INT_MIN) {
|
||||
sway_log(L_DEBUG, "apply_input_config(%s) left_handed_set_enabled(%d)", ic->identifier, ic->left_handed);
|
||||
libinput_device_config_left_handed_set(dev, ic->left_handed);
|
||||
}
|
||||
if (ic->middle_emulation != INT_MIN) {
|
||||
sway_log(L_DEBUG, "apply_input_config(%s) middle_emulation_set_enabled(%d)", ic->identifier, ic->middle_emulation);
|
||||
libinput_device_config_middle_emulation_set_enabled(dev, ic->middle_emulation);
|
||||
}
|
||||
if (ic->natural_scroll != INT_MIN) {
|
||||
sway_log(L_DEBUG, "apply_input_config(%s) natural_scroll_set_enabled(%d)", ic->identifier, ic->natural_scroll);
|
||||
libinput_device_config_scroll_set_natural_scroll_enabled(dev, ic->natural_scroll);
|
||||
}
|
||||
if (ic->pointer_accel != FLT_MIN) {
|
||||
sway_log(L_DEBUG, "apply_input_config(%s) accel_set_speed(%f)", ic->identifier, ic->pointer_accel);
|
||||
libinput_device_config_accel_set_speed(dev, ic->pointer_accel);
|
||||
}
|
||||
if (ic->scroll_method != INT_MIN) {
|
||||
sway_log(L_DEBUG, "apply_input_config(%s) scroll_set_method(%d)", ic->identifier, ic->scroll_method);
|
||||
libinput_device_config_scroll_set_method(dev, ic->scroll_method);
|
||||
}
|
||||
if (ic->send_events != INT_MIN) {
|
||||
sway_log(L_DEBUG, "apply_input_config(%s) send_events_set_mode(%d)", ic->identifier, ic->send_events);
|
||||
libinput_device_config_send_events_set_mode(dev, ic->send_events);
|
||||
}
|
||||
if (ic->tap != INT_MIN) {
|
||||
sway_log(L_DEBUG, "apply_input_config(%s) tap_set_enabled(%d)", ic->identifier, ic->tap);
|
||||
libinput_device_config_tap_set_enabled(dev, ic->tap);
|
||||
}
|
||||
}
|
||||
|
||||
void apply_output_config(struct output_config *oc, swayc_t *output) {
|
||||
if (oc && oc->enabled == 0) {
|
||||
destroy_output(output);
|
||||
return;
|
||||
}
|
||||
|
||||
if (oc && oc->width > 0 && oc->height > 0) {
|
||||
output->width = oc->width;
|
||||
output->height = oc->height;
|
||||
|
||||
sway_log(L_DEBUG, "Set %s size to %ix%i (%d)", oc->name, oc->width, oc->height, oc->scale);
|
||||
// TODO WLR: modes
|
||||
//struct wlc_size new_size = { .w = oc->width, .h = oc->height };
|
||||
//wlc_output_set_resolution(output->handle, &new_size, (uint32_t)oc->scale);
|
||||
} else if (oc) {
|
||||
//const struct wlc_size *new_size = wlc_output_get_resolution(output->handle);
|
||||
//wlc_output_set_resolution(output->handle, new_size, (uint32_t)oc->scale);
|
||||
}
|
||||
|
||||
// TODO WLR: wlr_output_layout
|
||||
// Find position for it
|
||||
if (oc && oc->x != -1 && oc->y != -1) {
|
||||
sway_log(L_DEBUG, "Set %s position to %d, %d", oc->name, oc->x, oc->y);
|
||||
output->x = oc->x;
|
||||
output->y = oc->y;
|
||||
} else {
|
||||
int x = 0;
|
||||
for (int i = 0; i < root_container.children->length; ++i) {
|
||||
swayc_t *c = root_container.children->items[i];
|
||||
if (c->type == C_OUTPUT) {
|
||||
if (c->width + c->x > x) {
|
||||
x = c->width + c->x;
|
||||
}
|
||||
}
|
||||
}
|
||||
output->x = x;
|
||||
}
|
||||
|
||||
if (!oc || !oc->background) {
|
||||
// Look for a * config for background
|
||||
int i = list_seq_find(config->output_configs, output_name_cmp, "*");
|
||||
if (i >= 0) {
|
||||
oc = config->output_configs->items[i];
|
||||
} else {
|
||||
oc = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int output_i;
|
||||
for (output_i = 0; output_i < root_container.children->length; ++output_i) {
|
||||
if (root_container.children->items[output_i] == output) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO WLR
|
||||
if (oc && oc->background) {
|
||||
if (output->bg_pid != 0) {
|
||||
terminate_swaybg(output->bg_pid);
|
||||
}
|
||||
|
||||
sway_log(L_DEBUG, "Setting background for output %d to %s", output_i, oc->background);
|
||||
|
||||
size_t bufsize = 12;
|
||||
char output_id[bufsize];
|
||||
snprintf(output_id, bufsize, "%d", output_i);
|
||||
output_id[bufsize-1] = 0;
|
||||
|
||||
char *const cmd[] = {
|
||||
"swaybg",
|
||||
output_id,
|
||||
oc->background,
|
||||
oc->background_option,
|
||||
NULL,
|
||||
};
|
||||
|
||||
output->bg_pid = fork();
|
||||
if (output->bg_pid == 0) {
|
||||
execvp(cmd[0], cmd);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
char *do_var_replacement(char *str) {
|
||||
int i;
|
||||
char *find = str;
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue