NetSurf
|
GTK generic core window interface. More...
#include <assert.h>
#include <string.h>
#include <math.h>
#include <gtk/gtk.h>
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/utf8.h"
#include "netsurf/types.h"
#include "netsurf/keypress.h"
#include "netsurf/mouse.h"
#include "gtk/compat.h"
#include "gtk/gui.h"
#include "gtk/plotters.h"
#include "gtk/corewindow.h"
Go to the source code of this file.
Functions | |
static browser_mouse_state | nsgtk_cw_gdkbutton_to_nsstate (GdkEventButton *event) |
Convert GDK mouse event to netsurf mouse state. More... | |
static gboolean | nsgtk_cw_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer g) |
gtk event on mouse button press. More... | |
static gboolean | nsgtk_cw_button_release_event (GtkWidget *widget, GdkEventButton *event, gpointer g) |
gtk event on mouse button release. More... | |
static gboolean | nsgtk_cw_motion_notify_event (GtkWidget *widget, GdkEventMotion *event, gpointer g) |
gtk event on mouse movement. More... | |
static nserror | nsgtk_cw_key (struct nsgtk_corewindow *nsgtk_cw, uint32_t nskey) |
Deal with keypress events not handled buy input method or callback. More... | |
static gboolean | nsgtk_cw_keypress_event (GtkWidget *widget, GdkEventKey *event, gpointer g) |
gtk event on key press. More... | |
static gboolean | nsgtk_cw_keyrelease_event (GtkWidget *widget, GdkEventKey *event, gpointer g) |
gtk event on key release. More... | |
static void | nsgtk_cw_input_method_commit (GtkIMContext *ctx, const gchar *str, gpointer g) |
gtk event handler for input method commit. More... | |
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 More... | |
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. More... | |
static nserror | nsgtk_cw_update_size (struct core_window *cw, int width, int height) |
update window size core window callback More... | |
static nserror | nsgtk_cw_set_scroll (struct core_window *cw, int x, int y) |
scroll window core window callback More... | |
static nserror | nsgtk_cw_get_scroll (const struct core_window *cw, int *x, int *y) |
scroll window core window callback More... | |
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. More... | |
static nserror | nsgtk_cw_drag_status (struct core_window *cw, core_window_drag_status ds) |
update window drag status core window callback More... | |
nserror | nsgtk_corewindow_init (struct nsgtk_corewindow *nsgtk_cw) |
initialise elements of gtk core window. More... | |
nserror | nsgtk_corewindow_fini (struct nsgtk_corewindow *nsgtk_cw) |
finalise elements of gtk core window. More... | |
Variables | |
static struct core_window_table | nsgtk_cw_cb_table |
core window callback table for nsgtk More... | |
struct core_window_table * | nsgtk_core_window_table = &nsgtk_cw_cb_table |
GTK generic core window interface.
Provides interface for core renderers to the gtk toolkit drawable area.
This module is an object that must be encapsulated. Client users should embed a struct nsgtk_corewindow at the beginning of their context for this display surface, fill in relevant data and then call nsgtk_corewindow_init()
The nsgtk core window structure requires the drawing area and scrollable widgets are present and the callback for draw, key and mouse operations.
Definition in file corewindow.c.
nserror nsgtk_corewindow_fini | ( | struct nsgtk_corewindow * | nsgtk_cw | ) |
finalise elements of gtk core window.
nsgtk_cw | A gtk core window structure to initialise |
Definition at line 786 of file corewindow.c.
References nsgtk_corewindow::input_method, and NSERROR_OK.
Referenced by nsgtk_cookies_destroy(), nsgtk_global_history_destroy(), nsgtk_hotlist_destroy(), nsgtk_local_history_destroy(), and nsgtk_pi_delete_event().
nserror nsgtk_corewindow_init | ( | struct nsgtk_corewindow * | nsgtk_cw | ) |
initialise elements of gtk core window.
nsgtk_cw | A gtk core window structure to initialise |
Definition at line 733 of file corewindow.c.
References CORE_WINDOW_DRAG_NONE, nsgtk_corewindow::drag_status, nsgtk_corewindow::drawing_area, GTK_STATE_FLAG_NORMAL, nsgtk_corewindow::input_method, NSERROR_OK, nsgtk_connect_draw_event(), nsgtk_cw_button_press_event(), nsgtk_cw_button_release_event(), nsgtk_cw_draw_event(), nsgtk_cw_input_method_commit(), nsgtk_cw_keypress_event(), nsgtk_cw_keyrelease_event(), nsgtk_cw_motion_notify_event(), and nsgtk_widget_override_background_color().
Referenced by nsgtk_cookies_init(), nsgtk_global_history_init(), nsgtk_hotlist_init(), nsgtk_local_history_init(), and nsgtk_page_info().
|
static |
gtk event on mouse button press.
Service gtk event for a mouse button transition to pressed from released state.
widget | The gtk widget the event occurred for. |
event | The event that occurred. |
g | The context pointer passed when the event was registered. |
Definition at line 109 of file corewindow.c.
References nsgtk_corewindow::drawing_area, nsgtk_corewindow::input_method, nsgtk_corewindow_mouse::last_x, nsgtk_corewindow_mouse::last_y, nsgtk_corewindow::mouse, nsgtk_corewindow::mouse_state, nsgtk_cw_gdkbutton_to_nsstate(), nsgtk_corewindow_mouse::pressed, nsgtk_corewindow_mouse::pressed_x, nsgtk_corewindow_mouse::pressed_y, and nsgtk_corewindow_mouse::state.
Referenced by nsgtk_corewindow_init().
|
static |
gtk event on mouse button release.
Service gtk event for a mouse button transition from pressed to released state.
widget | The gtk widget the event occurred for. |
event | The event that occurred. |
g | The context pointer passed when the event was registered. |
Definition at line 143 of file corewindow.c.
References BROWSER_MOUSE_CLICK_1, BROWSER_MOUSE_CLICK_2, BROWSER_MOUSE_DOUBLE_CLICK, BROWSER_MOUSE_DRAG_ON, BROWSER_MOUSE_HOLDING_1, BROWSER_MOUSE_HOLDING_2, BROWSER_MOUSE_HOVER, BROWSER_MOUSE_MOD_1, BROWSER_MOUSE_MOD_2, BROWSER_MOUSE_MOD_3, BROWSER_MOUSE_PRESS_1, BROWSER_MOUSE_PRESS_2, nsgtk_corewindow::mouse, nsgtk_corewindow::mouse_state, nsgtk_corewindow_mouse::pressed, and nsgtk_corewindow_mouse::state.
Referenced by nsgtk_corewindow_init().
|
static |
update window drag status core window callback
cw | core window handle. |
ds | The new drag status. |
Definition at line 709 of file corewindow.c.
References nsgtk_corewindow::drag_status, and NSERROR_OK.
|
static |
handler for gtk draw event on a nsgtk core window for GTK 2
widget | The GTK widget to redraw. |
event | The GDK expose event |
g | The context pointer passed when the event was registered. |
Definition at line 534 of file corewindow.c.
References clip(), current_cr, nsgtk_corewindow::draw, and nsgtk_widget_get_window().
Referenced by nsgtk_corewindow_init().
|
static |
Convert GDK mouse event to netsurf mouse state.
event | The GDK mouse event to convert. |
Definition at line 59 of file corewindow.c.
References BROWSER_MOUSE_DOUBLE_CLICK, BROWSER_MOUSE_HOVER, BROWSER_MOUSE_MOD_1, BROWSER_MOUSE_MOD_2, BROWSER_MOUSE_MOD_3, BROWSER_MOUSE_PRESS_1, and BROWSER_MOUSE_PRESS_2.
Referenced by nsgtk_cw_button_press_event().
|
static |
scroll window core window callback
cw | core window handle. |
r | rectangle that needs scrolling. |
Definition at line 643 of file corewindow.c.
References NSERROR_OK, and nsgtk_corewindow::scrolled.
|
static |
Callback from the core to obtain the window viewport dimensions.
[in] | cw | the core window object |
[out] | width | to be set to viewport width in px |
[out] | height | to be set to viewport height in px |
Definition at line 675 of file corewindow.c.
References nsgtk_corewindow::drawing_area, height, NSERROR_OK, nsgtk_corewindow::scrolled, and width.
|
static |
gtk event handler for input method commit.
Service gtk commit for input method commit action.
ctx | The gtk input method context the event occurred for. |
str | The resulting string from the input method. |
g | The context pointer passed when the event was registered. |
Definition at line 468 of file corewindow.c.
References nsgtk_corewindow::key, utf8_next(), and utf8_to_ucs4().
Referenced by nsgtk_corewindow_init().
|
static |
callback from core to request an invalidation of a GTK core window area.
The specified area of the window should now be considered out of date. If the area is NULL the entire window must be invalidated.
[in] | cw | The core window to invalidate. |
[in] | rect | area to redraw or NULL for the entire window area. |
Definition at line 570 of file corewindow.c.
References nsgtk_corewindow::drawing_area, NSERROR_OK, rect::x0, rect::x1, rect::y0, and rect::y1.
|
static |
Deal with keypress events not handled buy input method or callback.
nsgtk_cw | nsgtk core window key event happened in. |
nskey | The netsurf keycode of the event. |
Definition at line 310 of file corewindow.c.
References NS_KEY_DOWN, NS_KEY_LEFT, NS_KEY_PAGE_DOWN, NS_KEY_PAGE_UP, NS_KEY_RIGHT, NS_KEY_TEXT_END, NS_KEY_TEXT_START, NS_KEY_UP, NSERROR_OK, nsgtk_adjustment_get_lower(), nsgtk_adjustment_get_page_increment(), nsgtk_adjustment_get_step_increment(), nsgtk_adjustment_get_upper(), and nsgtk_corewindow::scrolled.
Referenced by nsgtk_cw_keypress_event().
|
static |
gtk event on key press.
Service gtk key-press-event for key transition on a widget from released to pressed.
widget | The gtk widget the event occurred for. |
event | The event that occurred. |
g | The context pointer passed when the event was registered. |
Definition at line 406 of file corewindow.c.
References gtk_gui_gdkkey_to_nskey(), nsgtk_corewindow::input_method, nsgtk_corewindow::key, messages_get_errorcode(), NSERROR_NOT_IMPLEMENTED, NSERROR_OK, nsgtk_cw_key(), and NSLOG.
Referenced by nsgtk_corewindow_init().
|
static |
gtk event on key release.
Service gtk key-release-event for key transition on a widget from pressed to released.
widget | The gtk widget the event occurred for. |
event | The event that occurred. |
g | The context pointer passed when the event was registered. |
Definition at line 450 of file corewindow.c.
References nsgtk_corewindow::input_method.
Referenced by nsgtk_corewindow_init().
|
static |
gtk event on mouse movement.
Service gtk motion-notify-event for mouse movement above a widget.
widget | The gtk widget the event occurred for. |
event | The motion event that occurred. |
g | The context pointer passed when the event was registered. |
Definition at line 220 of file corewindow.c.
References BROWSER_MOUSE_DRAG_1, BROWSER_MOUSE_DRAG_2, BROWSER_MOUSE_DRAG_ON, BROWSER_MOUSE_HOLDING_1, BROWSER_MOUSE_HOLDING_2, BROWSER_MOUSE_HOVER, BROWSER_MOUSE_MOD_1, BROWSER_MOUSE_MOD_2, BROWSER_MOUSE_MOD_3, BROWSER_MOUSE_PRESS_1, BROWSER_MOUSE_PRESS_2, nsgtk_corewindow_mouse::last_x, nsgtk_corewindow_mouse::last_y, nsgtk_corewindow::mouse, nsgtk_corewindow::mouse_state, nsgtk_corewindow_mouse::pressed, nsgtk_corewindow_mouse::pressed_x, nsgtk_corewindow_mouse::pressed_y, and nsgtk_corewindow_mouse::state.
Referenced by nsgtk_corewindow_init().
|
static |
scroll window core window callback
cw | core window handle. |
r | rectangle that needs scrolling. |
Definition at line 615 of file corewindow.c.
References NSERROR_OK, and nsgtk_corewindow::scrolled.
|
static |
update window size core window callback
cw | core window handle. |
width | New widget width. |
height | New widget height. |
Definition at line 597 of file corewindow.c.
References nsgtk_corewindow::drawing_area, height, NSERROR_OK, and width.
struct core_window_table* nsgtk_core_window_table = &nsgtk_cw_cb_table |
Definition at line 730 of file corewindow.c.
Referenced by main().
|
static |
core window callback table for nsgtk
Definition at line 721 of file corewindow.c.