2015-01-29 21:53:53 +01:00
|
|
|
// Copyright (c) 2015 The Chromium Embedded Framework Authors. All rights
|
|
|
|
// reserved. Use of this source code is governed by a BSD-style license that
|
|
|
|
// can be found in the LICENSE file.
|
|
|
|
|
2015-01-31 01:55:56 +01:00
|
|
|
#ifndef CEF_TESTS_CEFCLIENT_BROWSER_BROWSER_WINDOW_OSR_GTK_H_
|
|
|
|
#define CEF_TESTS_CEFCLIENT_BROWSER_BROWSER_WINDOW_OSR_GTK_H_
|
|
|
|
#pragma once
|
2015-01-29 21:53:53 +01:00
|
|
|
|
2016-11-18 00:52:42 +01:00
|
|
|
#include "tests/cefclient/browser/browser_window.h"
|
|
|
|
#include "tests/cefclient/browser/client_handler_osr.h"
|
|
|
|
#include "tests/cefclient/browser/osr_renderer.h"
|
2015-01-29 21:53:53 +01:00
|
|
|
|
|
|
|
namespace client {
|
|
|
|
|
|
|
|
// Represents a native child window hosting a single off-screen browser
|
|
|
|
// instance. The methods of this class must be called on the main thread unless
|
|
|
|
// otherwise indicated.
|
|
|
|
class BrowserWindowOsrGtk : public BrowserWindow,
|
|
|
|
public ClientHandlerOsr::OsrDelegate {
|
|
|
|
public:
|
|
|
|
// Constructor may be called on any thread.
|
|
|
|
// |delegate| must outlive this object.
|
|
|
|
BrowserWindowOsrGtk(BrowserWindow::Delegate* delegate,
|
|
|
|
const std::string& startup_url,
|
2015-04-09 16:59:34 +02:00
|
|
|
const OsrRenderer::Settings& settings);
|
2015-01-29 21:53:53 +01:00
|
|
|
|
|
|
|
// BrowserWindow methods.
|
|
|
|
void CreateBrowser(ClientWindowHandle parent_handle,
|
|
|
|
const CefRect& rect,
|
2015-02-14 00:17:08 +01:00
|
|
|
const CefBrowserSettings& settings,
|
|
|
|
CefRefPtr<CefRequestContext> request_context) OVERRIDE;
|
2015-01-29 21:53:53 +01:00
|
|
|
void GetPopupConfig(CefWindowHandle temp_handle,
|
|
|
|
CefWindowInfo& windowInfo,
|
|
|
|
CefRefPtr<CefClient>& client,
|
|
|
|
CefBrowserSettings& settings) OVERRIDE;
|
|
|
|
void ShowPopup(ClientWindowHandle parent_handle,
|
2017-05-17 11:29:28 +02:00
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
size_t width,
|
|
|
|
size_t height) OVERRIDE;
|
2015-01-29 21:53:53 +01:00
|
|
|
void Show() OVERRIDE;
|
|
|
|
void Hide() OVERRIDE;
|
|
|
|
void SetBounds(int x, int y, size_t width, size_t height) OVERRIDE;
|
2015-01-30 19:07:13 +01:00
|
|
|
void SetFocus(bool focus) OVERRIDE;
|
2015-08-10 22:49:45 +02:00
|
|
|
void SetDeviceScaleFactor(float device_scale_factor) OVERRIDE;
|
|
|
|
float GetDeviceScaleFactor() const OVERRIDE;
|
2015-01-29 21:53:53 +01:00
|
|
|
ClientWindowHandle GetWindowHandle() const OVERRIDE;
|
|
|
|
|
|
|
|
// ClientHandlerOsr::OsrDelegate methods.
|
|
|
|
void OnAfterCreated(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
|
|
|
void OnBeforeClose(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
2017-05-17 11:29:28 +02:00
|
|
|
bool GetRootScreenRect(CefRefPtr<CefBrowser> browser, CefRect& rect) OVERRIDE;
|
|
|
|
bool GetViewRect(CefRefPtr<CefBrowser> browser, CefRect& rect) OVERRIDE;
|
2015-01-29 21:53:53 +01:00
|
|
|
bool GetScreenPoint(CefRefPtr<CefBrowser> browser,
|
|
|
|
int viewX,
|
|
|
|
int viewY,
|
|
|
|
int& screenX,
|
|
|
|
int& screenY) OVERRIDE;
|
|
|
|
bool GetScreenInfo(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefScreenInfo& screen_info) OVERRIDE;
|
|
|
|
void OnPopupShow(CefRefPtr<CefBrowser> browser, bool show) OVERRIDE;
|
2017-05-17 11:29:28 +02:00
|
|
|
void OnPopupSize(CefRefPtr<CefBrowser> browser, const CefRect& rect) OVERRIDE;
|
2015-01-29 21:53:53 +01:00
|
|
|
void OnPaint(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRenderHandler::PaintElementType type,
|
|
|
|
const CefRenderHandler::RectList& dirtyRects,
|
|
|
|
const void* buffer,
|
|
|
|
int width,
|
|
|
|
int height) OVERRIDE;
|
|
|
|
void OnCursorChange(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefCursorHandle cursor,
|
|
|
|
CefRenderHandler::CursorType type,
|
|
|
|
const CefCursorInfo& custom_cursor_info) OVERRIDE;
|
|
|
|
bool StartDragging(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefDragData> drag_data,
|
|
|
|
CefRenderHandler::DragOperationsMask allowed_ops,
|
2017-05-17 11:29:28 +02:00
|
|
|
int x,
|
|
|
|
int y) OVERRIDE;
|
2015-01-29 21:53:53 +01:00
|
|
|
void UpdateDragCursor(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRenderHandler::DragOperation operation) OVERRIDE;
|
2016-10-28 18:11:24 +02:00
|
|
|
void OnImeCompositionRangeChanged(
|
|
|
|
CefRefPtr<CefBrowser> browser,
|
|
|
|
const CefRange& selection_range,
|
|
|
|
const CefRenderHandler::RectList& character_bounds) OVERRIDE;
|
2017-05-12 20:28:25 +02:00
|
|
|
void UpdateAccessibilityTree(CefRefPtr<CefValue> value) OVERRIDE;
|
2015-01-29 21:53:53 +01:00
|
|
|
|
|
|
|
private:
|
2017-05-11 21:06:32 +02:00
|
|
|
~BrowserWindowOsrGtk();
|
|
|
|
|
2015-01-29 21:53:53 +01:00
|
|
|
// Create the GTK GlArea.
|
|
|
|
void Create(ClientWindowHandle parent_handle);
|
|
|
|
|
|
|
|
// Signal handlers for the GTK GlArea.
|
|
|
|
static gint SizeAllocation(GtkWidget* widget,
|
|
|
|
GtkAllocation* allocation,
|
|
|
|
BrowserWindowOsrGtk* self);
|
|
|
|
static gint ClickEvent(GtkWidget* widget,
|
|
|
|
GdkEventButton* event,
|
|
|
|
BrowserWindowOsrGtk* self);
|
|
|
|
static gint KeyEvent(GtkWidget* widget,
|
|
|
|
GdkEventKey* event,
|
|
|
|
BrowserWindowOsrGtk* self);
|
|
|
|
static gint MoveEvent(GtkWidget* widget,
|
|
|
|
GdkEventMotion* event,
|
|
|
|
BrowserWindowOsrGtk* self);
|
|
|
|
static gint ScrollEvent(GtkWidget* widget,
|
|
|
|
GdkEventScroll* event,
|
|
|
|
BrowserWindowOsrGtk* self);
|
|
|
|
static gint FocusEvent(GtkWidget* widget,
|
|
|
|
GdkEventFocus* event,
|
|
|
|
BrowserWindowOsrGtk* self);
|
|
|
|
|
|
|
|
bool IsOverPopupWidget(int x, int y) const;
|
|
|
|
int GetPopupXOffset() const;
|
|
|
|
int GetPopupYOffset() const;
|
|
|
|
void ApplyPopupOffset(int& x, int& y) const;
|
|
|
|
|
|
|
|
void EnableGL();
|
|
|
|
void DisableGL();
|
|
|
|
|
2017-05-11 21:06:32 +02:00
|
|
|
// Drag & drop
|
|
|
|
void RegisterDragDrop();
|
|
|
|
void UnregisterDragDrop();
|
|
|
|
void DragReset();
|
|
|
|
static void DragBegin(GtkWidget* widget,
|
|
|
|
GdkDragContext* drag_context,
|
|
|
|
BrowserWindowOsrGtk* self);
|
|
|
|
static void DragDataGet(GtkWidget* widget,
|
|
|
|
GdkDragContext* drag_context,
|
|
|
|
GtkSelectionData* data,
|
|
|
|
guint info,
|
|
|
|
guint time,
|
|
|
|
BrowserWindowOsrGtk* self);
|
|
|
|
static void DragEnd(GtkWidget* widget,
|
|
|
|
GdkDragContext* drag_context,
|
|
|
|
BrowserWindowOsrGtk* self);
|
|
|
|
static gboolean DragMotion(GtkWidget* widget,
|
|
|
|
GdkDragContext* drag_context,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
guint time,
|
|
|
|
BrowserWindowOsrGtk* self);
|
|
|
|
static void DragLeave(GtkWidget* widget,
|
|
|
|
GdkDragContext* drag_context,
|
|
|
|
guint time,
|
|
|
|
BrowserWindowOsrGtk* self);
|
|
|
|
static gboolean DragFailed(GtkWidget* widget,
|
|
|
|
GdkDragContext* drag_context,
|
|
|
|
GtkDragResult result,
|
|
|
|
BrowserWindowOsrGtk* self);
|
|
|
|
static gboolean DragDrop(GtkWidget* widget,
|
|
|
|
GdkDragContext* drag_context,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
guint time,
|
|
|
|
BrowserWindowOsrGtk* self);
|
|
|
|
static void DragDataReceived(GtkWidget* widget,
|
|
|
|
GdkDragContext* drag_context,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
GtkSelectionData* data,
|
|
|
|
guint info,
|
|
|
|
guint time,
|
|
|
|
BrowserWindowOsrGtk* self);
|
|
|
|
|
2015-01-29 21:53:53 +01:00
|
|
|
// The below members will only be accessed on the main thread which should be
|
|
|
|
// the same as the CEF UI thread.
|
|
|
|
OsrRenderer renderer_;
|
|
|
|
ClientWindowHandle glarea_;
|
|
|
|
bool hidden_;
|
|
|
|
bool gl_enabled_;
|
|
|
|
bool painting_popup_;
|
|
|
|
|
2015-08-10 22:49:45 +02:00
|
|
|
float device_scale_factor_;
|
|
|
|
|
2017-05-11 21:06:32 +02:00
|
|
|
// Drag & drop
|
|
|
|
GdkEvent* drag_trigger_event_; // mouse event, a possible trigger for drag
|
|
|
|
CefRefPtr<CefDragData> drag_data_;
|
|
|
|
CefRenderHandler::DragOperation drag_operation_;
|
|
|
|
GdkDragContext* drag_context_;
|
|
|
|
GtkTargetList* drag_targets_;
|
|
|
|
bool drag_leave_;
|
|
|
|
bool drag_drop_;
|
|
|
|
|
2015-01-29 21:53:53 +01:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(BrowserWindowOsrGtk);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace client
|
|
|
|
|
2015-01-31 01:55:56 +01:00
|
|
|
#endif // CEF_TESTS_CEFCLIENT_BROWSER_BROWSER_WINDOW_OSR_GTK_H_
|