Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Factor out switcheroos for the different wayland shell protocols #359

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: true
FixNamespaceComments: true
Expand Down
42 changes: 37 additions & 5 deletions .github/toolchain.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,51 @@
#! /bin/bash
set -e
set -eu -o pipefail

# Info on available toolchains: https://wk-contrib.igalia.com/
INSTALL_DIR=${1:-${HOME}/toolchain}
BASEURL=https://wk-contrib.igalia.com/yocto/meta-perf-browser/browsers/nightly/sdk
FILE=wandboard-mesa/browsers-glibc-x86_64-core-image-weston-browsers-armv7at2hf-neon-wandboard-mesa-toolchain-1.0.sh
BASEURL=https://wk-contrib.igalia.com/yocto/meta-perf-browser/browsers/stable/sdk
FILE=wandboard-mesa/browsers-glibc-x86_64-core-image-weston-browsers-cortexa9t2hf-neon-wandboard-mesa-toolchain-1.0.sh

declare -r INSTALL_DIR BASEURL FILE
rm -f ~/toolchain.sh

declare -a curl_opts=( --retry 3 -L )
declare -a curl_opts=( --http1.1 --retry 3 -L -C - )
if [[ -r ${INSTALL_DIR}/.installed ]] ; then
curl_opts+=( --time-cond "${INSTALL_DIR}/.installed" )
fi

curl "${curl_opts[@]}" -o ~/toolchain.sh "${BASEURL}/${FILE}"
declare -i tries=0

function fetch_installer {
if [[ $(( tries++ )) -ge 10 ]] ; then
echo 'Maximum amount of retries reached, bailing out.' 1>&2
return 1
fi

local exit_code=0
if curl "${curl_opts[@]}" -o ~/toolchain.sh "${BASEURL}/${FILE}" ; then
return 0
else
exit_code=$?

if [[ ${exit_code} -eq 36 ]] ; then
echo "Bad resume (${exit_code}), restarting download from scratch..." 1>&2
rm -f ~/toolchain.sh
else
echo "Download error (${exit_code}), retrying download..." 1>&2
fi
local seconds=$(( RANDOM % 10 + 5 ))
printf 'Waiting... %i' "${seconds}"
while [[ $(( seconds-- )) -gt 0 ]] ; do
sleep 1
printf ' %i' "${seconds}"
done
echo '.'
fetch_installer
fi
}

fetch_installer

if [[ -r ~/toolchain.sh ]] ; then
echo 'Installing toolchain...'
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/ci-cross.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Install Debian Packages
run: |
sudo apt update
sudo apt install -y cmake ninja-build
sudo apt install -y cmake ninja-build libwayland-bin
- name: Cache
uses: actions/cache@v2
id: cache
Expand All @@ -29,8 +29,9 @@ jobs:
env:
BUILD_TYPE: ${{ matrix.buildtype }}
run: |-
. ~/toolchain/environment-setup-armv7at2hf-neon-poky-linux-gnueabi
. ~/toolchain/environment-setup-*-poky-linux-gnueabi
cmake -GNinja -S. -Bbuild \
-DWAYLAND_SCANNER=/usr/bin/wayland-scanner \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DCOG_PLATFORM_FDO=ON \
-DCOG_PLATFORM_DRM=ON
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codestyle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
curl -sL https://apt.llvm.org/llvm-snapshot.gpg.key | \
sudo apt-key add -
sudo add-apt-repository \
'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-11 main'
'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-13 main'
sudo apt update
sudo apt install -y clang-format-11 diffutils
sudo apt install -y clang-format-13 diffutils
- name: Check
run: |
data/check-style -ocode-style.diff origin/master
Expand Down
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cmake_minimum_required (VERSION 3.3)
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_SOURCE_DIR}/cmake")
include(VersioningUtils)

set_project_version(0 9 1)
set_project_version(0 13 0)

# Before making a release, the LT_VERSION string should be modified.
# The string is of the form C:R:A.
Expand All @@ -12,7 +12,7 @@ set_project_version(0 9 1)
# - If binary compatibility has been broken (eg removed or changed interfaces)
# change to C+1:0:0
# - If the interface is the same as the previous version, change to C:R+1:A
calculate_library_versions_from_libtool_triple(COGCORE 5 0 4)
calculate_library_versions_from_libtool_triple(COGCORE 8 0 1)

project(cog VERSION "${PROJECT_VERSION}" LANGUAGES C)
include(DistTargets)
Expand Down Expand Up @@ -126,11 +126,13 @@ set(COGCORE_SOURCES
)

if (USE_SOUP2)
set(WPEWEBKIT_PC_NAME "wpe-webkit-1.0")
set(REQUIRED_GIO_VERSION "gio-2.0>=2.44")
set(REQUIRED_SOUP_VERSION "libsoup-2.4")
set(REQUIRED_WEBKIT_VERSION "wpe-webkit-1.0>=2.28.0")
add_definitions("-DCOG_USE_SOUP2=1")
else()
set(WPEWEBKIT_PC_NAME "wpe-webkit-1.1")
set(REQUIRED_GIO_VERSION "gio-2.0>=2.67.4")
set(REQUIRED_SOUP_VERSION "libsoup-3.0>=2.99.7")
set(REQUIRED_WEBKIT_VERSION "wpe-webkit-1.1>=2.33.1")
Expand Down
23 changes: 23 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
=========================
0.11.1 - November 3, 2021
=========================

