performance improvements, add zoom functionality
This commit is contained in:
parent
e397b14dbe
commit
b132abcd23
4
config.h
4
config.h
|
@ -12,6 +12,8 @@ static Key keys[] = {
|
||||||
{ MODKEY, GDK_KEY_l, goforward },
|
{ MODKEY, GDK_KEY_l, goforward },
|
||||||
{ MODKEY, GDK_KEY_y, copy_url },
|
{ MODKEY, GDK_KEY_y, copy_url },
|
||||||
{ MODKEY, GDK_KEY_p, paste_url },
|
{ MODKEY, GDK_KEY_p, paste_url },
|
||||||
|
{ MODKEY, GDK_KEY_e, search },
|
||||||
|
{ MODKEY, GDK_KEY_equal, zoomin },
|
||||||
|
{ MODKEY, GDK_KEY_minus, zoomout },
|
||||||
{ 0, GDK_KEY_F11, fullscreen },
|
{ 0, GDK_KEY_F11, fullscreen },
|
||||||
{ MODKEY, GDK_KEY_e, search }
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,5 +18,7 @@ enum {
|
||||||
paste_url,
|
paste_url,
|
||||||
fullscreen,
|
fullscreen,
|
||||||
inspector,
|
inspector,
|
||||||
search
|
search,
|
||||||
|
zoomin,
|
||||||
|
zoomout
|
||||||
};
|
};
|
||||||
|
|
19
makefile
19
makefile
|
@ -1,9 +1,24 @@
|
||||||
CC = clang
|
CC = clang
|
||||||
CFLAGS = `pkg-config --cflags gtk4 webkit2gtk-5.0 x11`
|
CFLAGS = `pkg-config --cflags gtk4 webkit2gtk-5.0 x11 `
|
||||||
LIBS = `pkg-config --libs gtk4 webkit2gtk-5.0 x11`
|
LIBS = `pkg-config --libs gtk4 webkit2gtk-5.0 x11`
|
||||||
|
GTKFLAGS = -Dgtk_doc=false -Dintrospection=false \
|
||||||
|
-DG_DISABLE_CAST_CHECKS \
|
||||||
|
-Dcloudproviders=false \
|
||||||
|
-DGTK_DISABLE_DEPRECATED \
|
||||||
|
-GDK_PIXBUF_DISABLE_DEPRECATED \
|
||||||
|
-G_DISABLE_DEPRECATED -DENABLE_GLES2=ON \
|
||||||
|
-DENABLE_GEOLOCATION=OFF -DENABLE_PLUGIN_PROCESS_GTK2=OFF \
|
||||||
|
-DPORT=GTK \
|
||||||
|
-Dforce_posix_threads=true \
|
||||||
|
-Dman=false \
|
||||||
|
-Dxinerama=false \
|
||||||
|
-Dcolord=false \
|
||||||
|
-Db_coverage=false \
|
||||||
|
-Ddebug=false
|
||||||
|
|
||||||
|
|
||||||
all:
|
all:
|
||||||
${CC} -fPIC -O3 -o rose *.c $(CFLAGS) $(LIBS)
|
${CC} -fPIC -Os -o rose *.c $(CFLAGS) $(LIBS) $(GTKFLAGS)
|
||||||
strip ./rose
|
strip ./rose
|
||||||
|
|
||||||
install: all
|
install: all
|
||||||
|
|
15
webview.c
15
webview.c
|
@ -113,12 +113,16 @@ GtkWidget* rose_webview_new()
|
||||||
WebKitUserContentManager *contentmanager;
|
WebKitUserContentManager *contentmanager;
|
||||||
|
|
||||||
WebKitSettings *settings = webkit_settings_new_with_settings(
|
WebKitSettings *settings = webkit_settings_new_with_settings(
|
||||||
"auto-load-images", true,
|
"auto-load-images", TRUE,
|
||||||
"enable-back-forward-navigation-gestures", true,
|
"enable-back-forward-navigation-gestures", TRUE,
|
||||||
"enable-developer-extras", true,
|
"enable-developer-extras", TRUE,
|
||||||
"enable-media-stream", true,
|
"enable-media-stream", TRUE,
|
||||||
|
"enable-plugins", FALSE,
|
||||||
|
"enable-dns-prefetching", TRUE,
|
||||||
|
"enable-smooth-scrolling", TRUE,
|
||||||
|
"media-content-types-requiring-hardware-support", "video:/mp4;codecs=\"H.264-encoded\"",
|
||||||
"hardware-acceleration-policy", WEBKIT_HARDWARE_ACCELERATION_POLICY_ALWAYS,
|
"hardware-acceleration-policy", WEBKIT_HARDWARE_ACCELERATION_POLICY_ALWAYS,
|
||||||
"javascript-can-access-clipboard", true, NULL);
|
"javascript-can-access-clipboard", TRUE, NULL);
|
||||||
|
|
||||||
WebKitWebContext *context = webkit_web_context_new_with_website_data_manager(
|
WebKitWebContext *context = webkit_web_context_new_with_website_data_manager(
|
||||||
webkit_website_data_manager_new(
|
webkit_website_data_manager_new(
|
||||||
|
@ -129,7 +133,6 @@ GtkWidget* rose_webview_new()
|
||||||
webkit_settings_set_user_agent_with_application_details(
|
webkit_settings_set_user_agent_with_application_details(
|
||||||
settings, "Mini", "0.1");
|
settings, "Mini", "0.1");
|
||||||
|
|
||||||
webkit_web_context_set_process_model(context, WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES);
|
|
||||||
webkit_web_context_set_cache_model(context, WEBKIT_CACHE_MODEL_WEB_BROWSER);
|
webkit_web_context_set_cache_model(context, WEBKIT_CACHE_MODEL_WEB_BROWSER);
|
||||||
contentmanager = webkit_user_content_manager_new();
|
contentmanager = webkit_user_content_manager_new();
|
||||||
cookiemanager = webkit_web_context_get_cookie_manager(context);
|
cookiemanager = webkit_web_context_get_cookie_manager(context);
|
||||||
|
|
17
window.c
17
window.c
|
@ -20,6 +20,8 @@ enum {
|
||||||
PROP_ACTIVE_CHILD
|
PROP_ACTIVE_CHILD
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static float zoom = 1.0;
|
||||||
|
|
||||||
G_DEFINE_TYPE(RoseWindow, rose_window, GTK_TYPE_APPLICATION_WINDOW)
|
G_DEFINE_TYPE(RoseWindow, rose_window, GTK_TYPE_APPLICATION_WINDOW)
|
||||||
|
|
||||||
static void read_clipboard(GObject *object,
|
static void read_clipboard(GObject *object,
|
||||||
|
@ -85,10 +87,20 @@ static gboolean key_press_callback(RoseWindow *window,
|
||||||
webkit_web_view_load_uri(window->webview, getatom(AtomGo));
|
webkit_web_view_load_uri(window->webview, getatom(AtomGo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case zoomin:
|
||||||
|
zoom += 0.1;
|
||||||
|
webkit_web_view_set_zoom_level(window->webview, zoom);
|
||||||
|
break;
|
||||||
|
case zoomout:
|
||||||
|
zoom -= 0.1;
|
||||||
|
webkit_web_view_set_zoom_level(window->webview, zoom);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("%i\n", keyval);
|
||||||
|
puts("");
|
||||||
return GDK_EVENT_PROPAGATE;
|
return GDK_EVENT_PROPAGATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +117,12 @@ static void rose_window_init(RoseWindow *window)
|
||||||
guint rose_window_show(GtkApplication *app, RoseWindow *window, const char *url)
|
guint rose_window_show(GtkApplication *app, RoseWindow *window, const char *url)
|
||||||
{
|
{
|
||||||
GtkWidget *w = gtk_application_window_new(app);
|
GtkWidget *w = gtk_application_window_new(app);
|
||||||
|
|
||||||
|
gtk_application_set_menubar(app, FALSE);
|
||||||
GtkWidget *webview = rose_webview_new();
|
GtkWidget *webview = rose_webview_new();
|
||||||
|
gtk_widget_set_has_tooltip(webview, FALSE);
|
||||||
|
gtk_widget_has_default(webview);
|
||||||
|
gtk_window_set_destroy_with_parent(GTK_WINDOW(w), TRUE);
|
||||||
window->webview = WEBKIT_WEB_VIEW(webview);
|
window->webview = WEBKIT_WEB_VIEW(webview);
|
||||||
|
|
||||||
if (url)
|
if (url)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user