win: Fix notify icon and context menu.
This commit is contained in:
		
					parent
					
						
							
								b4ba149662
							
						
					
				
			
			
				commit
				
					
						b2afe7b3bf
					
				
			
		
					 5 changed files with 17 additions and 11 deletions
				
			
		
							
								
								
									
										1
									
								
								atom.gyp
									
										
									
									
									
								
							
							
						
						
									
										1
									
								
								atom.gyp
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -439,7 +439,6 @@
 | 
			
		|||
              '-loleacc.lib',
 | 
			
		||||
              '-lComdlg32.lib',
 | 
			
		||||
              '-lWininet.lib',
 | 
			
		||||
              '<(atom_source_root)/<(libchromiumcontent_library_dir)/chromiumviews.lib',
 | 
			
		||||
            ],
 | 
			
		||||
          },
 | 
			
		||||
          'dependencies': [
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -44,9 +44,7 @@ class MenuItem
 | 
			
		|||
    Object.defineProperty this, name,
 | 
			
		||||
      enumerable: true
 | 
			
		||||
      get: => v8Util.getHiddenValue this, name
 | 
			
		||||
      set: (val) =>
 | 
			
		||||
        v8Util.setHiddenValue this, name, val
 | 
			
		||||
        @menu?._updateStates()
 | 
			
		||||
      set: (val) => v8Util.setHiddenValue this, name, val
 | 
			
		||||
 | 
			
		||||
  overrideReadOnlyProperty: (name, defaultValue=null) ->
 | 
			
		||||
    this[name] ?= defaultValue
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -76,9 +76,6 @@ Menu::insert = (pos, item) ->
 | 
			
		|||
            v8Util.setHiddenValue otherItem, 'checked', false
 | 
			
		||||
          v8Util.setHiddenValue item, 'checked', true
 | 
			
		||||
 | 
			
		||||
          # Update states when clicked on Windows.
 | 
			
		||||
          @_updateStates() if process.platform is 'win32'
 | 
			
		||||
 | 
			
		||||
      @insertRadioItem pos, item.commandId, item.label, item.groupId
 | 
			
		||||
 | 
			
		||||
  @setSublabel pos, item.sublabel if item.sublabel?
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,6 +13,7 @@
 | 
			
		|||
#include "ui/gfx/icon_util.h"
 | 
			
		||||
#include "ui/gfx/point.h"
 | 
			
		||||
#include "ui/gfx/rect.h"
 | 
			
		||||
#include "ui/views/controls/menu/menu_runner.h"
 | 
			
		||||
 | 
			
		||||
namespace atom {
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -60,8 +61,16 @@ void NotifyIcon::HandleClickEvent(const gfx::Point& cursor_pos,
 | 
			
		|||
  if (!SetForegroundWindow(window_))
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  menu_.reset(new Menu2(menu_model_));
 | 
			
		||||
  menu_->RunContextMenuAt(cursor_pos);
 | 
			
		||||
  menu_runner_.reset(new views::MenuRunner(menu_model_));
 | 
			
		||||
  views::MenuRunner::RunResult result = menu_runner_->RunMenuAt(
 | 
			
		||||
      NULL,
 | 
			
		||||
      NULL,
 | 
			
		||||
      gfx::Rect(cursor_pos, gfx::Size()),
 | 
			
		||||
      views::MenuItemView::TOPLEFT,
 | 
			
		||||
      ui::MENU_SOURCE_MOUSE,
 | 
			
		||||
      views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU);
 | 
			
		||||
  if (result == views::MenuRunner::MENU_DELETED)
 | 
			
		||||
    LOG(ERROR) << "Menu deleted when running";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void NotifyIcon::ResetIcon() {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,9 +20,12 @@ namespace gfx {
 | 
			
		|||
class Point;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
namespace views {
 | 
			
		||||
class MenuRunner;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
namespace atom {
 | 
			
		||||
 | 
			
		||||
class Menu2;
 | 
			
		||||
class NotifyIconHost;
 | 
			
		||||
 | 
			
		||||
class NotifyIcon : public TrayIcon {
 | 
			
		||||
| 
						 | 
				
			
			@ -69,7 +72,7 @@ class NotifyIcon : public TrayIcon {
 | 
			
		|||
 | 
			
		||||
  // The context menu.
 | 
			
		||||
  ui::SimpleMenuModel* menu_model_;
 | 
			
		||||
  scoped_ptr<atom::Menu2> menu_;
 | 
			
		||||
  scoped_ptr<views::MenuRunner> menu_runner_;
 | 
			
		||||
 | 
			
		||||
  DISALLOW_COPY_AND_ASSIGN(NotifyIcon);
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue