forked from baskerville/bspwm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split types.c into {monitor,desktop,history}.c
- Loading branch information
1 parent
ff03ce7
commit d168e91
Showing
23 changed files
with
734 additions
and
690 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
bspc.o: bspc.c common.h helpers.h | ||
bspwm.o: bspwm.c bspwm.h common.h events.h ewmh.h helpers.h messages.h rules.h settings.h tree.h types.h window.h | ||
events.o: events.c bspwm.h events.h ewmh.h helpers.h query.h rules.h settings.h tree.h types.h window.h | ||
bspwm.o: bspwm.c bspwm.h common.h desktop.h events.h ewmh.h helpers.h messages.h monitor.h rules.h settings.h tree.h types.h window.h | ||
desktop.o: desktop.c bspwm.h desktop.h ewmh.h helpers.h history.h tree.h types.h window.h | ||
events.o: events.c bspwm.h events.h ewmh.h helpers.h monitor.h query.h rules.h settings.h tree.h types.h window.h | ||
ewmh.o: ewmh.c bspwm.h ewmh.h helpers.h settings.h tree.h types.h | ||
helpers.o: helpers.c bspwm.h helpers.h types.h | ||
messages.o: messages.c bspwm.h common.h events.h ewmh.h helpers.h messages.h query.h restore.h rules.h settings.h tree.h types.h window.h | ||
query.o: query.c bspwm.h helpers.h messages.h query.h settings.h tree.h types.h | ||
restore.o: restore.c bspwm.h ewmh.h helpers.h query.h restore.h settings.h tree.h types.h | ||
history.o: history.c helpers.h history.h query.h types.h | ||
messages.o: messages.c bspwm.h common.h desktop.h events.h ewmh.h helpers.h messages.h monitor.h query.h restore.h rules.h settings.h tree.h types.h window.h | ||
monitor.o: monitor.c bspwm.h desktop.h ewmh.h helpers.h monitor.h tree.h types.h window.h | ||
query.o: query.c bspwm.h helpers.h history.h messages.h query.h settings.h tree.h types.h | ||
restore.o: restore.c bspwm.h desktop.h ewmh.h helpers.h history.h monitor.h query.h restore.h settings.h tree.h types.h | ||
rules.o: rules.c bspwm.h ewmh.h helpers.h query.h rules.h types.h window.h | ||
settings.o: settings.c bspwm.h common.h helpers.h settings.h types.h | ||
tree.o: tree.c bspwm.h ewmh.h helpers.h settings.h tree.h types.h window.h | ||
types.o: types.c bspwm.h ewmh.h helpers.h rules.h settings.h tree.h types.h window.h | ||
tree.o: tree.c bspwm.h desktop.h ewmh.h helpers.h history.h query.h settings.h tree.h types.h window.h | ||
window.o: window.c bspwm.h ewmh.h helpers.h query.h rules.h settings.h tree.h types.h window.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include "bspwm.h" | ||
#include "types.h" | ||
#include "desktop.h" | ||
#include "history.h" | ||
#include "tree.h" | ||
#include "window.h" | ||
#include "ewmh.h" | ||
|
||
void transfer_desktop(monitor_t *ms, monitor_t *md, desktop_t *d) | ||
{ | ||
if (ms == md) | ||
return; | ||
|
||
desktop_t *dd = ms->desk; | ||
unlink_desktop(ms, d); | ||
insert_desktop(md, d); | ||
|
||
if (d == dd) { | ||
if (ms->desk != NULL) | ||
show_desktop(ms->desk); | ||
if (md->desk != d) | ||
hide_desktop(d); | ||
} | ||
|
||
for (node_t *n = first_extrema(d->root); n != NULL; n = next_leaf(n, d->root)) | ||
fit_monitor(md, n->client); | ||
arrange(md, d); | ||
if (d != dd && md->desk == d) { | ||
show_desktop(d); | ||
} | ||
|
||
ewmh_update_wm_desktops(); | ||
ewmh_update_desktop_names(); | ||
ewmh_update_current_desktop(); | ||
put_status(); | ||
} | ||
|
||
desktop_t *make_desktop(const char *name) | ||
{ | ||
desktop_t *d = malloc(sizeof(desktop_t)); | ||
if (name == NULL) | ||
snprintf(d->name, sizeof(d->name), "%s%02d", DEFAULT_DESK_NAME, ++desktop_uid); | ||
else | ||
strncpy(d->name, name, sizeof(d->name)); | ||
d->layout = LAYOUT_TILED; | ||
d->prev = d->next = NULL; | ||
d->root = d->focus = NULL; | ||
d->history = make_focus_history(); | ||
d->window_gap = WINDOW_GAP; | ||
return d; | ||
} | ||
|
||
void insert_desktop(monitor_t *m, desktop_t *d) | ||
{ | ||
if (m->desk == NULL) { | ||
m->desk = d; | ||
m->desk_head = d; | ||
m->desk_tail = d; | ||
} else { | ||
m->desk_tail->next = d; | ||
d->prev = m->desk_tail; | ||
m->desk_tail = d; | ||
} | ||
} | ||
|
||
void add_desktop(monitor_t *m, desktop_t *d) | ||
{ | ||
PRINTF("add desktop %s\n", d->name); | ||
|
||
insert_desktop(m, d); | ||
num_desktops++; | ||
ewmh_update_number_of_desktops(); | ||
ewmh_update_desktop_names(); | ||
put_status(); | ||
} | ||
|
||
void empty_desktop(desktop_t *d) | ||
{ | ||
destroy_tree(d->root); | ||
d->root = d->focus = NULL; | ||
empty_history(d->history); | ||
} | ||
|
||
void unlink_desktop(monitor_t *m, desktop_t *d) | ||
{ | ||
desktop_t *prev = d->prev; | ||
desktop_t *next = d->next; | ||
if (prev != NULL) | ||
prev->next = next; | ||
if (next != NULL) | ||
next->prev = prev; | ||
if (m->desk_head == d) | ||
m->desk_head = next; | ||
if (m->desk_tail == d) | ||
m->desk_tail = prev; | ||
if (m->last_desk == d) | ||
m->last_desk = NULL; | ||
if (m->desk == d) | ||
m->desk = (m->last_desk == NULL ? (prev == NULL ? next : prev) : m->last_desk); | ||
d->prev = d->next = NULL; | ||
} | ||
|
||
void remove_desktop(monitor_t *m, desktop_t *d) | ||
{ | ||
PRINTF("remove desktop %s\n", d->name); | ||
|
||
unlink_desktop(m, d); | ||
empty_desktop(d); | ||
free(d); | ||
num_desktops--; | ||
ewmh_update_number_of_desktops(); | ||
ewmh_update_desktop_names(); | ||
put_status(); | ||
} | ||
|
||
void swap_desktops(monitor_t *m, desktop_t *d1, desktop_t *d2) | ||
{ | ||
if (d1 == NULL || d2 == NULL || d1 == d2) | ||
return; | ||
|
||
if (m->desk_head == d1) | ||
m->desk_head = d2; | ||
else if (m->desk_head == d2) | ||
m->desk_head = d1; | ||
if (m->desk_tail == d1) | ||
m->desk_tail = d2; | ||
else if (m->desk_tail == d2) | ||
m->desk_tail = d1; | ||
|
||
desktop_t *p1 = d1->prev; | ||
desktop_t *n1 = d1->next; | ||
desktop_t *p2 = d2->prev; | ||
desktop_t *n2 = d2->next; | ||
|
||
if (p1 != NULL && p1 != d2) | ||
p1->next = d2; | ||
if (n1 != NULL && n1 != d2) | ||
n1->prev = d2; | ||
if (p2 != NULL && p2 != d1) | ||
p2->next = d1; | ||
if (n2 != NULL && n2 != d1) | ||
n2->prev = d1; | ||
|
||
d1->prev = p2 == d1 ? d2 : p2; | ||
d1->next = n2 == d1 ? d2 : n2; | ||
d2->prev = p1 == d2 ? d1 : p1; | ||
d2->next = n1 == d2 ? d1 : n1; | ||
|
||
ewmh_update_wm_desktops(); | ||
ewmh_update_desktop_names(); | ||
ewmh_update_current_desktop(); | ||
put_status(); | ||
} | ||
|
||
void show_desktop(desktop_t *d) | ||
{ | ||
if (!visible) | ||
return; | ||
for (node_t *n = first_extrema(d->root); n != NULL; n = next_leaf(n, d->root)) | ||
window_show(n->client->window); | ||
} | ||
|
||
void hide_desktop(desktop_t *d) | ||
{ | ||
if (!visible) | ||
return; | ||
for (node_t *n = first_extrema(d->root); n != NULL; n = next_leaf(n, d->root)) | ||
window_hide(n->client->window); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#ifndef _DESKTOP_H | ||
#define _DESKTOP_H | ||
|
||
#define DEFAULT_DESK_NAME "Desktop" | ||
#define WINDOW_GAP 6 | ||
|
||
desktop_t *make_desktop(const char *); | ||
void insert_desktop(monitor_t *, desktop_t *); | ||
void add_desktop(monitor_t *, desktop_t *); | ||
void empty_desktop(desktop_t *); | ||
void unlink_desktop(monitor_t *, desktop_t *); | ||
void remove_desktop(monitor_t *, desktop_t *); | ||
void swap_desktops(monitor_t *, desktop_t *, desktop_t *); | ||
void transfer_desktop(monitor_t *, monitor_t *, desktop_t *); | ||
void show_desktop(desktop_t *); | ||
void hide_desktop(desktop_t *); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.