summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
Diffstat (limited to 'gtk')
-rw-r--r--gtk/font_pango.c1
-rw-r--r--gtk/gtk_gui.c70
-rw-r--r--gtk/gtk_gui.h3
-rw-r--r--gtk/gtk_plotters.c2
-rw-r--r--gtk/gtk_window.c43
5 files changed, 77 insertions, 42 deletions
diff --git a/gtk/font_pango.c b/gtk/font_pango.c
index e5994e71e..eda2f89c9 100644
--- a/gtk/font_pango.c
+++ b/gtk/font_pango.c
@@ -183,6 +183,7 @@ bool nsfont_split(const struct css_style *style,
pango_layout_set_width(layout, x * PANGO_SCALE);
pango_layout_set_wrap(layout, PANGO_WRAP_WORD);
+ pango_layout_set_single_paragraph_mode(layout, true);
line = pango_layout_get_line(layout, 1);
if (line)
index = line->start_index - 1;
diff --git a/gtk/gtk_gui.c b/gtk/gtk_gui.c
index 763898186..b8217b7f1 100644
--- a/gtk/gtk_gui.c
+++ b/gtk/gtk_gui.c
@@ -43,6 +43,7 @@
#include "desktop/netsurf.h"
#include "desktop/options.h"
#include "desktop/save_pdf/pdf_plotters.h"
+#include "desktop/textinput.h"
#include "gtk/gtk_gui.h"
#include "gtk/dialogs/gtk_options.h"
#include "gtk/gtk_completion.h"
@@ -734,3 +735,72 @@ static void nsgtk_PDF_no_pass(GtkButton *w, gpointer data)
}
#endif
+uint32_t gtk_gui_gdkkey_to_nskey(GdkEventKey *key)
+{
+ /* this function will need to become much more complex to support
+ * everything that the RISC OS version does. But this will do for
+ * now. I hope.
+ */
+ switch (key->keyval)
+ {
+ case GDK_BackSpace:
+ if (key->state & GDK_SHIFT_MASK)
+ return KEY_DELETE_LINE_START;
+ else
+ return KEY_DELETE_LEFT;
+ case GDK_Delete:
+ if (key->state & GDK_SHIFT_MASK)
+ return KEY_DELETE_LINE_END;
+ else
+ return KEY_DELETE_RIGHT;
+ case GDK_Linefeed: return 13;
+ case GDK_Return: return 10;
+ case GDK_Left: return KEY_LEFT;
+ case GDK_Right: return KEY_RIGHT;
+ case GDK_Up: return KEY_UP;
+ case GDK_Down: return KEY_DOWN;
+ case GDK_Home:
+ if (key->state & GDK_CONTROL_MASK)
+ return KEY_TEXT_START;
+ else
+ return KEY_LINE_START;
+ case GDK_End:
+ if (key->state & GDK_CONTROL_MASK)
+ return KEY_TEXT_END;
+ else
+ return KEY_LINE_END;
+ case GDK_Page_Up:
+ return KEY_PAGE_UP;
+ case GDK_Page_Down:
+ return KEY_PAGE_DOWN;
+ case 'a':
+ if (key->state & GDK_CONTROL_MASK)
+ return KEY_SELECT_ALL;
+ return gdk_keyval_to_unicode(key->keyval);
+ case 'u':
+ if (key->state & GDK_CONTROL_MASK)
+ return KEY_CLEAR_SELECTION;
+ return gdk_keyval_to_unicode(key->keyval);
+ case GDK_Escape:
+ return KEY_ESCAPE;
+
+ /* Modifiers - do nothing for now */
+ case GDK_Shift_L:
+ case GDK_Shift_R:
+ case GDK_Control_L:
+ case GDK_Control_R:
+ case GDK_Caps_Lock:
+ case GDK_Shift_Lock:
+ case GDK_Meta_L:
+ case GDK_Meta_R:
+ case GDK_Alt_L:
+ case GDK_Alt_R:
+ case GDK_Super_L:
+ case GDK_Super_R:
+ case GDK_Hyper_L:
+ case GDK_Hyper_R: return 0;
+
+ default: return gdk_keyval_to_unicode(
+ key->keyval);
+ }
+}
diff --git a/gtk/gtk_gui.h b/gtk/gtk_gui.h
index eab25873b..8c9aa0afb 100644
--- a/gtk/gtk_gui.h
+++ b/gtk/gtk_gui.h
@@ -19,6 +19,7 @@
#ifndef GTK_GUI_H
#define GTK_GUI_H
+#include <inttypes.h>
#include <stdbool.h>
#include <gtk/gtk.h>
#include <glade/glade.h>
@@ -37,5 +38,7 @@ extern GtkLabel *labelTooltip;
extern GtkDialog *wndOpenFile;
+uint32_t gtk_gui_gdkkey_to_nskey(GdkEventKey *);
+
#endif /* GTK_GUI_H */
diff --git a/gtk/gtk_plotters.c b/gtk/gtk_plotters.c
index 935b07992..700493b4c 100644
--- a/gtk/gtk_plotters.c
+++ b/gtk/gtk_plotters.c
@@ -119,7 +119,7 @@ bool nsgtk_plot_rectangle(int x0, int y0, int width, int height,
line_width = 1;
cairo_set_line_width(current_cr, line_width);
- cairo_rectangle(current_cr, x0, y0, width, height);
+ cairo_rectangle(current_cr, x0 + 0.5, y0 + 0.5, width, height);
cairo_stroke(current_cr);
return true;
diff --git a/gtk/gtk_window.c b/gtk/gtk_window.c
index 57ac59ca5..7649418c4 100644
--- a/gtk/gtk_window.c
+++ b/gtk/gtk_window.c
@@ -38,7 +38,7 @@
struct gui_window *window_list = 0; /**< first entry in win list*/
int temp_open_background = -1;
-static uint32_t gdkkey_to_nskey(GdkEventKey *);
+
static void nsgtk_gui_window_attach_child(struct gui_window *parent,
struct gui_window *child);
/* Methods which apply only to a gui_window */
@@ -449,50 +449,11 @@ gboolean nsgtk_window_button_release_event(GtkWidget *widget,
return TRUE;
}
-uint32_t gdkkey_to_nskey(GdkEventKey *key)
-{
- /* this function will need to become much more complex to support
- * everything that the RISC OS version does. But this will do for
- * now. I hope.
- */
-
- switch (key->keyval)
- {
- case GDK_BackSpace: return KEY_DELETE_LEFT;
- case GDK_Delete: return KEY_DELETE_RIGHT;
- case GDK_Linefeed: return 13;
- case GDK_Return: return 10;
- case GDK_Left: return KEY_LEFT;
- case GDK_Right: return KEY_RIGHT;
- case GDK_Up: return KEY_UP;
- case GDK_Down: return KEY_DOWN;
-
- /* Modifiers - do nothing for now */
- case GDK_Shift_L:
- case GDK_Shift_R:
- case GDK_Control_L:
- case GDK_Control_R:
- case GDK_Caps_Lock:
- case GDK_Shift_Lock:
- case GDK_Meta_L:
- case GDK_Meta_R:
- case GDK_Alt_L:
- case GDK_Alt_R:
- case GDK_Super_L:
- case GDK_Super_R:
- case GDK_Hyper_L:
- case GDK_Hyper_R: return 0;
-
- default: return gdk_keyval_to_unicode(
- key->keyval);
- }
-}
-
gboolean nsgtk_window_keypress_event(GtkWidget *widget, GdkEventKey *event,
gpointer data)
{
struct gui_window *g = data;
- uint32_t nskey = gdkkey_to_nskey(event);
+ uint32_t nskey = gtk_gui_gdkkey_to_nskey(event);
if (browser_window_key_press(g->bw, nskey))
return TRUE;