summaryrefslogtreecommitdiff
path: root/Docs/core-window-interface
blob: 0d5f7bccb81e7bd00405912a21fc34c5a0512898 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
Core Window Interface
=====================

The NetSurf core provides an optional API to frontend implementations
which allows a number of "standard" window content interfaces to be
provided.

The currently available user interfaces are:

 - Cookies
 - Global history
 - Hotlist
 - SSL certificate view

Although not currently included in future additional user interfaces
will be available for:

 - local history
 - browser render

To be clear these are generic implementations of this functionality
that any frontend may use. Frontends are free to implement these
interfaces in any manner as they see fit, the corewindow interface
simply provides a default.

core window API
---------------

The API is fairly simple and simply involves passing a callback table
and context pointer to the interface element being constructed.

The header that defines the callback interface is netsurf/core_window.h 

The callback table contains five function pointer interfaces which the
frontend must implement for the core.

 - redraw_request
      request a redraw an area of a window

 - update_size
      Update the limits of the window 

 - scroll_visible
      Scroll the window to make area visible

 - get_window_dimensions
      Get window viewport dimensions

 - drag_status
      Inform corewindow owner of drag status

Each callback will be passed the context pointer for the corewindow
instance and the relevant additional information necessary to perform
the operation.

Each exported user interface element wraps this generic interface with
a concrete implementation. For example the SSL certificate viewer is
initialised with:

nserror sslcert_viewer_init(struct core_window_callback_table *cw_t,
                            void *core_window_handle,
                            struct sslcert_session_data *ssl_d);

This call creates a context which will display and navigate the ssl
session data passed. The frontend must service the callbacks from the
core to provide the necessary interactions with the frontend windowing
system.

These actions should ideally use the standard frontend window
processing. So for the GTK frontend when the core calls the redraw
operation it simply marks the area passed as damaged (using
gtk_widget_queue_draw_area()) and lets the standard expose event cause
the redraw to occour.

If the frontend needs to redraw an area of a window (perhaps an expose
event occoured) it must call the corewindoe API wrappers
implementation e.g in the case of ssl certificate viewer

void sslcert_viewer_redraw(struct sslcert_session_data *ssl_d,
		           int x, int y, struct rect *clip,
		           const struct redraw_context *ctx);

which will perform the plot operations required to update an area of
the window for that SSL data.

Usage
-----

The usage pattern that is expected is for a frontend to create a core
window impementation that implements the necessary five API in a
generic way and allows the frontend to provide the specific
specialisation for each of the user interface elements it wishes to
use (cookies, SSL viewer etc).

The GTK frontend for example:

has source corewindow.[ch] which implement the five core callbacks
using generic GTK operations (redraw_request calls
gtk_widget_queue_draw_area() etc.) and then provides additional
operations on a GTK drawing area object to attach expose event
processing, keypress processing etc.

The GTK corewindow (not to be confused with the core window API
itself, this is purely the gtk wrapper) is used by ssl_cert.c which
creates a nsgtk_crtvrfy_window structure containing the
nsgtk_corewindow structure. It attaches actual GTK window handles to
this structure and populates elements of nsgtk_corewindow and then
calls sslcert_viewer_init() directly.