Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

Fix CEF 2171 build on Linux #499

Closed
wants to merge 15 commits into from
Closed
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ appshell_extensions_js.o
Makefile
appshell.Makefile
Brackets.target.mk
gtk.target.mk
libcef_dll_wrapper.target.mk
appshell/gtk
appshell/gtk/*
Expand Down
9 changes: 6 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,14 @@ module.exports = function (grunt) {
"lib/**",
"locales/**",
"node-core/**",
"cef.pak",
"cef_100_percent.pak",
"cef_200_percent.pak",
"devtools_resources.pak",
"icudtl.dat",
"appshell*.png",
"Brackets",
"Brackets-node",
"cef.pak",
"devtools_resources.pak"
"Brackets-node"
],
"dest" : "<%= build.staging %>"
},
Expand Down
40 changes: 35 additions & 5 deletions appshell.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -333,16 +333,19 @@
'<@(includes_linux)',
'<@(appshell_sources_linux)',
],
'dependencies': [
'gtk'
],
'link_settings': {
'ldflags': [
'<!@(<(pkg-config) --libs-only-other gtk+-2.0 gthread-2.0)',
# Look for libcef.so in the current directory. Path can also be
# specified using the LD_LIBRARY_PATH environment variable.
'-Wl,-rpath,\$$ORIGIN/lib',
'<(march)'
],
'libraries': [
'<!@(<(pkg-config) --libs-only-l gtk+-2.0 gthread-2.0)',
'$(BUILDTYPE)/libcef.so',
'appshell_extensions_js.o',
"$(BUILDTYPE)/libcef.so",
"appshell_extensions_js.o",
"-lX11",
],
},
}],
Expand Down Expand Up @@ -490,6 +493,33 @@
}, # target appshell_helper_app
],
}], # OS=="mac"
[ 'OS=="linux" or OS=="freebsd" or OS=="openbsd"', {
'targets': [
{
'target_name': 'gtk',
'type': 'none',
'variables': {
# gtk requires gmodule, but it does not list it as a dependency
# in some misconfigured systems.
'gtk_packages': 'gmodule-2.0 gtk+-2.0 gthread-2.0',
},
'direct_dependent_settings': {
'cflags': [
'$(shell <(pkg-config) --cflags <(gtk_packages))',
],
},
'link_settings': {
'ldflags': [
'$(shell <(pkg-config) --libs-only-L --libs-only-other <(gtk_packages))',
],
'libraries': [
'$(shell <(pkg-config) --libs-only-l <(gtk_packages))',
'-lpthread',
],
},
},
],
}], # OS=="linux" or OS=="freebsd" or OS=="openbsd"
['target_arch=="ia32"', {
'variables': {
'output_bfd': 'elf32-i386',
Expand Down
32 changes: 23 additions & 9 deletions appshell/appshell_extensions_gtk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@

GtkWidget* _menuWidget;

// The global ClientHandler reference.
extern CefRefPtr<ClientHandler> g_handler;

// Supported browsers (order matters):
// - google-chorme
// - chromium-browser - chromium executable name (in ubuntu)
Expand Down Expand Up @@ -532,21 +535,32 @@ void MoveFileOrDirectoryToTrash(ExtensionString filename, CefRefPtr<CefBrowser>

void CloseWindow(CefRefPtr<CefBrowser> browser)
{
if (browser.get()) {
isReallyClosing = true;
// //# Hack because CEF's CloseBrowser() is bad. Should emit delete_event instead of directly destroying widget
// GtkWidget* hwnd = gtk_widget_get_toplevel (browser->GetHost()->GetWindowHandle() );
// if(gtk_widget_is_toplevel (hwnd))
// gtk_signal_emit_by_name(GTK_OBJECT(hwnd), "delete_event");
// else
browser->GetHost()->CloseBrowser(true);
if (browser.get()) {
isReallyClosing = true;
browser->GetHost()->CloseBrowser(true);

// //# Hack because CEF's CloseBrowser() is bad. Should emit delete_event instead of directly destroying widget
//GtkWidget* hwnd = gtk_widget_get_toplevel (browser->GetHost()->GetWindowHandle() );
//GtkWindow* hwnd = GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(g_handler->GetMainHwnd())));
// if(gtk_widget_is_toplevel (hwnd))
//g_message("Called destroy");
//gtk_widget_destroy(gtk_widget_get_toplevel(GTK_WIDGET(g_handler->GetMainHwnd())));
//gtk_signal_emit_by_name(GTK_OBJECT(hwnd), "delete_event");
// else

// pass this message onto the window
if (g_handler && g_handler->GetMainHwnd()) {
GtkWidget* hwnd = gtk_widget_get_toplevel(GTK_WIDGET(g_handler->GetMainHwnd()));
if(gtk_widget_is_toplevel (hwnd))
gtk_signal_emit_by_name(GTK_OBJECT(hwnd), "delete_event");
}
}
}

void BringBrowserWindowToFront(CefRefPtr<CefBrowser> browser)
{
if (browser.get()) {
GtkWindow* hwnd = GTK_WINDOW(browser->GetHost()->GetWindowHandle());
GtkWindow* hwnd = GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(g_handler->GetMainHwnd())));
if (hwnd)
gtk_window_present(hwnd);
}
Expand Down
30 changes: 17 additions & 13 deletions appshell/appshell_extensions_platform.h
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
/*
* Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/
*
*/

#pragma once

Expand All @@ -28,6 +28,10 @@

#include <string>

#ifdef OS_LINUX
#include <gtk/gtk.h>
#endif

// Extension error codes. These MUST be in sync with the error
// codes in appshell_extensions.js
#if !defined(OS_WIN) // NO_ERROR is defined on windows
Expand Down
10 changes: 5 additions & 5 deletions appshell/appshell_node_process_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#include "config.h"

#define BRACKETS_NODE_BUFFER_SIZE 4096
#define MAX_PATH 128
#define MAX_PATH 256

// init mutex
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
Expand Down Expand Up @@ -82,10 +82,10 @@ void* nodeThread(void* unused) {

// TODO nodeStartTime = get time();

char executablePath[MAX_PATH];
char bracketsDirPath[MAX_PATH];
char nodeExecutablePath[MAX_PATH];
char nodecorePath[MAX_PATH];
char executablePath[MAX_PATH] = {0};
char bracketsDirPath[MAX_PATH] = {0};
char nodeExecutablePath[MAX_PATH] = {0};
char nodecorePath[MAX_PATH] = {0};

// get path to Brackets
if (readlink("/proc/self/exe", executablePath, MAX_PATH) == -1) {
Expand Down
4 changes: 2 additions & 2 deletions appshell/cefclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ CefRefPtr<CefBrowser> AppGetBrowser() {
return g_handler->GetBrowser();
}

CefWindowHandle AppGetMainHwnd() {
ClientWindowHandle AppGetMainHwnd() {
if (!g_handler.get())
return NULL;
return kNullWindowHandle;
return g_handler->GetMainHwnd();
}

Expand Down
3 changes: 2 additions & 1 deletion appshell/cefclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <string>
#include "include/cef_base.h"
#include "client_app.h"
#include "client_handler.h"

class CefApp;
class CefBrowser;
Expand All @@ -18,7 +19,7 @@ class CefCommandLine;
CefRefPtr<CefBrowser> AppGetBrowser();

// Returns the main application window handle.
CefWindowHandle AppGetMainHwnd();
ClientWindowHandle AppGetMainHwnd();

// Returns the application working directory.
std::string AppGetWorkingDirectory();
Expand Down
Loading