const int kResizeInsideBoundsSize = 5;
const int kResizeAreaCornerSize = 16;
+// Returns true if |possible_parent| is a parent window of |child|.
+bool IsParent(gfx::NativeView child, gfx::NativeView possible_parent) {
+ if (!child)
+ return false;
+ if (::GetWindow(child, GW_OWNER) == possible_parent)
+ return true;
+ gfx::NativeView parent = ::GetParent(child);
+ while (parent) {
+ if (possible_parent == parent)
+ return true;
+ parent = ::GetParent(parent);
+ }
+
+ return false;
+}
+
// Wrapper of NativeWidgetWin to handle WM_MENUCOMMAND messages, which are
// triggered by window menus.
class MenuCommandNativeWidget : public views::NativeWidgetWin {
window_->set_frame_type(views::Widget::FRAME_TYPE_FORCE_NATIVE);
window_->Init(params);
+ views::WidgetFocusManager::GetInstance()->AddFocusChangeListener(this);
+
int width = 800, height = 600;
options->GetInteger(switches::kWidth, &width);
options->GetInteger(switches::kHeight, &height);
return new NativeWindowFramelessView(widget, this);
}
+void NativeWindowWin::OnNativeFocusChange(gfx::NativeView focused_before,
+ gfx::NativeView focused_now) {
+ gfx::NativeView this_window = GetWidget()->GetNativeView();
+ if (IsParent(focused_now, this_window))
+ return;
+
+ if (focused_now == this_window)
+ NotifyWindowFocus();
+ else if (focused_before == this_window)
+ NotifyWindowBlur();
+}
+
void NativeWindowWin::ClientAreaSizeToWindowSize(gfx::Size* size) {
gfx::Size window = window_->GetWindowBoundsInScreen().size();
gfx::Size client = window_->GetClientAreaBoundsInScreen().size();
#include "atom/browser/native_window.h"
#include "atom/browser/ui/accelerator_util.h"
#include "ui/gfx/size.h"
+#include "ui/views/focus/widget_focus_manager.h"
#include "ui/views/widget/widget_delegate.h"
namespace ui {
class Menu2;
class NativeWindowWin : public NativeWindow,
+ public views::WidgetFocusChangeListener,
public views::WidgetDelegateView {
public:
explicit NativeWindowWin(content::WebContents* web_contents,
virtual views::NonClientFrameView* CreateNonClientFrameView(
views::Widget* widget) OVERRIDE;
+ // Overridden from views::WidgetFocusChangeListener:
+ virtual void OnNativeFocusChange(gfx::NativeView focused_before,
+ gfx::NativeView focused_now) OVERRIDE;
+
private:
typedef struct { int position; ui::MenuModel* model; } MenuItem;
typedef std::map<ui::Accelerator, MenuItem> AcceleratorTable;