- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的 firefox 扩展上有一个 xul:panel。我根据 screen.width 和 screen.height 给出了显示的位置。当我有多个显示器并且我在第一个显示器上启动浏览器时,我的问题出现了,它出现在第二个显示器上并且 xul:panel 是根据第一个屏幕的分辨率在第二个显示器上绘制的。有没有根据副屏分辨率绘制的方案?
最佳答案
背景:
当我为工作开发基于 XULRunner 的多监视器应用程序时,我发现您无法预测在主应用程序/浏览器窗口首次启动后窗口管理器会将启动的窗口放置在何处。
XULRunner 确实正确地给我:
当我指定一组将窗口放置在特定监视器上的窗口坐标时,它没有正确地遵循多监视器几何(而是窗口管理器将新窗口放置在它喜欢的任何地方)。
这让我不得不以某种方式完成以下任务:
在 js-ctypes 加载/使用的外部 DLL 的帮助下,我能够实现这两个目标。
Win32 示例:
以下是将外部 DLL 绑定(bind)到 JavaScript 的基础知识。这个例子只涉及 Win32,但我也为 Linux 和 MacOSX 做了这个(与 Win32 相比,它们分别更容易和更难)。
有3个部分:
我用后面的两个文件构建了一个简单的 GUI DLL 项目并编译了 wmctrl.dll
,依赖于 msvcr100.dll
,并使用了 Dependency Walker找到由 DLL 导出以供 js-ctypes 使用的“纯 C”符号。
我还围绕 API 构建了一个 JavaScript 库,它允许在应用程序的多次运行中操作、跟踪和保留多个窗口的窗口状态/几何图形,但这与这个简单的示例并不相关。
在特权 JavaScript 代码中:
// get js-ctypes, you do this part a bit differently from browser chrome
const {Cc,Ci,Cu} = require("chrome");
var file=null, lib=null, ctypes = {};
Cu.import("resource://gre/modules/ctypes.jsm", ctypes);
var ctypes = ctypes.ctypes;
// build platform specific library path
var filename = ctypes.libraryName("wmctrl");
var comp = "@mozilla.org/file/directory_service;1";
var file = Cc[comp].getService(Ci.nsIProperties).get("CurProcD", Ci.nsIFile);
file.append("browser_code");
file.append(filename);
// get the JavaScript library interface (load the library)
var lib = ctypes.open(file.path);
// wmctrl_find_window: returing unsigned 32bit (long) "window handle"
// takes string "window title".
var find_window = lib.declare("?wmctrl_find_window@@YAKPAD@Z",
ctypes.stdcall_abi, ctypes.uint32_t,
ctypes.char.ptr);
// wmctrl_window_focus: takes unsigned 32bit (long) "window handle".
var window_focus = lib.declare("?wmctrl_window_focus@@YAXK@Z",
ctypes.stdcall_abi, ctypes.void_t,
ctypes.uint32_t);
// wmctrl_window_move: takes unsigned 32bit (long) "window handle",
// and two (x & y) signed 32bit ints.
var window_move = lib.declare("?wmctrl_window_move@@YAXKHH@Z",
ctypes.stdcall_abi, ctypes.void_t,
ctypes.uint32_t, ctypes.int32_t, ctypes.int32_t);
wmctrldll.h
#ifdef WMCTRLDLL_EXPORTS
#define WMCTRLDLL_API __declspec(dllexport)
#else
#define WMCTRLDLL_API __declspec(dllimport)
#endif
WMCTRLDLL_API void wmctrl_window_focus (unsigned long wid);
WMCTRLDLL_API void wmctrl_window_move (unsigned long wid, int x, int y);
WMCTRLDLL_API unsigned long wmctrl_find_window(char* find_title);
wmctrldll.cpp
#include "stdafx.h"
#include "wmctrldll.h"
typedef struct {
HWND hWnd;
char title[255];
} myWinSpec;
BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam) {
char String[255];
myWinSpec* to_find = (myWinSpec*) lParam;
// not a window
if (!hWnd) return TRUE;
// not visible
if (!IsWindowVisible(hWnd)) return TRUE;
// no window title
if (!GetWindowTextA(hWnd, (LPSTR)String, 255)) return TRUE;
// no title match
if (strcmp(String, to_find->title) != 0) return TRUE;
to_find->hWnd = hWnd;
return FALSE;
}
WMCTRLDLL_API void wmctrl_window_focus(unsigned long wid) {
SetForegroundWindow((HWND) wid);
}
WMCTRLDLL_API unsigned long wmctrl_find_window(char* find_title) {
myWinSpec to_find;
sprintf_s(to_find.title, sizeof(to_find.title), "%s", find_title);
to_find.hWnd = 0;
EnumWindows(EnumWindowsProc, (LPARAM)&to_find);
return (unsigned long) to_find.hWnd;
}
WMCTRLDLL_API void wmctrl_window_move(unsigned long wid, int x, int y) {
UINT flags = SWP_SHOWWINDOW | SWP_NOSIZE;
SetForegroundWindow((HWND) wid);
SetWindowPos((HWND) wid, HWND_NOTOPMOST, x, y, NULL, NULL, flags);
}
关于javascript - xul:多个显示器上的面板位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10070456/
我有一个 Bootstrap 面板,里面有另一个面板。两者在面板标题中都有一个字形图标。默认情况下,面板是折叠的。当面板折叠时,将设置 glyphicon-unchecked。当我点击这个字形图标时,
使用 Grafana 时,我们会在某些电视上使用它。有谁知道制作它的方法,如果有人添加面板,更改布局等,它不仅会自动刷新数据,还会自动刷新实际仪表板? 我们真的厌倦了不断要求具有远程访问权限的人登录并
基本上,我试图让屏幕底部有 3 个按钮,然后在屏幕中间有一个包含文字的标签。但是,我似乎无法同时在 GUI 中同时拥有按钮和标签。我是一名初学者,对布局了解不多(即使我已经阅读过它们),因此任何帮助/
作为学校的类(class)作业,我们必须提出一个自定义项目,我选择了一个原本打算在 ActionScript 上编写的游戏创意,但决定在 Java 上插入它。最初进展顺利,游戏代码正常运行, Spri
我正在尝试使用 Java Graphics 制作一个生命模拟游戏,但是当运行我的代码时,屏幕的左侧三分之一是灰色的。我希望整个屏幕是白色的,黑色方 block 代表生命方 block 。我对所有 ja
下面是动态驱动的一个不错的“下拉面板”。 http://www.dynamicdrive.com/dynamicindex17/dddropdownpanel.htm 如您所见,它是一个面板,在打开时
所以我有这个函数 onDisplayError ,如果请求失败,每次都会调用它。这意味着如果用户按下保存按钮并且 3 个请求失败,我当前会收到 3 个弹出消息。我的目标是此函数检查我的弹出窗口是否已打
我正在尝试为我的一个类(class)制作一款游戏,但在实现一些我想做的事情时遇到了麻烦。本质上,我希望在同一个图形用户界面窗口中包含多个不同的部分。 据我了解,我会使用 JPanel 来创建这些不同的
我目前正在测试这种类型的面板 jquery: http://codyhouse.co/gem/css-slide-in-panel/ 但是当我想检测从顶部滚动以显示一个 div 时:没办法:( 一种检
我可能正在搜索错误的问题,但我找不到这个问题的答案。 我有一个 AutoScroll 设置为 true 的面板。控件动态添加到面板。我需要在滚动条可见时触发一个事件,但我找不到这样的事件。 如有任何建
我有一堆 Bootstrap 面板,其中一些是相互关联的。有点像 Panel A -> Panel B -> Panel C 当用户单击面板 B 时,将显示面板 C,当单击面板 C 时,将显示面板 D
我正在尝试开发一种带有指标的下拉列表,并相应地针对应该出现在仪表板上的选定指标特定面板。反之亦然,如果未选择指标,则面板应隐藏。 我找到了链接 http://search-devops.com/m/k
我有一个窗口,窗口里面有面板。我动态地向面板添加组件。这些组件采用“hbox”布局,以便它们水平排列。单击按钮后,我将在“hbox”布局中再向面板添加一行类似组件。这里的问题是我想在第一行下面添加第二
我使用 jQuery Accordion 将表单拆分为多个面板,并使用 jQuery 验证来检查所需字段。只要验证字段位于打开的面板中,它就可以很好地显示已验证字段中的错误。 举个例子。假设我有三个
我正在尝试检查我的面板是打开还是关闭。 我尝试过这样的: $(document).on('open', '.ui-panel', function(){ console.log('open');
我有一个面板,我想将其 float 在所有窗口之上并出现在所有空间中。这可以通过 轻松完成 [self.panel setLevel:kCGUtilityWindowLevel]; [self.win
我想在格子中的单个面板上叠加多个组,并且想要独立的回归线。 获得多个面板相当容易,每个面板都有一条使用条件因子的回归线: xyplot( Petal.Width ~ Petal.Length |
Delphi 有滑动(动画)面板组件吗? 例如可以在 Raize Components 中找到它(带有“热点”或隐藏/显示按钮的左侧面板)。 我不需要一个可调整大小的面板,而是一个可以从左向右水平平滑
我有一个 Bootstrap Accordion : 我想禁用非事件面板中的所有输入控件。仅验证事件面板。 我有一个检测事件选项卡的功能: $(".panel").on("show.bs.collap
我正在尝试将组件放入不同尺寸的面板中。但是,我意识到 GridLayout 将大小相同的部分分开。如何实现如下图所示 enter image description here import java.
我是一名优秀的程序员,十分优秀!