- core: Changed platform plug-ins to be able to automatically detect which
one should be used. Passing the "--platform=" command line option to the
launcher is now optional.
- core: Added support for building against libsoup3.
- core: Added CogHostRoutesHandler, which can route URI scheme requests
with different host parts to other handlers.
- core, cog: Added support for running in WebDriver automation mode.
- cog: New "--enable-sandbox" command line option, which allows isolating
rendering processes from the rest of the system.
- cog: New "--content-filter=" command line option, which allows loading
a content blocker (WebKitUserContentFilter) JSON rule set.
- drm: Implemented handling of pointer axis/wheel/finger/continuous events
and absolute motion events.
- wl: Renamed "fdo" platform module to "wl" (Wayland) as it better reflects
its usage; the old name still works e.g. when using "cog --platform=fdo"
but it is considered deprecated and will cause a warning.
- wl, gtk4: Added support for fullscreening web views.
- gtk4: Honor the CogShell.device-scale-factor property.

======================
0.9.1 - March 16, 2021
======================
Expand Down
8 changes: 1 addition & 7 deletions cog.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,13 +342,7 @@ platform_setup (CogShell *shell)
static void
on_shutdown (CogLauncher *launcher G_GNUC_UNUSED, void *user_data G_GNUC_UNUSED)
{
g_debug ("%s: Platform = %p", __func__, s_options.platform);

if (s_options.platform) {
cog_platform_teardown (s_options.platform);
g_clear_object(&s_options.platform);
g_debug ("%s: Platform teardown completed.", __func__);
}
g_clear_object(&s_options.platform);
}

static void*
Expand Down
10 changes: 0 additions & 10 deletions core/cog-platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,6 @@ cog_platform_new(const char *name, GError **error)
return g_steal_pointer(&self);
}

void
cog_platform_teardown(CogPlatform *platform)
{
g_return_if_fail(COG_IS_PLATFORM(platform));

CogPlatformClass *klass = COG_PLATFORM_GET_CLASS(platform);
if (klass->teardown)
klass->teardown(platform);
}

