static bool region_is_parent(WRegion *reg, WRegion *aw) { while(aw!=NULL){ if(aw==reg) return TRUE; aw=REGION_PARENT_REG(aw); } return FALSE; }
static void await_watch_handler(Watch *UNUSED(watch), WRegion *prev) { WRegion *r; while(1){ r=REGION_PARENT_REG(prev); if(r==NULL) break; if(watch_setup(&await_watch, (Obj*)r, (WatchHandler*)await_watch_handler)) break; prev=r; } }
static void check_scroll(WMenu *menu, int x, int y) { WRegion *parent=REGION_PARENT_REG(menu); int rx, ry; WTimerHandler *fn=NULL; if(!menu->pmenu_mode) return; if(parent==NULL){ end_scroll(menu); return; } region_rootpos(parent, &rx, &ry); x-=rx; y-=ry; if(x<=SCROLL_OFFSET){ fn=(WTimerHandler*)scroll_right; }else if(y<=SCROLL_OFFSET){ fn=(WTimerHandler*)scroll_down; }else if(x>=REGION_GEOM(parent).w-SCROLL_OFFSET){ fn=(WTimerHandler*)scroll_left; }else if(y>=REGION_GEOM(parent).h-SCROLL_OFFSET){ fn=(WTimerHandler*)scroll_up; }else{ end_scroll(menu); return; } assert(fn!=NULL); if(scroll_timer!=NULL){ if(scroll_timer->handler==(WTimerHandler*)fn && timer_is_set(scroll_timer)){ return; } }else{ scroll_timer=create_timer(); if(scroll_timer==NULL) return; } fn(scroll_timer, (Obj*)menu_head(menu)); }
void region_absolute_geom_to_parent(WRegion *reg, const WRectangle *rgeom, WRectangle *pgeom) { WRegion *parent=REGION_PARENT_REG(reg); pgeom->w=rgeom->w; pgeom->h=rgeom->h; if(parent==NULL){ pgeom->x=rgeom->x; pgeom->y=rgeom->y; }else{ region_rootpos(reg, &pgeom->x, &pgeom->y); pgeom->x=rgeom->x-pgeom->x; pgeom->y=rgeom->y-pgeom->y; } }
static int scrolld_subs(WMenu *menu, int d) { int diff=0; WRegion *p=REGION_PARENT_REG(menu); const WRectangle *pg; if(p==NULL) return 0; pg=®ION_GEOM(p); while(menu!=NULL){ diff=maxof(diff, calc_diff(®ION_GEOM(menu), pg, d)); menu=menu->submenu; } return minof(maxof(0, diff), scroll_amount); }
static int scrolld_subs(WMenu *menu, int d) { int diff=0; WRegion *p=REGION_PARENT_REG(menu); const WRectangle *pg; if(p==NULL) return 0; pg=®ION_GEOM(p); while(menu!=NULL){ int new_diff = calc_diff(®ION_GEOM(menu), pg, d); diff=MAXOF(diff, new_diff); menu=menu->submenu; } return MINOF(MAXOF(0, diff), scroll_amount); }
if(reg->active_sub==NULL) { /* I update the current focus indicator right now. The focuslist is * updated on a timer to keep the list ordered by importance (to keep * windows that the user quickly cycles through at the bottom of the list) */ ioncore_g.focus_current = reg; schedule_focuslist_insert_timer(reg); } if(!REGION_IS_ACTIVE(reg)){ D(fprintf(stderr, "got focus (inact) %s [%p]\n", OBJ_TYPESTR(reg), reg);) reg->flags|=REGION_ACTIVE; region_set_manager_pseudoactivity(reg); par=REGION_PARENT_REG(reg); if(par!=NULL){ par->active_sub=reg; region_update_owned_grabs(par); } region_activated(reg); region_notify_change(reg, ioncore_g.notifies.activated); }else{ D(fprintf(stderr, "got focus (act) %s [%p]\n", OBJ_TYPESTR(reg), reg);) } /* Install default colour map only if there is no active subregion; * their maps should come first. WClientWins will install their maps * in region_activated. Other regions are supposed to use the same * default map.
static void confine_to_parent(WWindow *wwin) { WRegion *par=REGION_PARENT_REG(wwin); if(par!=NULL) ioncore_grab_confine_to(region_xwindow(par)); }