Skip to content

Commit

Permalink
[Win32] Fix issue with creating status icon before creating a window
Browse files Browse the repository at this point in the history
  • Loading branch information
milani committed Nov 6, 2012
1 parent 8b53576 commit 79038e3
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 40 deletions.
2 changes: 1 addition & 1 deletion lib/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ inherit(App, EventEmitter, [
}

if(options.icon) {
options.icon = pathResolve(options.icon);
options.icon = pathResolve(__dirname,'../../../..',options.icon);
}

var self = this,
Expand Down
2 changes: 1 addition & 1 deletion lib/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var normalizeMnemonic = function(options){
var normalize = function(options){
for(i in options) {
if(options[i].hasOwnProperty('icon')){
options[i]['icon'] = path.resolve(options[i]['icon']);
options[i]['icon'] = path.resolve(__dirname,'../../../..',options[i]['icon']);
}
normalize(options[i]['submenu']);
}
Expand Down
13 changes: 13 additions & 0 deletions src/includes/cef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,19 @@ void Cef::Init(Settings* initOptions) {
gtk_init(NULL,NULL);
#endif

#if defined(__WIN__)
dwmapiDLL = LoadLibrary(TEXT("dwmapi.dll"));
if (dwmapiDLL != NULL) {
DwmExtendFrameIntoClientArea = (DWMEFICA)GetProcAddress(dwmapiDLL, "DwmExtendFrameIntoClientArea");
DwmEnableBlurBehindWindow = (DWMEBBW)GetProcAddress(dwmapiDLL, "DwmEnableBlurBehindWindow");
DwmDefWindowProc = (DWMWP)GetProcAddress(dwmapiDLL, "DwmDefWindowProc");
}

Gdiplus::GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
#endif

Cef::initialized_ = true;
}
}
Expand Down
40 changes: 40 additions & 0 deletions src/includes/cef.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,48 @@
#include "util.h"
#include "cef_loop.h"

#ifdef __WIN__
#include <windows.h>
#include <algorithm>
#define min(left,right) std::min(left,right)
#define max(left,right) std::max(left,right)
#include <gdiplus.h>
#undef min
#undef max
#include <shlobj.h>
#include <shlwapi.h>

typedef struct _BLURBEHIND {
DWORD dwFlags;
BOOL fEnable;
HRGN hRgnBlur;
BOOL fTransitionOnMaximized;
} BLURBEHIND, *PBLURBEHIND;

typedef struct _MARGINS {
int cxLeftWidth;
int cxRightWidth;
int cyTopHeight;
int cyBottomHeight;
} MARGINS, *PMARGINS;

typedef HRESULT (WINAPI *DWMEFICA)(HWND, MARGINS*);
typedef HRESULT (WINAPI *DWMEBBW)(HWND, BLURBEHIND*);
typedef BOOL (WINAPI *DWMWP)(HWND, UINT, WPARAM, LPARAM, LRESULT*);

static DWMEFICA DwmExtendFrameIntoClientArea = NULL;
static DWMEBBW DwmEnableBlurBehindWindow = NULL;
static DWMWP DwmDefWindowProc = NULL;
static HMODULE dwmapiDLL = NULL;

#endif

namespace appjs {

// ###################################################
// ### DWM functions that don't exist in WindowsXP ###
// ###################################################

class Cef : public CefLoop {

public:
Expand Down
38 changes: 0 additions & 38 deletions src/native_window/native_window_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,34 +32,6 @@ HINSTANCE hInstance;
char* url_;
bool emitFullscreen = false;


// ###################################################
// ### DWM functions that don't exist in WindowsXP ###
// ###################################################

typedef struct _BLURBEHIND {
DWORD dwFlags;
BOOL fEnable;
HRGN hRgnBlur;
BOOL fTransitionOnMaximized;
} BLURBEHIND, *PBLURBEHIND;

typedef struct _MARGINS {
int cxLeftWidth;
int cxRightWidth;
int cyTopHeight;
int cyBottomHeight;
} MARGINS, *PMARGINS;

typedef HRESULT (WINAPI *DWMEFICA)(HWND, MARGINS*);
typedef HRESULT (WINAPI *DWMEBBW)(HWND, BLURBEHIND*);
typedef BOOL (WINAPI *DWMWP)(HWND, UINT, WPARAM, LPARAM, LRESULT*);

static DWMEFICA DwmExtendFrameIntoClientArea = NULL;
static DWMEBBW DwmEnableBlurBehindWindow = NULL;
static DWMWP DwmDefWindowProc = NULL;
static HMODULE dwmapiDLL = NULL;

// #################################
// ### Windows Utility Functions ###
// #################################
Expand Down Expand Up @@ -176,16 +148,6 @@ void NativeWindow::Init(char* url, Settings* settings) {
url_ = url;

if (is_main_window_) {
dwmapiDLL = LoadLibrary(TEXT("dwmapi.dll"));
if (dwmapiDLL != NULL) {
DwmExtendFrameIntoClientArea = (DWMEFICA)GetProcAddress(dwmapiDLL, "DwmExtendFrameIntoClientArea");
DwmEnableBlurBehindWindow = (DWMEBBW)GetProcAddress(dwmapiDLL, "DwmEnableBlurBehindWindow");
DwmDefWindowProc = (DWMWP)GetProcAddress(dwmapiDLL, "DwmDefWindowProc");
}

Gdiplus::GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

TCHAR* wSmallIconPath = icons->getString("small", TEXT(""));
TCHAR* wBigIconPath = icons->getString("big", TEXT(""));
Expand Down

0 comments on commit 79038e3

Please sign in to comment.