Skip to content
Browse files

[Win32] Fix issue with creating status icon before creating a window

  • Loading branch information...
1 parent 8b53576 commit 79038e30043f61d6f8c15a32726717f840f6a54f @milani milani committed Nov 6, 2012
Showing with 55 additions and 40 deletions.
  1. +1 −1 lib/App.js
  2. +1 −1 lib/menu.js
  3. +13 −0 src/includes/cef.cpp
  4. +40 −0 src/includes/cef.h
  5. +0 −38 src/native_window/native_window_win.cpp
View
2 lib/App.js
@@ -55,7 +55,7 @@ inherit(App, EventEmitter, [
}
if(options.icon) {
- options.icon = pathResolve(options.icon);
+ options.icon = pathResolve(__dirname,'../../../..',options.icon);
}
var self = this,
View
2 lib/menu.js
@@ -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']);
}
View
13 src/includes/cef.cpp
@@ -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;
}
}
View
40 src/includes/cef.h
@@ -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:
View
38 src/native_window/native_window_win.cpp
@@ -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 ###
// #################################
@@ -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(""));

0 comments on commit 79038e3

Please sign in to comment.
Something went wrong with that request. Please try again.