added moving tabs
This commit is contained in:
parent
cae16dc8dc
commit
30e39c17fd
19
config.def.h
19
config.def.h
|
@ -1,11 +1,10 @@
|
|||
/* modifier 0 means no modifier */
|
||||
static int surfuseragent = 1; /* Append Surf version to default WebKit user agent */
|
||||
static char *fulluseragent = ""; /* Or override the whole user agent string */
|
||||
static char *scriptfile = "~/.config/surf/script.js";
|
||||
static char *styledir = "~/.config/surf/styles/";
|
||||
static char *tabstyle = "~/.config/surf/styles/tab_bar.css";
|
||||
static char *certdir = "~/.config/surf/certificates/";
|
||||
static char *dlstatus = "~/.config/surf/dlstatus/";
|
||||
static char *scriptfile = "~/.config/savoia/script.js";
|
||||
static char *styledir = "~/.config/savoia/styles/";
|
||||
static char *certdir = "~/.config/savoia/certificates/";
|
||||
static char *dlstatus = "~/.config/savoia/dlstatus/";
|
||||
static char *cachedir = "/tmp/cache";
|
||||
static char *cookiefile = "/tmp/cookies.txt";
|
||||
static char *dldir = "~/dl/";
|
||||
|
@ -13,9 +12,7 @@ static char *dldir = "~/dl/";
|
|||
static int tab_bar_height = 27;
|
||||
static int tab_spacer_height = 4;
|
||||
static const char *tab_bar_color[] = {"#222222", "#318d56"};
|
||||
static const char tabfont[] = "Mononoki Nerd Font:size=16";
|
||||
static int min_tab_fraction_size = 4; // 1/4th of the screen
|
||||
static int click_cooldown_ms = 200;
|
||||
|
||||
static SearchEngine searchengines[] = {
|
||||
{ " ", "https://web.penwing.org/search?q=%s" },
|
||||
|
@ -85,7 +82,7 @@ static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE |
|
|||
.v = (const char *[]){ "/bin/sh", "-c", \
|
||||
"prop=\"$(printf '%b' \"$(xprop -id $1 "r" " \
|
||||
"| sed -e 's/^"r"(UTF8_STRING) = \"\\(.*\\)\"/\\1/' " \
|
||||
" -e 's/\\\\\\(.\\)/\\1/g' && cat ~/.config/surf/bookmarks)\" " \
|
||||
" -e 's/\\\\\\(.\\)/\\1/g' && cat ~/.config/savoia/bookmarks)\" " \
|
||||
"| marukuru -p '"p"' -w $1)\" " \
|
||||
"&& xprop -id $1 -f "s" 8u -set "s" \"$prop\"", \
|
||||
"surf-setprop", winid, NULL \
|
||||
|
@ -122,9 +119,9 @@ static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE |
|
|||
#define BM_ADD(r) {\
|
||||
.v = (const char *[]){ "/bin/sh", "-c", \
|
||||
"(echo $(xprop -id $0 $1) | cut -d '\"' -f2 " \
|
||||
"| sed 's/.*https*:\\/\\/\\(www\\.\\)\\?//' && cat ~/.config/surf/bookmarks) " \
|
||||
"| awk '!seen[$0]++' > ~/.config/surf/bookmarks.tmp && " \
|
||||
"mv ~/.config/surf/bookmarks.tmp ~/.config/surf/bookmarks &&" \
|
||||
"| sed 's/.*https*:\\/\\/\\(www\\.\\)\\?//' && cat ~/.config/savoia/bookmarks) " \
|
||||
"| awk '!seen[$0]++' > ~/.config/savoia/bookmarks.tmp && " \
|
||||
"mv ~/.config/savoia/bookmarks.tmp ~/.config/savoia/bookmarks &&" \
|
||||
"notify-send -u low -a 'savoia' 'added bookmark'", \
|
||||
winid, r, NULL \
|
||||
} \
|
||||
|
|
42
surf.c
42
surf.c
|
@ -151,6 +151,7 @@ typedef struct Client {
|
|||
guint selected_tab;
|
||||
GtkWidget *tab_bar;
|
||||
int tab_click_index;
|
||||
bool tab_drag;
|
||||
} Client;
|
||||
|
||||
typedef struct {
|
||||
|
@ -582,9 +583,7 @@ void tab_bar_mouse_press(GtkWidget *w, GdkEvent *e, Client *c) {
|
|||
}
|
||||
|
||||
tab_mouse_pos_index(e, c, &c->tab_click_index, NULL);
|
||||
|
||||
g_print("press\n");
|
||||
|
||||
c->tab_drag = false;
|
||||
}
|
||||
|
||||
void tab_bar_mouse_release(GtkWidget *w, GdkEvent *e, Client *c) {
|
||||
|
@ -596,20 +595,47 @@ void tab_bar_mouse_release(GtkWidget *w, GdkEvent *e, Client *c) {
|
|||
bool close_tab_flag;
|
||||
tab_mouse_pos_index(e, c, &press_index, &close_tab_flag);
|
||||
|
||||
g_print("%i # %i\n", c->tab_click_index, press_index);
|
||||
if (c->tab_click_index == press_index) {
|
||||
if (!c->tab_drag) {
|
||||
tab_bar_click(c, close_tab_flag);
|
||||
}
|
||||
|
||||
c->tab_click_index = -1;
|
||||
|
||||
}
|
||||
|
||||
void tab_bar_mouse_move(GtkWidget *w, GdkEvent *e, Client *c) {
|
||||
if (c->tab_click_index == -1) {
|
||||
return;
|
||||
}
|
||||
g_print("move\n");
|
||||
int move_index;
|
||||
tab_mouse_pos_index(e, c, &move_index, NULL);
|
||||
|
||||
if (move_index == c->tab_click_index) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (move_index < 0 || move_index >= g_list_length(c->tabs) ||
|
||||
c->tab_click_index < 0 || c->tab_click_index >= g_list_length(c->tabs)) {
|
||||
return;
|
||||
}
|
||||
|
||||
GList *node1 = g_list_nth(c->tabs, c->tab_click_index);
|
||||
GList *node2 = g_list_nth(c->tabs, move_index);
|
||||
|
||||
if (node1 && node2) {
|
||||
GList *temp = node1->data;
|
||||
node1->data = node2->data;
|
||||
node2->data = temp;
|
||||
}
|
||||
|
||||
if (c->selected_tab == move_index) {
|
||||
c->selected_tab = c->tab_click_index;
|
||||
} else if (c->selected_tab == c->tab_click_index) {
|
||||
c->selected_tab = move_index;
|
||||
}
|
||||
|
||||
c->tab_click_index = move_index;
|
||||
c->tab_drag = true;
|
||||
update_tab_bar(c);
|
||||
}
|
||||
|
||||
void tab_bar_click(Client *c, bool close) {
|
||||
|
@ -617,8 +643,6 @@ void tab_bar_click(Client *c, bool close) {
|
|||
return;
|
||||
}
|
||||
|
||||
g_print("click\n");
|
||||
|
||||
if (close) {
|
||||
Arg close_arg = {.i = c->tab_click_index};
|
||||
close_tab(c, &close_arg);
|
||||
|
|
Loading…
Reference in a new issue