63 if (event->type == GDK_2BUTTON_PRESS) {
70 switch (event->button) {
81 if (event->state & GDK_SHIFT_MASK) {
85 if (event->state & GDK_CONTROL_MASK) {
89 if (event->state & GDK_MOD1_MASK) {
110 GdkEventButton *event,
117 gtk_widget_grab_focus(GTK_WIDGET(nsgtk_cw->
drawing_area));
126 nsgtk_cw->
mouse(nsgtk_cw, mouse->
state, event->x, event->y);
144 GdkEventButton *event,
149 bool was_drag =
false;
182 !(
event->state & GDK_SHIFT_MASK)) {
186 !(
event->state & GDK_CONTROL_MASK)) {
190 !(
event->state & GDK_MOD1_MASK)) {
195 if (was_drag && (mouse->
state & (
202 nsgtk_cw->
mouse(nsgtk_cw, mouse->
state, event->x, event->y);
221 GdkEventMotion *event,
228 nsgtk_cw->
mouse(nsgtk_cw,
235 if ((fabs(event->x - mouse->
last_x) < 5.0) &&
236 (fabs(event->y - mouse->
last_y) < 5.0)) {
252 nsgtk_cw->
mouse(nsgtk_cw,
264 nsgtk_cw->
mouse(nsgtk_cw,
279 !(
event->state & GDK_SHIFT_MASK)) {
283 !(
event->state & GDK_CONTROL_MASK)) {
287 !(
event->state & GDK_MOD1_MASK)) {
293 nsgtk_cw->
mouse(nsgtk_cw,
313 GtkAdjustment *vscroll;
314 GtkAdjustment *hscroll;
315 GtkAdjustment *scroll = NULL;
316 gdouble hpage, vpage;
318 vscroll = gtk_scrolled_window_get_vadjustment(nsgtk_cw->
scrolled);
319 hscroll = gtk_scrolled_window_get_hadjustment(nsgtk_cw->
scrolled);
320 g_object_get(vscroll,
"page-size", &vpage, NULL);
321 g_object_get(hscroll,
"page-size", &hpage, NULL);
338 value = gtk_adjustment_get_value(scroll) -
346 value = gtk_adjustment_get_value(scroll) +
353 value = gtk_adjustment_get_value(scroll) -
361 value = gtk_adjustment_get_value(scroll) +
369 value = gtk_adjustment_get_value(scroll) -
379 value = gtk_adjustment_get_value(scroll) +
388 if (scroll != NULL) {
389 gtk_adjustment_set_value(scroll, value);
413 if (gtk_im_context_filter_keypress(nsgtk_cw->
input_method, event)) {
421 res = nsgtk_cw->
key(nsgtk_cw, nskey);
454 return gtk_im_context_filter_keypress(nsgtk_cw->
input_method, event);
477 while (offset < len) {
480 nsgtk_cw->
key(nsgtk_cw, nskey);
487#if GTK_CHECK_VERSION(3,0,0)
510 cairo_clip_extents(cr, &
x1, &
y1, &x2, &y2);
535 GdkEventExpose *event,
541 clip.x0 =
event->area.x;
542 clip.y0 =
event->area.y;
543 clip.x1 =
event->area.x +
event->area.width;
544 clip.y1 =
event->area.y +
event->area.height;
575 gtk_widget_queue_draw(GTK_WIDGET(nsgtk_cw->
drawing_area));
579 gtk_widget_queue_draw_area(GTK_WIDGET(nsgtk_cw->
drawing_area),
601 gtk_widget_set_size_request(GTK_WIDGET(nsgtk_cw->
drawing_area),
623 vadj = gtk_scrolled_window_get_vadjustment(nsgtk_cw->
scrolled);
624 hadj = gtk_scrolled_window_get_hadjustment(nsgtk_cw->
scrolled);
626 assert(vadj != NULL);
627 assert(hadj != NULL);
629 gtk_adjustment_set_value(vadj, y);
630 gtk_adjustment_set_value(hadj, x);
651 vadj = gtk_scrolled_window_get_vadjustment(nsgtk_cw->
scrolled);
652 hadj = gtk_scrolled_window_get_hadjustment(nsgtk_cw->
scrolled);
654 assert(vadj != NULL);
655 assert(hadj != NULL);
657 *y = (int)(gtk_adjustment_get_value(vadj));
658 *x = (int)(gtk_adjustment_get_value(hadj));
684 hadj = gtk_scrolled_window_get_hadjustment(nsgtk_cw->
scrolled);
685 g_object_get(hadj,
"page-size", &page, NULL);
688 vadj = gtk_scrolled_window_get_vadjustment(nsgtk_cw->
scrolled);
689 g_object_get(vadj,
"page-size", &page, NULL);
692 GtkAllocation allocation;
693 gtk_widget_get_allocation(GTK_WIDGET(nsgtk_cw->
drawing_area),
695 *
width = allocation.width;
696 *
height = allocation.height;
739 gtk_im_context_set_client_window(nsgtk_cw->
input_method,
740 gtk_widget_get_parent_window(GTK_WIDGET(nsgtk_cw->
drawing_area)));
741 gtk_im_context_set_use_preedit(nsgtk_cw->
input_method, FALSE);
753 "button-press-event",
758 "button-release-event",
763 "motion-notify-event",
780 0, 0xffff, 0xffff, 0xffff);
void nsgtk_widget_override_background_color(GtkWidget *widget, GtkStateFlags state, uint16_t a, uint16_t r, uint16_t g, uint16_t b)
GdkWindow * nsgtk_widget_get_window(GtkWidget *widget)
gulong nsgtk_connect_draw_event(GtkWidget *widget, GCallback callback, gpointer g)
gdouble nsgtk_adjustment_get_page_increment(GtkAdjustment *adjustment)
gdouble nsgtk_adjustment_get_upper(GtkAdjustment *adjustment)
gdouble nsgtk_adjustment_get_lower(GtkAdjustment *adjustment)
gdouble nsgtk_adjustment_get_step_increment(GtkAdjustment *adjustment)
Compatibility functions for older GTK versions (interface)
#define GTK_STATE_FLAG_NORMAL
core_window_drag_status
drag status passed to drag_status callback
nserror
Enumeration of error codes.
@ NSERROR_NOT_IMPLEMENTED
Functionality is not implemented.
Target independent plotting GTK+ interface.
nserror nsgtk_corewindow_init(struct nsgtk_corewindow *nsgtk_cw)
initialise elements of gtk core window.
static gboolean nsgtk_cw_keypress_event(GtkWidget *widget, GdkEventKey *event, gpointer g)
gtk event on key press.
static gboolean nsgtk_cw_keyrelease_event(GtkWidget *widget, GdkEventKey *event, gpointer g)
gtk event on key release.
static gboolean nsgtk_cw_button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer g)
gtk event on mouse button release.
static gboolean nsgtk_cw_motion_notify_event(GtkWidget *widget, GdkEventMotion *event, gpointer g)
gtk event on mouse movement.
static nserror nsgtk_cw_update_size(struct core_window *cw, int width, int height)
update window size core window callback
static void nsgtk_cw_input_method_commit(GtkIMContext *ctx, const gchar *str, gpointer g)
gtk event handler for input method commit.
static browser_mouse_state nsgtk_cw_gdkbutton_to_nsstate(GdkEventButton *event)
Convert GDK mouse event to netsurf mouse state.
struct core_window_table * nsgtk_core_window_table
static nserror nsgtk_cw_get_window_dimensions(const struct core_window *cw, int *width, int *height)
Callback from the core to obtain the window viewport dimensions.
static nserror nsgtk_cw_get_scroll(const struct core_window *cw, int *x, int *y)
scroll window core window callback
static struct core_window_table nsgtk_cw_cb_table
core window callback table for nsgtk
static nserror nsgtk_cw_drag_status(struct core_window *cw, core_window_drag_status ds)
update window drag status core window callback
static nserror nsgtk_cw_set_scroll(struct core_window *cw, int x, int y)
scroll window core window callback
nserror nsgtk_corewindow_fini(struct nsgtk_corewindow *nsgtk_cw)
finalise elements of gtk core window.
static gboolean nsgtk_cw_draw_event(GtkWidget *widget, GdkEventExpose *event, gpointer g)
handler for gtk draw event on a nsgtk core window for GTK 2
static gboolean nsgtk_cw_button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer g)
gtk event on mouse button press.
static nserror nsgtk_cw_key(struct nsgtk_corewindow *nsgtk_cw, uint32_t nskey)
Deal with keypress events not handled buy input method or callback.
static nserror nsgtk_cw_invalidate_area(struct core_window *cw, const struct rect *rect)
callback from core to request an invalidation of a GTK core window area.
uint32_t gtk_gui_gdkkey_to_nskey(GdkEventKey *key)
input conversion.
Core mouse and pointer states.
browser_mouse_state
Mouse state: 1 is primary mouse button.
@ BROWSER_MOUSE_PRESS_1
primary button pressed
@ BROWSER_MOUSE_CLICK_2
button 2 clicked.
@ BROWSER_MOUSE_PRESS_2
auxillary button pressed
@ BROWSER_MOUSE_HOVER
No mouse buttons pressed, May be used to indicate hover or end of drag.
@ BROWSER_MOUSE_CLICK_1
button 1 clicked.
@ BROWSER_MOUSE_MOD_2
2nd modifier key pressed (eg.
@ BROWSER_MOUSE_DOUBLE_CLICK
button double clicked
@ BROWSER_MOUSE_MOD_3
3rd modifier key pressed (eg.
@ BROWSER_MOUSE_MOD_1
1st modifier key pressed (eg.
@ BROWSER_MOUSE_DRAG_1
start of button 1 drag
@ BROWSER_MOUSE_HOLDING_2
during button 2 drag
@ BROWSER_MOUSE_HOLDING_1
during button 1 drag
@ BROWSER_MOUSE_DRAG_ON
a drag operation was started and a mouse button is still pressed
@ BROWSER_MOUSE_DRAG_2
start of button 2 drag
Interface to key press operations.
#define NSLOG(catname, level, logmsg, args...)
const char * messages_get_errorcode(nserror code)
lookup of a message by errorcode from the standard Messages hash.
Localised message support (interface).
Interface to utility string handling.
Core user interface window function table.
nserror(* invalidate)(struct core_window *cw, const struct rect *rect)
Invalidate an area of a window.
nsgtk core window mouse state
browser_mouse_state state
last event status
nserror(* key)(struct nsgtk_corewindow *nsgtk_cw, uint32_t nskey)
callback for keypress on nsgtk core window
nserror(* draw)(struct nsgtk_corewindow *nsgtk_cw, struct rect *r)
callback to draw on drawable area of nsgtk core window
GtkScrolledWindow * scrolled
scrollable area drawing area is within
nserror(* mouse)(struct nsgtk_corewindow *nsgtk_cw, browser_mouse_state mouse_state, int x, int y)
callback for mouse event on nsgtk core window
core_window_drag_status drag_status
drag status set by core
GtkDrawingArea * drawing_area
GTK drawable widget.
GtkIMContext * input_method
Input method.
struct nsgtk_corewindow_mouse mouse_state
mouse state
uint32_t utf8_to_ucs4(const char *s_in, size_t l)
Convert a UTF-8 multibyte sequence into a single UCS4 character.
size_t utf8_next(const char *s, size_t l, size_t o)
Find next legal UTF-8 char in string.
UTF-8 manipulation functions (interface).
static nserror clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.