mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Merge revision 569 and 624 changes:
- Add off-screen rendering support for Mac OS-X (issue #540). - Add patch for ninja build support on Mac OS-X. - Avoid calling OnSetFocus multiple times (issue #563). git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@626 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "cefclient/osrplugin.h"
|
||||
#include "cefclient/osrenderer.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
|
||||
@@ -28,27 +29,22 @@ NPNetscapeFuncs* g_osrbrowser = NULL;
|
||||
|
||||
namespace {
|
||||
|
||||
GLuint g_textureID = -1;
|
||||
float g_spinX = 0.0f;
|
||||
float g_spinY = 0.0f;
|
||||
int g_width = -1, g_height = -1;
|
||||
CefRefPtr<CefBrowser> g_offscreenBrowser;
|
||||
|
||||
// If set to true alpha transparency will be used.
|
||||
bool g_offscreenTransparent = false;
|
||||
|
||||
#define GL_IMAGE_FORMAT (g_offscreenTransparent?GL_RGBA:GL_RGB)
|
||||
#define GL_BYTE_COUNT (g_offscreenTransparent?4:3)
|
||||
|
||||
// Class holding pointers for the client plugin window.
|
||||
class ClientPlugin {
|
||||
public:
|
||||
ClientPlugin() {
|
||||
hWnd = NULL;
|
||||
hDC = NULL;
|
||||
hRC = NULL;
|
||||
ClientPlugin(bool transparent)
|
||||
: renderer(transparent),
|
||||
hWnd(NULL),
|
||||
hDC(NULL),
|
||||
hRC(NULL) {
|
||||
}
|
||||
|
||||
ClientOSRenderer renderer;
|
||||
HWND hWnd;
|
||||
HDC hDC;
|
||||
HGLRC hRC;
|
||||
@@ -63,17 +59,9 @@ class ClientOSRHandler : public CefClient,
|
||||
public CefRenderHandler {
|
||||
public:
|
||||
explicit ClientOSRHandler(ClientPlugin* plugin)
|
||||
: plugin_(plugin),
|
||||
view_buffer_(NULL),
|
||||
view_buffer_size_(0),
|
||||
popup_buffer_(NULL),
|
||||
popup_buffer_size_(0) {
|
||||
: plugin_(plugin) {
|
||||
}
|
||||
~ClientOSRHandler() {
|
||||
if (view_buffer_)
|
||||
delete [] view_buffer_;
|
||||
if (popup_buffer_)
|
||||
delete [] popup_buffer_;
|
||||
}
|
||||
|
||||
// CefClient methods
|
||||
@@ -111,10 +99,12 @@ class ClientOSRHandler : public CefClient,
|
||||
virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) OVERRIDE {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
// Set the view size to match the plugin window size.
|
||||
browser->SetSize(PET_VIEW, g_width, g_height);
|
||||
|
||||
g_offscreenBrowser = browser;
|
||||
|
||||
// Set the off-screen browser size to match the plugin window size.
|
||||
RECT clientRect;
|
||||
::GetClientRect(plugin_->hWnd, &clientRect);
|
||||
g_offscreenBrowser->SetSize(PET_VIEW, clientRect.right, clientRect.bottom);
|
||||
}
|
||||
|
||||
virtual void OnBeforeClose(CefRefPtr<CefBrowser> browser) OVERRIDE {
|
||||
@@ -214,9 +204,12 @@ class ClientOSRHandler : public CefClient,
|
||||
|
||||
// The simulated screen and view rectangle are the same. This is necessary
|
||||
// for popup menus to be located and sized inside the view.
|
||||
RECT clientRect;
|
||||
::GetClientRect(plugin_->hWnd, &clientRect);
|
||||
|
||||
rect.x = rect.y = 0;
|
||||
rect.width = g_width;
|
||||
rect.height = g_height;
|
||||
rect.width = clientRect.right;
|
||||
rect.height = clientRect.bottom;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -243,29 +236,13 @@ class ClientOSRHandler : public CefClient,
|
||||
virtual void OnPopupShow(CefRefPtr<CefBrowser> browser,
|
||||
bool show) OVERRIDE {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
if (!show) {
|
||||
// Clear the popup buffer.
|
||||
popup_rect_.Set(0, 0, 0, 0);
|
||||
if (popup_buffer_) {
|
||||
delete [] popup_buffer_;
|
||||
popup_buffer_ = NULL;
|
||||
popup_buffer_size_ = 0;
|
||||
}
|
||||
}
|
||||
plugin_->renderer.OnPopupShow(browser, show);
|
||||
}
|
||||
|
||||
virtual void OnPopupSize(CefRefPtr<CefBrowser> browser,
|
||||
const CefRect& rect) OVERRIDE {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
if (rect.width > 0) {
|
||||
// Update the popup rectange. It will always be inside the view due to
|
||||
// HandleGetRect().
|
||||
ASSERT(rect.x + rect.width < g_width &&
|
||||
rect.y + rect.height < g_height);
|
||||
popup_rect_ = rect;
|
||||
}
|
||||
plugin_->renderer.OnPopupSize(browser, rect);
|
||||
}
|
||||
|
||||
virtual void OnPaint(CefRefPtr<CefBrowser> browser,
|
||||
@@ -275,65 +252,7 @@ class ClientOSRHandler : public CefClient,
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
wglMakeCurrent(plugin_->hDC, plugin_->hRC);
|
||||
|
||||
if (g_offscreenTransparent) {
|
||||
// Enable alpha blending.
|
||||
glEnable(GL_BLEND);
|
||||
}
|
||||
|
||||
// Enable 2D textures.
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, g_textureID);
|
||||
|
||||
if (type == PET_VIEW) {
|
||||
SetBufferSize(g_width, g_height, true);
|
||||
// Paint the view.
|
||||
if (g_offscreenTransparent) {
|
||||
RectList::const_iterator i = dirtyRects.begin();
|
||||
for (; i != dirtyRects.end(); ++i) {
|
||||
ConvertToRGBARect(*i, (unsigned char*)buffer, view_buffer_, g_width,
|
||||
g_height);
|
||||
}
|
||||
} else {
|
||||
RectList::const_iterator i = dirtyRects.begin();
|
||||
for (i; i != dirtyRects.end(); ++i) {
|
||||
ConvertToRGBRect(*i, (unsigned char*)buffer, view_buffer_, g_width,
|
||||
g_height);
|
||||
}
|
||||
}
|
||||
|
||||
// Update the whole texture. This is done for simplicity instead of
|
||||
// updating just the dirty region.
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, g_width, g_height,
|
||||
GL_IMAGE_FORMAT, GL_UNSIGNED_BYTE, view_buffer_);
|
||||
}
|
||||
|
||||
if (popup_rect_.width > 0) {
|
||||
if (type == PET_POPUP) {
|
||||
// Paint the popup.
|
||||
if (g_offscreenTransparent)
|
||||
SetRGBA(buffer, popup_rect_.width, popup_rect_.height, false);
|
||||
else
|
||||
SetRGB(buffer, popup_rect_.width, popup_rect_.height, false);
|
||||
}
|
||||
|
||||
if (popup_buffer_) {
|
||||
// Update the popup region.
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, popup_rect_.x,
|
||||
g_height-popup_rect_.y-popup_rect_.height, popup_rect_.width,
|
||||
popup_rect_.height, GL_IMAGE_FORMAT, GL_UNSIGNED_BYTE,
|
||||
popup_buffer_);
|
||||
}
|
||||
}
|
||||
|
||||
// Disable 2D textures.
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
if (g_offscreenTransparent) {
|
||||
// Disable alpha blending.
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
plugin_->renderer.OnPaint(browser, type, dirtyRects, buffer);
|
||||
}
|
||||
|
||||
virtual void OnCursorChange(CefRefPtr<CefBrowser> browser,
|
||||
@@ -357,112 +276,7 @@ class ClientOSRHandler : public CefClient,
|
||||
AppGetBrowser()->GetMainFrame()->ExecuteJavaScript(ss.str(), "", 0);
|
||||
}
|
||||
|
||||
// Size the RGB buffer.
|
||||
void SetBufferSize(int width, int height, bool view) {
|
||||
int dst_size = width * height * GL_BYTE_COUNT;
|
||||
|
||||
// Allocate a new buffer if necesary.
|
||||
if (view) {
|
||||
if (dst_size > view_buffer_size_) {
|
||||
if (view_buffer_)
|
||||
delete [] view_buffer_;
|
||||
view_buffer_ = new unsigned char[dst_size];
|
||||
view_buffer_size_ = dst_size;
|
||||
}
|
||||
} else {
|
||||
if (dst_size > popup_buffer_size_) {
|
||||
if (popup_buffer_)
|
||||
delete [] popup_buffer_;
|
||||
popup_buffer_ = new unsigned char[dst_size];
|
||||
popup_buffer_size_ = dst_size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set the contents of the RGBA buffer.
|
||||
void SetRGBA(const void* src, int width, int height, bool view) {
|
||||
SetBufferSize(width, height, view);
|
||||
ConvertToRGBA((unsigned char*)src, view?view_buffer_:popup_buffer_, width,
|
||||
height);
|
||||
}
|
||||
|
||||
// Convert from BGRA to RGBA format and from upper-left to lower-left origin.
|
||||
static void ConvertToRGBA(const unsigned char* src, unsigned char* dst,
|
||||
int width, int height) {
|
||||
int sp = 0, dp = (height-1) * width * 4;
|
||||
for (int i = 0; i < height; i++) {
|
||||
for (int j = 0; j < width; j++, dp += 4, sp += 4) {
|
||||
dst[dp] = src[sp+2]; // R
|
||||
dst[dp+1] = src[sp+1]; // G
|
||||
dst[dp+2] = src[sp]; // B
|
||||
dst[dp+3] = src[sp+3]; // A
|
||||
}
|
||||
dp -= width * 8;
|
||||
}
|
||||
}
|
||||
|
||||
static void ConvertToRGBARect(const CefRect& clipRect,
|
||||
const unsigned char* src, unsigned char* dst,
|
||||
int width, int height) {
|
||||
int sp = 0, dp = (height-1) * width * 4;
|
||||
for (int i = 0; i < height; i++) {
|
||||
for (int j = 0; j < width; j++, dp += 4, sp += 4) {
|
||||
if ((clipRect.x <= j) && (clipRect.x + clipRect.width > j) &&
|
||||
(clipRect.y <= i) && (clipRect.y + clipRect.height > i)) {
|
||||
dst[dp] = src[sp+2]; // R
|
||||
dst[dp+1] = src[sp+1]; // G
|
||||
dst[dp+2] = src[sp]; // B
|
||||
dst[dp+3] = src[sp+3]; // A
|
||||
}
|
||||
}
|
||||
dp -= width * 8;
|
||||
}
|
||||
}
|
||||
|
||||
// Set the contents of the RGB buffer.
|
||||
void SetRGB(const void* src, int width, int height, bool view) {
|
||||
SetBufferSize(width, height, view);
|
||||
ConvertToRGB((unsigned char*)src, view?view_buffer_:popup_buffer_, width,
|
||||
height);
|
||||
}
|
||||
|
||||
// Convert from BGRA to RGB format and from upper-left to lower-left origin.
|
||||
static void ConvertToRGB(const unsigned char* src, unsigned char* dst,
|
||||
int width, int height) {
|
||||
int sp = 0, dp = (height-1) * width * 3;
|
||||
for (int i = 0; i < height; i++) {
|
||||
for (int j = 0; j < width; j++, dp += 3, sp += 4) {
|
||||
dst[dp] = src[sp+2]; // R
|
||||
dst[dp+1] = src[sp+1]; // G
|
||||
dst[dp+2] = src[sp]; // B
|
||||
}
|
||||
dp -= width * 6;
|
||||
}
|
||||
}
|
||||
|
||||
static void ConvertToRGBRect(const CefRect& clipRect,
|
||||
const unsigned char* src, unsigned char* dst,
|
||||
int width, int height) {
|
||||
int sp = 0, dp = (height-1) * width * 3;
|
||||
for (int i = 0; i < height; i++) {
|
||||
for (int j = 0; j < width; j++, dp += 3, sp += 4) {
|
||||
if ((clipRect.x <= j) && (clipRect.x + clipRect.width > j) &&
|
||||
(clipRect.y <= i) && (clipRect.y + clipRect.height > i)) {
|
||||
dst[dp] = src[sp+2]; // R
|
||||
dst[dp+1] = src[sp+1]; // G
|
||||
dst[dp+2] = src[sp]; // B
|
||||
}
|
||||
}
|
||||
dp -= width * 6;
|
||||
}
|
||||
}
|
||||
|
||||
ClientPlugin* plugin_;
|
||||
unsigned char* view_buffer_;
|
||||
int view_buffer_size_;
|
||||
unsigned char* popup_buffer_;
|
||||
int popup_buffer_size_;
|
||||
CefRect popup_rect_;
|
||||
|
||||
// Include the default reference counting implementation.
|
||||
IMPLEMENT_REFCOUNTING(ClientOSRPlugin);
|
||||
@@ -473,12 +287,12 @@ LRESULT CALLBACK PluginWndProc(HWND hWnd, UINT message, WPARAM wParam,
|
||||
LPARAM lParam);
|
||||
|
||||
// Enable GL.
|
||||
void EnableGL(HWND hWnd, HDC * hDC, HGLRC * hRC) {
|
||||
void EnableGL(ClientPlugin* plugin) {
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
int format;
|
||||
|
||||
// Get the device context.
|
||||
*hDC = GetDC(hWnd);
|
||||
plugin->hDC = GetDC(plugin->hWnd);
|
||||
|
||||
// Set the pixel format for the DC.
|
||||
ZeroMemory(&pfd, sizeof(pfd));
|
||||
@@ -489,83 +303,30 @@ void EnableGL(HWND hWnd, HDC * hDC, HGLRC * hRC) {
|
||||
pfd.cColorBits = 24;
|
||||
pfd.cDepthBits = 16;
|
||||
pfd.iLayerType = PFD_MAIN_PLANE;
|
||||
format = ChoosePixelFormat(*hDC, &pfd);
|
||||
SetPixelFormat(*hDC, format, &pfd);
|
||||
format = ChoosePixelFormat(plugin->hDC, &pfd);
|
||||
SetPixelFormat(plugin->hDC, format, &pfd);
|
||||
|
||||
// Create and enable the render context.
|
||||
*hRC = wglCreateContext(*hDC);
|
||||
wglMakeCurrent(*hDC, *hRC);
|
||||
plugin->hRC = wglCreateContext(plugin->hDC);
|
||||
wglMakeCurrent(plugin->hDC, plugin->hRC);
|
||||
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
// Necessary for non-power-of-2 textures to render correctly.
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
|
||||
if (g_offscreenTransparent) {
|
||||
// Alpha blending style.
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
plugin->renderer.Initialize();
|
||||
}
|
||||
|
||||
// Disable GL.
|
||||
void DisableGL(HWND hWnd, HDC hDC, HGLRC hRC) {
|
||||
// Delete the texture.
|
||||
if (g_textureID != -1)
|
||||
glDeleteTextures(1, &g_textureID);
|
||||
void DisableGL(ClientPlugin* plugin) {
|
||||
plugin->renderer.Cleanup();
|
||||
|
||||
wglMakeCurrent(NULL, NULL);
|
||||
wglDeleteContext(hRC);
|
||||
ReleaseDC(hWnd, hDC);
|
||||
wglDeleteContext(plugin->hRC);
|
||||
ReleaseDC(plugin->hWnd, plugin->hDC);
|
||||
}
|
||||
|
||||
// Size the GL view.
|
||||
void SizeGL(ClientPlugin* plugin, int width, int height) {
|
||||
g_width = width;
|
||||
g_height = height;
|
||||
|
||||
wglMakeCurrent(plugin->hDC, plugin->hRC);
|
||||
|
||||
// Match GL units to screen coordinates.
|
||||
glViewport(0, 0, width, height);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(0, 0, width, height, 0.1, 100.0);
|
||||
|
||||
if (g_offscreenTransparent) {
|
||||
// Enable alpha blending.
|
||||
glEnable(GL_BLEND);
|
||||
}
|
||||
|
||||
// Enable 2D textures.
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
// Delete the existing exture.
|
||||
if (g_textureID != -1)
|
||||
glDeleteTextures(1, &g_textureID);
|
||||
|
||||
// Create a new texture.
|
||||
glGenTextures(1, &g_textureID);
|
||||
glBindTexture(GL_TEXTURE_2D, g_textureID);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
||||
// Start with all white contents.
|
||||
int size = width * height * GL_BYTE_COUNT;
|
||||
unsigned char* buffer = new unsigned char[size];
|
||||
memset(buffer, 255, size);
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0,
|
||||
GL_IMAGE_FORMAT, GL_UNSIGNED_BYTE, buffer);
|
||||
|
||||
// Disable 2D textures.
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
if (g_offscreenTransparent) {
|
||||
// Disable alpha blending.
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
delete [] buffer;
|
||||
plugin->renderer.SetSize(width, height);
|
||||
|
||||
if (g_offscreenBrowser.get())
|
||||
g_offscreenBrowser->SetSize(PET_VIEW, width, height);
|
||||
@@ -575,58 +336,7 @@ void SizeGL(ClientPlugin* plugin, int width, int height) {
|
||||
void RenderGL(ClientPlugin* plugin) {
|
||||
wglMakeCurrent(plugin->hDC, plugin->hRC);
|
||||
|
||||
struct {
|
||||
float tu, tv;
|
||||
float x, y, z;
|
||||
} static vertices[] = {
|
||||
{0.0f, 0.0f, -1.0f, -1.0f, 0.0f},
|
||||
{1.0f, 0.0f, 1.0f, -1.0f, 0.0f},
|
||||
{1.0f, 1.0f, 1.0f, 1.0f, 0.0f},
|
||||
{0.0f, 1.0f, -1.0f, 1.0f, 0.0f}
|
||||
};
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
// glTranslatef(0.0f, 0.0f, -3.0f);
|
||||
|
||||
// Draw the background gradient.
|
||||
glPushAttrib(GL_ALL_ATTRIB_BITS);
|
||||
glBegin(GL_QUADS);
|
||||
glColor4f(1.0, 0.0, 0.0, 1.0); // red
|
||||
glVertex2f(-1.0, -1.0);
|
||||
glVertex2f(1.0, -1.0);
|
||||
glColor4f(0.0, 0.0, 1.0, 1.0); // blue
|
||||
glVertex2f(1.0, 1.0);
|
||||
glVertex2f(-1.0, 1.0);
|
||||
glEnd();
|
||||
glPopAttrib();
|
||||
|
||||
// Rotate the view based on the mouse spin.
|
||||
glRotatef(-g_spinX, 1.0f, 0.0f, 0.0f);
|
||||
glRotatef(-g_spinY, 0.0f, 1.0f, 0.0f);
|
||||
|
||||
if (g_offscreenTransparent) {
|
||||
// Enable alpha blending.
|
||||
glEnable(GL_BLEND);
|
||||
}
|
||||
|
||||
// Enable 2D textures.
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
// Draw the facets with the texture.
|
||||
glBindTexture(GL_TEXTURE_2D, g_textureID);
|
||||
glInterleavedArrays(GL_T2F_V3F, 0, vertices);
|
||||
glDrawArrays(GL_QUADS, 0, 4);
|
||||
|
||||
// Disable 2D textures.
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
if (g_offscreenTransparent) {
|
||||
// Disable alpha blending.
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
plugin->renderer.Render();
|
||||
|
||||
SwapBuffers(plugin->hDC);
|
||||
}
|
||||
@@ -637,7 +347,7 @@ NPError NPP_NewImpl(NPMIMEType plugin_type, NPP instance, uint16 mode,
|
||||
if (instance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
ClientPlugin* plugin = new ClientPlugin;
|
||||
ClientPlugin* plugin = new ClientPlugin(g_offscreenTransparent);
|
||||
instance->pdata = reinterpret_cast<void*>(plugin);
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
@@ -649,7 +359,7 @@ NPError NPP_DestroyImpl(NPP instance, NPSavedData** save) {
|
||||
if (plugin) {
|
||||
if (plugin->hWnd) {
|
||||
DestroyWindow(plugin->hWnd);
|
||||
DisableGL(plugin->hWnd, plugin->hDC, plugin->hRC);
|
||||
DisableGL(plugin);
|
||||
}
|
||||
delete plugin;
|
||||
}
|
||||
@@ -693,7 +403,7 @@ NPError NPP_SetWindowImpl(NPP instance, NPWindow* window_info) {
|
||||
reinterpret_cast<LONG_PTR>(plugin));
|
||||
|
||||
// Enable GL drawing for the window.
|
||||
EnableGL(plugin->hWnd, &(plugin->hDC), &(plugin->hRC));
|
||||
EnableGL(plugin);
|
||||
|
||||
// Create the off-screen rendering window.
|
||||
CefWindowInfo windowInfo;
|
||||
@@ -771,8 +481,7 @@ LRESULT CALLBACK PluginWndProc(HWND hWnd, UINT message, WPARAM wParam,
|
||||
if (mouseRotation) {
|
||||
// End rotation effect.
|
||||
mouseRotation = false;
|
||||
g_spinX = 0;
|
||||
g_spinY = 0;
|
||||
plugin->renderer.SetSpin(0, 0);
|
||||
} else {
|
||||
if (g_offscreenBrowser.get()) {
|
||||
g_offscreenBrowser->SendMouseClickEvent(LOWORD(lParam), HIWORD(lParam),
|
||||
@@ -786,8 +495,8 @@ LRESULT CALLBACK PluginWndProc(HWND hWnd, UINT message, WPARAM wParam,
|
||||
// Apply rotation effect.
|
||||
curMousePos.x = LOWORD(lParam);
|
||||
curMousePos.y = HIWORD(lParam);
|
||||
g_spinX -= (curMousePos.x - lastMousePos.x);
|
||||
g_spinY -= (curMousePos.y - lastMousePos.y);
|
||||
plugin->renderer.IncrementSpin((curMousePos.x - lastMousePos.x),
|
||||
(curMousePos.y - lastMousePos.y));
|
||||
lastMousePos.x = curMousePos.x;
|
||||
lastMousePos.y = curMousePos.y;
|
||||
} else {
|
||||
@@ -825,7 +534,7 @@ LRESULT CALLBACK PluginWndProc(HWND hWnd, UINT message, WPARAM wParam,
|
||||
case WM_MOUSEWHEEL:
|
||||
if (g_offscreenBrowser.get()) {
|
||||
g_offscreenBrowser->SendMouseWheelEvent(LOWORD(lParam), HIWORD(lParam),
|
||||
GET_WHEEL_DELTA_WPARAM(wParam));
|
||||
0, GET_WHEEL_DELTA_WPARAM(wParam));
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -860,7 +569,8 @@ LRESULT CALLBACK PluginWndProc(HWND hWnd, UINT message, WPARAM wParam,
|
||||
case WM_IME_CHAR:
|
||||
if (g_offscreenBrowser.get()) {
|
||||
CefBrowser::KeyType type = KT_CHAR;
|
||||
bool sysChar = false, imeChar = false;
|
||||
CefKeyInfo keyInfo;
|
||||
keyInfo.key = wParam;
|
||||
|
||||
if (message == WM_KEYDOWN || message == WM_SYSKEYDOWN)
|
||||
type = KT_KEYDOWN;
|
||||
@@ -869,12 +579,12 @@ LRESULT CALLBACK PluginWndProc(HWND hWnd, UINT message, WPARAM wParam,
|
||||
|
||||
if (message == WM_SYSKEYDOWN || message == WM_SYSKEYUP ||
|
||||
message == WM_SYSCHAR)
|
||||
sysChar = true;
|
||||
keyInfo.sysChar = true;
|
||||
|
||||
if (message == WM_IME_CHAR)
|
||||
imeChar = true;
|
||||
keyInfo.imeChar = true;
|
||||
|
||||
g_offscreenBrowser->SendKeyEvent(type, wParam, lParam, sysChar, imeChar);
|
||||
g_offscreenBrowser->SendKeyEvent(type, keyInfo, lParam);
|
||||
}
|
||||
break;
|
||||
|
||||
|
Reference in New Issue
Block a user