gboolean
cog_platform_setup (CogPlatform *platform,
CogShell *shell,
Expand Down
3 changes: 0 additions & 3 deletions core/cog-platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ struct _CogPlatformClass {
/*< public >*/
gboolean (*is_supported)(void);
gboolean (*setup)(CogPlatform *, CogShell *shell, const char *params, GError **);
void (*teardown)(CogPlatform *);
WebKitWebViewBackend *(*get_view_backend)(CogPlatform *, WebKitWebView *related_view, GError **);
void (*init_web_view)(CogPlatform *, WebKitWebView *);
WebKitInputMethodContext *(*create_im_context)(CogPlatform *);
Expand All @@ -59,8 +58,6 @@ CogPlatform *cog_platform_new(const char *name, GError **);

gboolean cog_platform_setup(CogPlatform *platform, CogShell *shell, const char *params, GError **error);

void cog_platform_teardown (CogPlatform *platform);

WebKitWebViewBackend *cog_platform_get_view_backend (CogPlatform *platform,
WebKitWebView *related_view,
GError **error);
Expand Down
4 changes: 2 additions & 2 deletions data/check-style
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ declare -r BASE HEAD

declare -ra clang_format_diff_candidates=(
# Search in $PATH (Ubuntu, Debian, maybe others)
clang-format-diff-11
clang-format-diff-11.py
clang-format-diff-13
clang-format-diff-13.py
clang-format-diff
clang-format-diff.py
# Arch Linux, Fedora.
Expand Down
2 changes: 1 addition & 1 deletion docs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ add_custom_command(
--identifier-prefix=Cog
--symbol-prefix=cog
--pkg-export=cogcore
--pkg=wpe-webkit-1.0
--pkg=${WPEWEBKIT_PC_NAME}
--pkg=gobject-2.0
--pkg=gio-2.0
--pkg=glib-2.0
Expand Down
2 changes: 1 addition & 1 deletion docs/cog.toml.in
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ base_url = "https://github.com/Igalia/cog/blob/master/"
content_files = [
"overview.md",
"contributing.md",
"platform-fdo.md",
"platform-wl.md",
"platform-drm.md",
"platform-x11.md",
"platform-headless.md",
Expand Down
14 changes: 0 additions & 14 deletions docs/platform-fdo.md

This file was deleted.

14 changes: 14 additions & 0 deletions docs/platform-wl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Title: Platform: WL

# Wayland Platform

## Requirements

The `wl` (Wayland) platform plug-in additionally requires the following
libraries and packages:

- **WPEBackend-fdo**:
- **Wayland**:
- **libxkbcommon**:
- **wayland-protocols**:
- **wayland-scanner**:
2 changes: 1 addition & 1 deletion docs/webdriver.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def capabilities():
return {
"wpe:browserOptions": {
"binary": "/usr/bin/cog",
"args": ["--automation", "--platform=fdo"],
"args": ["--automation", "--platform=wl"],
}
}

Expand Down
26 changes: 16 additions & 10 deletions platform/drm/cog-platform-drm.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,13 +353,16 @@ check_drm(void)
if (num_devices < 0)
return FALSE;

for (int i = 0; i < num_devices; ++i) {
drmDevice *device = devices[i];
if (!!(device->available_nodes & (1 << DRM_NODE_PRIMARY)))
return TRUE;
gboolean supported = FALSE;
for (int i = 0; !supported && i < num_devices; ++i) {
if (devices[i]->available_nodes & (1 << DRM_NODE_PRIMARY)) {
supported = TRUE;
break;
}
}

return FALSE;
drmFreeDevices(devices, num_devices);
return supported;
}

static gboolean
Expand Down Expand Up @@ -405,6 +408,8 @@ init_drm(void)
drm_data.fd = -1;
}

drmFreeDevices(devices, num_devices);

if (!drm_data.base_resources)
return FALSE;

Expand Down Expand Up @@ -1822,18 +1827,17 @@ cog_drm_platform_setup(CogPlatform *platform, CogShell *shell, const char *param
}

static void
cog_drm_platform_teardown(CogPlatform *platform)
cog_drm_platform_finalize(GObject *object)
{
g_assert (platform);

clear_buffers ();

clear_glib ();
clear_input ();
clear_egl ();
clear_gbm ();
clear_cursor ();
clear_drm ();

G_OBJECT_CLASS(cog_drm_platform_parent_class)->finalize(object);
}

static WebKitWebViewBackend *
Expand Down Expand Up @@ -1875,10 +1879,12 @@ cog_drm_platform_init_web_view(CogPlatform *platform, WebKitWebView *view)
static void
cog_drm_platform_class_init(CogDrmPlatformClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS(klass);
object_class->finalize = cog_drm_platform_finalize;

CogPlatformClass *platform_class = COG_PLATFORM_CLASS(klass);
platform_class->is_supported = cog_drm_platform_is_supported;
platform_class->setup = cog_drm_platform_setup;
platform_class->teardown = cog_drm_platform_teardown;
platform_class->get_view_backend = cog_drm_platform_get_view_backend;
platform_class->init_web_view = cog_drm_platform_init_web_view;
}
Expand Down
7 changes: 0 additions & 7 deletions platform/gtk4/cog-platform-gtk4.c
Original file line number Diff line number Diff line change
Expand Up @@ -772,12 +772,6 @@ cog_gtk4_platform_setup(CogPlatform* platform, CogShell* shell, const char* para
return TRUE;
}

static void
cog_gtk4_platform_teardown(CogPlatform* platform)
{
g_assert_nonnull(platform);
}

static WebKitWebViewBackend*
cog_gtk4_platform_get_view_backend(CogPlatform* platform, WebKitWebView* related_view, GError** error)
{
Expand Down Expand Up @@ -865,7 +859,6 @@ cog_gtk4_platform_class_init(CogGtk4PlatformClass* klass)
CogPlatformClass* platform_class = COG_PLATFORM_CLASS(klass);
platform_class->is_supported = cog_gtk4_platform_is_supported;
platform_class->setup = cog_gtk4_platform_setup;
platform_class->teardown = cog_gtk4_platform_teardown;
platform_class->get_view_backend = cog_gtk4_platform_get_view_backend;
platform_class->init_web_view = cog_gtk4_platform_init_web_view;
}
Expand Down
8 changes: 6 additions & 2 deletions platform/headless/cog-platform-headless.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,12 @@ cog_headless_platform_setup(CogPlatform* platform, CogShell* shell G_GNUC_UNUSED
}

static void
cog_headless_platform_teardown(CogPlatform* platform)
cog_headless_platform_finalize(GObject* object)
{
g_source_remove(win.tick_source);
wpe_view_backend_exportable_fdo_destroy(win.exportable);

G_OBJECT_CLASS(cog_headless_platform_parent_class)->finalize(object);
}

static WebKitWebViewBackend*
Expand All @@ -97,9 +99,11 @@ cog_headless_platform_get_view_backend(CogPlatform* platform, WebKitWebView* rel
static void
cog_headless_platform_class_init(CogHeadlessPlatformClass* klass)
{
GObjectClass* object_class = G_OBJECT_CLASS(klass);
object_class->finalize = cog_headless_platform_finalize;

CogPlatformClass* platform_class = COG_PLATFORM_CLASS(klass);
platform_class->setup = cog_headless_platform_setup;
platform_class->teardown = cog_headless_platform_teardown;
platform_class->get_view_backend = cog_headless_platform_get_view_backend;
}

Expand Down
Loading