首先,在ioncore/eventh.c中加入下面的代码
#include <X11/extensions/Xrandr.h>
static int hasXrandR=0;
static int xrr_event_base;
static int xrr_error_base;
static void handle_xrandr_notify(XEvent *ev)
{
if ( !hasXrandR ) return ;
if(ev->type == xrr_event_base + RRScreenChangeNotify) {
XRRScreenChangeNotifyEvent *rev;
WScreen *screen;
WRootWin *rootwin;
WRectangle rc;
rev =(XRRScreenChangeNotifyEvent *)ev;
printf("handle xrandr event, width=%d, height=%d/n",
rev->width, rev->height);
rootwin = find_rootwin_for_root(rev->root);
printf("root=0x%X, rootwin=0x%X, globalrootwin=0x%X/n",
(int)rev->root, (int)rootwin, (int)wglobal.rootwins);
screen = rootwin_current_scr(rootwin);
if ( screen == NULL )
{
screen = rootwin_current_scr(wglobal.rootwins);
if (screen == NULL) return;
}
printf("screen: 0x%X/n", (unsigned int)screen);
rc.x = screen->managed_off.x;
rc.y = screen->managed_off.y;
if(rev->rotation==RR_Rotate_90 || rev->rotation==RR_Rotate_270){
rc.w=rev->height;
rc.h=rev->width;
}else{
rc.w=rev->width;
rc.h=rev->height;
}
printf("xrandr: %d, %d, %d, %d/n", rc.x , rc.y, rc.w, rc.h);
mplex_fit((WMPlex*)screen, &rc);
mplex_managed_geom((WMPlex*)screen, &rc);
mplex_fit_managed((WMPlex*)screen);
mplex_size_changed((WMPlex*)screen, 1, 1);
}
}
然后,修改ioncore_mainloop函数
void ioncore_mainloop()
{
XEvent ev;
wglobal.opmode=OPMODE_NORMAL;
set_initial_focus();
xrandr_init();
for(;;){
get_event(&ev);
CALL_ALT_B_NORET(handle_event_alt, (&ev));
handle_xrandr_notify(&ev);
....
}
修改ion2加入xrandr支持
最新推荐文章于 2022-09-21 01:46:53 发布