mirror of
https://github.com/swaywm/sway.git
synced 2024-12-28 07:56:31 +01:00
style
This commit is contained in:
parent
f6e002fb8b
commit
f5fde7c45c
9 changed files with 35 additions and 35 deletions
|
@ -11,7 +11,7 @@ enum swayc_types{
|
|||
C_WORKSPACE,
|
||||
C_CONTAINER,
|
||||
C_VIEW,
|
||||
//Keep last
|
||||
// Keep last
|
||||
C_TYPES,
|
||||
};
|
||||
|
||||
|
@ -22,7 +22,7 @@ enum swayc_layouts{
|
|||
L_STACKED,
|
||||
L_TABBED,
|
||||
L_FLOATING,
|
||||
//Keep last
|
||||
// Keep last
|
||||
L_LAYOUTS,
|
||||
};
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ static int bindsym_sort(const void *_lbind, const void *_rbind) {
|
|||
const struct sway_binding *rbind = *(void **)_rbind;
|
||||
unsigned int lmod = 0, rmod = 0, i;
|
||||
|
||||
//Count how any modifiers are pressed
|
||||
// Count how any modifiers are pressed
|
||||
for (i = 0; i < 8 * sizeof(lbind->modifiers); ++i) {
|
||||
lmod += lbind->modifiers & 1 << i;
|
||||
rmod += rbind->modifiers & 1 << i;
|
||||
|
@ -203,10 +203,10 @@ static bool cmd_floating(struct sway_config *config, int argc, char **argv) {
|
|||
}
|
||||
// Change from nonfloating to floating
|
||||
if (!view->is_floating) {
|
||||
//Remove view from its current location
|
||||
// Remove view from its current location
|
||||
destroy_container(remove_child(view));
|
||||
|
||||
//and move it into workspace floating
|
||||
// and move it into workspace floating
|
||||
add_floating(active_workspace,view);
|
||||
view->x = (active_workspace->width - view->width)/2;
|
||||
view->y = (active_workspace->height - view->height)/2;
|
||||
|
@ -233,11 +233,11 @@ static bool cmd_floating(struct sway_config *config, int argc, char **argv) {
|
|||
|
||||
sway_log(L_DEBUG, "Non-floating focused container is %p", focused);
|
||||
|
||||
//Case of focused workspace, just create as child of it
|
||||
// Case of focused workspace, just create as child of it
|
||||
if (focused->type == C_WORKSPACE) {
|
||||
add_child(focused, view);
|
||||
}
|
||||
//Regular case, create as sibling of current container
|
||||
// Regular case, create as sibling of current container
|
||||
else {
|
||||
add_sibling(focused, view);
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ static bool cmd_floating_mod(struct sway_config *config, int argc, char **argv)
|
|||
list_t *split = split_string(argv[0], "+");
|
||||
config->floating_mod = 0;
|
||||
|
||||
//set modifer keys
|
||||
// set modifer keys
|
||||
for (i = 0; i < split->length; ++i) {
|
||||
for (j = 0; j < sizeof(modifiers) / sizeof(struct modifier_key); ++j) {
|
||||
if (strcasecmp(modifiers[j].name, split->items[i]) == 0) {
|
||||
|
@ -508,14 +508,14 @@ static bool cmd_fullscreen(struct sway_config *config, int argc, char **argv) {
|
|||
swayc_t *container = get_focused_view(&root_container);
|
||||
bool current = (wlc_view_get_state(container->handle) & WLC_BIT_FULLSCREEN) > 0;
|
||||
wlc_view_set_state(container->handle, WLC_BIT_FULLSCREEN, !current);
|
||||
//Resize workspace if going from fullscreen -> notfullscreen
|
||||
//otherwise just resize container
|
||||
// Resize workspace if going from fullscreen -> notfullscreen
|
||||
// otherwise just resize container
|
||||
if (current) {
|
||||
while (container->type != C_WORKSPACE) {
|
||||
container = container->parent;
|
||||
}
|
||||
}
|
||||
//Only resize container when going into fullscreen
|
||||
// Only resize container when going into fullscreen
|
||||
arrange_windows(container, -1, -1);
|
||||
|
||||
return true;
|
||||
|
@ -679,7 +679,7 @@ bool handle_command(struct sway_config *config, char *exec) {
|
|||
char **argv = split_directive(exec + strlen(handler->command), &argc);
|
||||
int i;
|
||||
|
||||
//Perform var subs on all parts of the command
|
||||
// Perform var subs on all parts of the command
|
||||
for (i = 0; i < argc; ++i) {
|
||||
argv[i] = do_var_replacement(config, argv[i]);
|
||||
}
|
||||
|
|
|
@ -171,7 +171,7 @@ swayc_t *new_view(swayc_t *sibling, wlc_handle handle) {
|
|||
view->name = title ? strdup(title) : NULL;
|
||||
view->visible = true;
|
||||
view->is_focused = true;
|
||||
//Setup geometry
|
||||
// Setup geometry
|
||||
view->width = 0;
|
||||
view->height = 0;
|
||||
|
||||
|
@ -205,7 +205,7 @@ swayc_t *new_floating_view(wlc_handle handle) {
|
|||
// Set the geometry of the floating view
|
||||
const struct wlc_geometry* geometry = wlc_view_get_geometry(handle);
|
||||
|
||||
//give it requested geometry, but place in center
|
||||
// give it requested geometry, but place in center
|
||||
view->x = (active_workspace->width - geometry->size.w) / 2;
|
||||
view->y = (active_workspace->height- geometry->size.h) / 2;
|
||||
view->width = geometry->size.w;
|
||||
|
|
|
@ -21,7 +21,7 @@ static void update_focus(swayc_t *c) {
|
|||
// Case where output changes
|
||||
case C_OUTPUT:
|
||||
wlc_output_focus(c->handle);
|
||||
//Set new workspace to the outputs focused workspace
|
||||
// Set new workspace to the outputs focused workspace
|
||||
active_workspace = c->focused;
|
||||
break;
|
||||
|
||||
|
@ -118,7 +118,7 @@ void set_focused_container(swayc_t *c) {
|
|||
// activate current focus
|
||||
if (p->type == C_VIEW) {
|
||||
wlc_view_set_state(p->handle, WLC_BIT_ACTIVATED, true);
|
||||
//set focus if view_focus is unlocked
|
||||
// set focus if view_focus is unlocked
|
||||
if (!locked_view_focus) {
|
||||
wlc_view_focus(p->handle);
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ swayc_t *container_under_pointer(void) {
|
|||
static bool handle_output_created(wlc_handle output) {
|
||||
swayc_t *op = new_output(output);
|
||||
|
||||
//Switch to workspace if we need to
|
||||
// Switch to workspace if we need to
|
||||
if (active_workspace == NULL) {
|
||||
swayc_t *ws = op->children->items[0];
|
||||
workspace_switch(ws);
|
||||
|
@ -109,7 +109,7 @@ static void handle_output_destroyed(wlc_handle output) {
|
|||
if (list->length == 0) {
|
||||
active_workspace = NULL;
|
||||
} else {
|
||||
//switch to other outputs active workspace
|
||||
// switch to other outputs active workspace
|
||||
workspace_switch(((swayc_t *)root_container.children->items[0])->focused);
|
||||
}
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ static bool handle_view_created(wlc_handle handle) {
|
|||
// Dmenu keeps viewfocus, but others with this flag dont, for now simulate
|
||||
// dmenu
|
||||
case WLC_BIT_OVERRIDE_REDIRECT:
|
||||
// locked_view_focus = true;
|
||||
// locked_view_focus = true;
|
||||
wlc_view_focus(handle);
|
||||
wlc_view_set_state(handle, WLC_BIT_ACTIVATED, true);
|
||||
wlc_view_bring_to_front(handle);
|
||||
|
@ -217,7 +217,7 @@ static void handle_view_destroyed(wlc_handle handle) {
|
|||
// DMENU has this flag, and takes view_focus, but other things with this
|
||||
// flag dont
|
||||
case WLC_BIT_OVERRIDE_REDIRECT:
|
||||
// locked_view_focus = false;
|
||||
// locked_view_focus = false;
|
||||
break;
|
||||
case WLC_BIT_OVERRIDE_REDIRECT|WLC_BIT_UNMANAGED:
|
||||
locked_container_focus = false;
|
||||
|
@ -444,7 +444,7 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
|
|||
}
|
||||
}
|
||||
if (config->focus_follows_mouse && prev_handle != handle) {
|
||||
//Dont change focus if fullscreen
|
||||
// Dont change focus if fullscreen
|
||||
swayc_t *focused = get_focused_view(view);
|
||||
if (!(focused->type == C_VIEW && wlc_view_get_state(focused->handle) & WLC_BIT_FULLSCREEN)
|
||||
&& !(pointer_state.l_held || pointer_state.r_held)) {
|
||||
|
@ -474,7 +474,7 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
|
|||
static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct wlc_modifiers *modifiers,
|
||||
uint32_t button, enum wlc_button_state state, const struct wlc_origin *origin) {
|
||||
swayc_t *focused = get_focused_container(&root_container);
|
||||
//dont change focus if fullscreen
|
||||
// dont change focus if fullscreen
|
||||
if (focused->type == C_VIEW && wlc_view_get_state(focused->handle) & WLC_BIT_FULLSCREEN) {
|
||||
return false;
|
||||
}
|
||||
|
@ -510,7 +510,7 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w
|
|||
pointer_state.lock.left = !pointer_state.lock.right;
|
||||
start_floating(pointer);
|
||||
}
|
||||
//Dont want pointer sent to window while dragging or resizing
|
||||
// Dont want pointer sent to window while dragging or resizing
|
||||
return (pointer_state.floating.drag || pointer_state.floating.resize);
|
||||
}
|
||||
return (pointer && pointer != focused);
|
||||
|
|
|
@ -36,7 +36,7 @@ void press_key(keycode key) {
|
|||
void release_key(keycode key) {
|
||||
uint8_t index = find_key(key);
|
||||
if (index < KEY_STATE_MAX_LENGTH) {
|
||||
//shift it over and remove key
|
||||
// shift it over and remove key
|
||||
key_state_array[index] = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ void add_child(swayc_t *parent, swayc_t *child) {
|
|||
child->width, child->height, parent, parent->type, parent->width, parent->height);
|
||||
list_add(parent->children, child);
|
||||
child->parent = parent;
|
||||
//set focus for this container
|
||||
// set focus for this container
|
||||
if (parent->children->length == 1) {
|
||||
set_focused_container_for(parent, child);
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ swayc_t *remove_child(swayc_t *child) {
|
|||
}
|
||||
}
|
||||
}
|
||||
//Set focused to new container
|
||||
// Set focused to new container
|
||||
if (parent->focused == child) {
|
||||
if (parent->children->length > 0) {
|
||||
set_focused_container_for(parent, parent->children->items[i?i-1:0]);
|
||||
|
@ -191,7 +191,7 @@ void arrange_windows(swayc_t *container, int width, int height) {
|
|||
switch (container->layout) {
|
||||
case L_HORIZ:
|
||||
default:
|
||||
//Calculate total width
|
||||
// Calculate total width
|
||||
for (i = 0; i < container->children->length; ++i) {
|
||||
int *old_width = &((swayc_t *)container->children->items[i])->width;
|
||||
if (*old_width <= 0) {
|
||||
|
@ -203,7 +203,7 @@ void arrange_windows(swayc_t *container, int width, int height) {
|
|||
}
|
||||
scale += *old_width;
|
||||
}
|
||||
//Resize windows
|
||||
// Resize windows
|
||||
if (scale > 0.1) {
|
||||
scale = width / scale;
|
||||
sway_log(L_DEBUG, "Arranging %p horizontally", container);
|
||||
|
@ -218,7 +218,7 @@ void arrange_windows(swayc_t *container, int width, int height) {
|
|||
}
|
||||
break;
|
||||
case L_VERT:
|
||||
//Calculate total height
|
||||
// Calculate total height
|
||||
for (i = 0; i < container->children->length; ++i) {
|
||||
int *old_height = &((swayc_t *)container->children->items[i])->height;
|
||||
if (*old_height <= 0) {
|
||||
|
@ -230,7 +230,7 @@ void arrange_windows(swayc_t *container, int width, int height) {
|
|||
}
|
||||
scale += *old_height;
|
||||
}
|
||||
//Resize
|
||||
// Resize
|
||||
if (scale > 0.1) {
|
||||
scale = height / scale;
|
||||
sway_log(L_DEBUG, "Arranging %p vertically", container);
|
||||
|
|
|
@ -88,10 +88,10 @@ bool sway_assert(bool condition, const char* format, ...) {
|
|||
/* XXX:DEBUG:XXX */
|
||||
static void container_log(const swayc_t *c) {
|
||||
fprintf(stderr, "focus:%c|",
|
||||
c->is_focused ? 'F' : //Focused
|
||||
c == active_workspace ? 'W' : //active workspace
|
||||
c == &root_container ? 'R' : //root
|
||||
'X');//not any others
|
||||
c->is_focused ? 'F' : // Focused
|
||||
c == active_workspace ? 'W' : // active workspace
|
||||
c == &root_container ? 'R' : // root
|
||||
'X');// not any others
|
||||
fprintf(stderr,"(%p)",c);
|
||||
fprintf(stderr,"(p:%p)",c->parent);
|
||||
fprintf(stderr,"(f:%p)",c->focused);
|
||||
|
|
|
@ -47,7 +47,7 @@ char *workspace_next_name(void) {
|
|||
continue;
|
||||
}
|
||||
|
||||
//Make sure that the workspace doesn't already exist
|
||||
// Make sure that the workspace doesn't already exist
|
||||
if (workspace_find_by_name(target)) {
|
||||
list_free(args);
|
||||
continue;
|
||||
|
|
Loading…
Reference in a new issue