修改ion2加入xrandr支持

首先,在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);
....
}
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值