コード例 #1
0
NS_IMETHODIMP ExternalWrapper::Init(nsIDOMWindow* suppliedWindow,
    PRBool *_retval) {
#else
NS_IMETHODIMP ExternalWrapper::Init(nsIDOMWindow* suppliedWindow,
    bool *_retval) {
#endif //GECKO_VERSION

  Debug::log(Debug::Debugging) << "Plugin initialized from hosted.html"
      << Debug::flush;
  *_retval = false;
  nsCOMPtr<nsIDOMWindow> computedWindow;
  if (getWindowObject(getter_AddRefs(computedWindow))) {
    Debug::log(Debug::Debugging) << " passed window=" << suppliedWindow
        << ", computed=" << computedWindow << Debug::flush;
    domWindow = computedWindow;
  } else {
    Debug::log(Debug::Warning) << " using supplied window object"
        << Debug::flush;
    // TODO(jat): remove this
    domWindow = suppliedWindow;
  }
  if (getTopWindow(domWindow, getter_AddRefs(topWindow), url)) {
    *_retval = true;
  }
  return NS_OK;
}
コード例 #2
0
ファイル: getActiveWindow.c プロジェクト: awpe/xwinclone
Window
getActiveWindow (XWCContext * ctx,
                 Window       implicitW)
{
    if (ctx == NULL)
    {
        logCtrl ("Error getting active window: No program options"
                 " data specified!", LOG_LVL_NO, False);
        return None;
    }

    if (ctx->xDpy == NULL)
    {
        logCtrl ("Error getting active window: No display specified!",
                 LOG_LVL_NO, False);
        return None;
    }

    if (implicitW == None)
    {
        implicitW = getFocusedWindow (ctx);
    }

    if (     implicitW                                           == None
        || ( implicitW = getTopWindow (ctx, implicitW)   ) == None
        || ( implicitW = getNamedWindow (ctx, implicitW) ) == None )
    {
        logCtrl ("Error getting active window: No active window found!",
                 LOG_LVL_NO, False);
        return None;
    }

    return implicitW;
}
コード例 #3
0
ファイル: main.c プロジェクト: david0/neoplace
void toggleWindowVisible()
{
	is_visible = !is_visible;
	if (is_visible) {
		top_window = getTopWindow();
		centerOnWindow(main_window, top_window);
		ShowWindow(main_window, SW_SHOWDEFAULT);
		UpdateWindow(main_window);
		SetFocus(main_window);
		SetTimer(main_window, 1, 500, NULL);
	} else {
		ShowWindow(main_window, SW_HIDE);
		is_checking = false;
		KillTimer(main_window, 1);
	}

}
コード例 #4
0
ファイル: gui.cpp プロジェクト: Julien-B/aseprite
// Manager event handler.
bool CustomizedGuiManager::onProcessMessage(Message* msg)
{
    switch (msg->type()) {

    case kCloseAppMessage:
    {
        // Execute the "Exit" command.
        Command* command = CommandsModule::instance()->getCommandByName(CommandId::Exit);
        UIContext::instance()->executeCommand(command);
    }
    break;

    case kDropFilesMessage:
    {
        // If the main window is not the current foreground one. We
        // discard the drop-files event.
        if (getForegroundWindow() != App::instance()->getMainWindow())
            break;

        const DropFilesMessage::Files& files = static_cast<DropFilesMessage*>(msg)->files();

        // Open all files
        Command* cmd_open_file =
            CommandsModule::instance()->getCommandByName(CommandId::OpenFile);
        Params params;

        for (DropFilesMessage::Files::const_iterator
                it = files.begin(); it != files.end(); ++it) {
            params.set("filename", it->c_str());
            UIContext::instance()->executeCommand(cmd_open_file, &params);
        }
    }
    break;

    case kQueueProcessingMessage:
        gui_feedback();
        break;

    case kKeyDownMessage: {
        Window* toplevel_window = getTopWindow();

        // If there is a foreground window as top level...
        if (toplevel_window &&
                toplevel_window != App::instance()->getMainWindow() &&
                toplevel_window->isForeground()) {
            // We just do not process keyboard shortcuts for menus and tools
            break;
        }

        for (Shortcut* shortcut : *shortcuts) {
            if (shortcut->is_pressed(msg)) {
                // Cancel menu-bar loops (to close any popup menu)
                App::instance()->getMainWindow()->getMenuBar()->cancelMenuLoop();

                switch (shortcut->type) {

                case Shortcut::Type::ChangeTool: {
                    tools::Tool* current_tool = UIContext::instance()->settings()->getCurrentTool();
                    tools::Tool* select_this_tool = shortcut->tool;
                    tools::ToolBox* toolbox = App::instance()->getToolBox();
                    std::vector<tools::Tool*> possibles;

                    // Iterate over all tools
                    for (tools::ToolIterator it = toolbox->begin(); it != toolbox->end(); ++it) {
                        Shortcut* shortcut = get_keyboard_shortcut_for_tool(*it);

                        // Collect all tools with the pressed keyboard-shortcut
                        if (shortcut && shortcut->is_pressed(msg))
                            possibles.push_back(*it);
                    }

                    if (possibles.size() >= 2) {
                        bool done = false;

                        for (size_t i=0; i<possibles.size(); ++i) {
                            if (possibles[i] != current_tool &&
                                    ToolBar::instance()->isToolVisible(possibles[i])) {
                                select_this_tool = possibles[i];
                                done = true;
                                break;
                            }
                        }

                        if (!done) {
                            for (size_t i=0; i<possibles.size(); ++i) {
                                // If one of the possibilities is the current tool
                                if (possibles[i] == current_tool) {
                                    // We select the next tool in the possibilities
                                    select_this_tool = possibles[(i+1) % possibles.size()];
                                    break;
                                }
                            }
                        }
                    }

                    ToolBar::instance()->selectTool(select_this_tool);
                    return true;
                }

                case Shortcut::Type::ExecuteCommand: {
                    Command* command = shortcut->command;

                    // Commands are executed only when the main window is
                    // the current window running at foreground.
                    UI_FOREACH_WIDGET(getChildren(), it) {
                        Window* child = static_cast<Window*>(*it);

                        // There are a foreground window executing?
                        if (child->isForeground()) {
                            break;
                        }
                        // Is it the desktop and the top-window=
                        else if (child->isDesktop() && child == App::instance()->getMainWindow()) {
                            // OK, so we can execute the command represented
                            // by the pressed-key in the message...
                            UIContext::instance()->executeCommand(command, shortcut->params);
                            return true;
                        }
                    }
                    break;
                }

                case Shortcut::Type::EditorQuicktool: {
                    // Do nothing, it is used in the editor through the
                    // get_selected_quicktool() function.
                    break;
                }

                }
                break;
            }
        }
        break;
    }
コード例 #5
0
ファイル: main.c プロジェクト: david0/neoplace
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	HINSTANCE hInstance;
	switch (msg) {
	case WM_CREATE:
		{
			hInstance = ((LPCREATESTRUCT) lParam)->hInstance;
			initGUI(hWnd, hInstance);
			resizeMainWindow(hWnd);
			centerOnWindow(hWnd, top_window);
			return 0;
		}

	case WM_COMMAND:
		{
			unsigned x, y;

			for (x = 0; x < BUTTON_COLS; x++)
				for (y = 0; y < BUTTON_ROWS; y++) {
					if (lParam == (LPARAM) buttons[y][x]) {
						if (is_checking) {
							RECT area;

							area.top = min(y, last_click_position.y);
							area.bottom = max(y, last_click_position.y);

							area.left = min(x, last_click_position.x);
							area.right = max(x, last_click_position.x);

							resizeAndMoveWindowTo(top_window, area);
							centerOnWindow(main_window, top_window);
						}
						last_click_position.x = x;
						last_click_position.y = y;
					}
				}

			is_checking = !is_checking;
			return 0;
		}
		break;

		switch (LOWORD(wParam)) {
		case ID_BUTTON_RESIZE:
			if (HIWORD(wParam) == BN_CLICKED) {
				SetWindowPos(top_window, 0, 0, 0, 100, 100, 0);
			}
			return 0;

		}
		break;

	case WM_TIMER:
		{
			HWND foreground = getTopWindow();
			if (foreground != top_window) {
				top_window = foreground;
				if (is_visible) {
					centerOnWindow(hWnd, top_window);
					SetFocus(hWnd);
				}
			}
			SetTimer(hWnd, 1, 500, NULL);
			return 0;
		}

	case WM_KILLFOCUS:
		{
			if (is_visible) {
				SetTimer(hWnd, 1, 200, NULL);
				is_checking = false;
			}
		}
		break;

	case WM_CLOSE:
		{
			toggleWindowVisible();
			return 0;
		}

	}

	return DefWindowProc(hWnd, msg, wParam, lParam);
}