*
* Copyright (c) Tuomo Valkonen 1999-2007.
*
- * Ion is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or
- * (at your option) any later version.
+ * See the included file LICENSE for details.
*/
#include <string.h>
#include <libtu/objp.h>
#include <libtu/minmax.h>
-#include <libmainloop/defer.h>
#include "common.h"
#include "global.h"
#include "regbind.h"
#include "frame-pointer.h"
#include "rectangle.h"
-#include "infowin.h"
-#include "activity.h"
#include "extlconv.h"
#include "llist.h"
#include "group-ws.h"
#include "mplex.h"
-#include "tags.h"
-#include "gr.h"
-#include "gr-util.h"
#include "conf.h"
+#include "activity.h"
+#include "screen-notify.h"
WHook *screen_managed_changed_hook=NULL;
-static void screen_update_infowin(WScreen *scr);
-
-
-
/*{{{ Init/deinit */
scr->managed_off.h=0;
scr->next_scr=NULL;
scr->prev_scr=NULL;
- scr->rotation=SCREEN_ROTATION_0;
watch_init(&(scr->notifywin_watch));
watch_init(&(scr->infowin_watch));
n==NULL ? "" : n);
}
+ if(region_is_activity_r((WRegion*)scr))
+ screen_update_notifywin(scr);
+
screen_update_infowin(scr);
mplex_call_changed_hook((WMPlex*)scr,
/*}}}*/
-/*}}}*/
-
-
-/*{{{ Notifications */
-
-
-static void do_notify(WScreen *scr, Watch *watch, bool right,
- const char *str, char *style)
-{
-
- WInfoWin *iw=(WInfoWin*)(watch->obj);
- WFitParams fp;
-
- if(iw==NULL){
- WMPlexAttachParams param=MPLEXATTACHPARAMS_INIT;
-
- param.flags=(MPLEX_ATTACH_UNNUMBERED|
- MPLEX_ATTACH_SIZEPOLICY|
- MPLEX_ATTACH_GEOM|
- MPLEX_ATTACH_LEVEL);
- param.level=STACKING_LEVEL_ON_TOP;
-
- if(!right){
- param.szplcy=SIZEPOLICY_GRAVITY_NORTHWEST;
- param.geom.x=0;
- }else{
- param.szplcy=SIZEPOLICY_GRAVITY_NORTHEAST;
- param.geom.x=REGION_GEOM(scr).w-1;
- }
-
- param.geom.y=0;
- param.geom.w=1;
- param.geom.h=1;
-
- iw=(WInfoWin*)mplex_do_attach_new(&scr->mplex, ¶m,
- (WRegionCreateFn*)create_infowin,
- style);
-
- if(iw==NULL)
- return;
-
- watch_setup(watch, (Obj*)iw, NULL);
- }
-
- infowin_set_text(iw, str);
-}
-
-
-void screen_notify(WScreen *scr, const char *str)
-{
- do_notify(scr, &scr->notifywin_watch, FALSE, str, "actnotify");
-}
-
-
-void screen_windowinfo(WScreen *scr, const char *str)
-{
- do_notify(scr, &scr->infowin_watch, TRUE, str, "tab-info");
-}
-
-
-void screen_unnotify(WScreen *scr)
-{
- Obj *iw=scr->notifywin_watch.obj;
- if(iw!=NULL){
- watch_reset(&(scr->notifywin_watch));
- region_dispose((WRegion*)iw, FALSE);
- }
-}
-
-
-void screen_nowindowinfo(WScreen *scr)
-{
- Obj *iw=scr->infowin_watch.obj;
- if(iw!=NULL){
- watch_reset(&(scr->infowin_watch));
- region_dispose((WRegion*)iw, FALSE);
- }
-}
-
-
-static char *addnot(char *str, WRegion *reg)
-{
- const char *nm=region_name(reg);
- char *nstr=NULL;
-
- if(nm==NULL)
- return str;
-
- if(str==NULL)
- return scat(TR("act: "), nm);
-
- nstr=scat3(str, ", ", nm);
- if(nstr!=NULL)
- free(str);
- return nstr;
-}
-
-
-static char *screen_managed_activity(WScreen *scr)
-{
- char *notstr=NULL;
- WMPlexIterTmp tmp;
- WRegion *reg;
-
- FOR_ALL_MANAGED_BY_MPLEX(&scr->mplex, reg, tmp){
- if(region_is_activity_r(reg) && !REGION_IS_MAPPED(reg))
- notstr=addnot(notstr, reg);
- }
-
- return notstr;
-}
-
-
-static void screen_notify_activity(WScreen *scr)
-{
- if(ioncore_g.screen_notify){
- char *notstr=screen_managed_activity(scr);
- if(notstr!=NULL){
- screen_notify(scr, notstr);
- free(notstr);
- return;
- }
- }
-
- screen_unnotify(scr);
-
- screen_update_infowin(scr);
-}
-
-
-static void screen_notify_tag(WScreen *scr)
-{
- screen_update_infowin(scr);
-}
-
-
-GR_DEFATTR(active);
-GR_DEFATTR(inactive);
-GR_DEFATTR(selected);
-GR_DEFATTR(tagged);
-GR_DEFATTR(not_tagged);
-GR_DEFATTR(not_dragged);
-GR_DEFATTR(activity);
-GR_DEFATTR(no_activity);
-
-
-static void init_attr()
-{
- GR_ALLOCATTR_BEGIN;
- GR_ALLOCATTR(active);
- GR_ALLOCATTR(inactive);
- GR_ALLOCATTR(selected);
- GR_ALLOCATTR(tagged);
- GR_ALLOCATTR(not_tagged);
- GR_ALLOCATTR(not_dragged);
- GR_ALLOCATTR(no_activity);
- GR_ALLOCATTR(activity);
- GR_ALLOCATTR_END;
-}
-
-
-static void screen_update_infowin(WScreen *scr)
-{
- WRegion *reg=mplex_mx_current(&(scr->mplex));
- bool tag=(reg!=NULL && region_is_tagged(reg));
- bool act=(reg!=NULL && region_is_activity_r(reg) && !REGION_IS_ACTIVE(scr));
- bool sac=REGION_IS_ACTIVE(scr);
-
- if(tag || act){
- const char *n=region_displayname(reg);
- WInfoWin *iw;
-
- screen_windowinfo(scr, n);
-
- iw=(WInfoWin*)scr->infowin_watch.obj;
-
- if(iw!=NULL){
- GrStyleSpec *spec=infowin_stylespec(iw);
-
- init_attr();
-
- gr_stylespec_unalloc(spec);
-
- gr_stylespec_set(spec, GR_ATTR(selected));
- gr_stylespec_set(spec, GR_ATTR(not_dragged));
- gr_stylespec_set(spec, sac ? GR_ATTR(active) : GR_ATTR(inactive));
- gr_stylespec_set(spec, tag ? GR_ATTR(tagged) : GR_ATTR(not_tagged));
- gr_stylespec_set(spec, act ? GR_ATTR(activity) : GR_ATTR(no_activity));
- }
-
- }else{
- screen_nowindowinfo(scr);
- }
-}
-
-
-static void screen_managed_notify(WScreen *scr, WRegion *reg, WRegionNotify how)
-{
- if(how==ioncore_g.notifies.sub_activity){
- /* TODO: multiple calls */
- mainloop_defer_action((Obj*)scr,
- (WDeferredAction*)screen_notify_activity);
- }else if(how==ioncore_g.notifies.tag){
- mainloop_defer_action((Obj*)scr,
- (WDeferredAction*)screen_notify_tag);
- }
-}
-
-
-/*}}}*/
-
-
/*{{{ Misc. */
}
-static bool screen_managed_may_destroy(WScreen *scr, WRegion *reg)
+static WRegion *screen_managed_disposeroot(WScreen *scr, WRegion *reg)
{
- bool onmxlist=FALSE;
+ bool onmxlist=FALSE, others=FALSE;
WLListNode *lnode;
WLListIterTmp tmp;
-
- if(OBJ_IS(reg, WClientWin))
- return TRUE;
- FOR_ALL_NODES_ON_LLIST(lnode, scr->mplex.mx_list, tmp){
- if(lnode->st->reg==reg)
- onmxlist=TRUE;
- else /*if(OBJ_IS(node->reg, WGenWS))*/
- return TRUE;
+ if(OBJ_IS(reg, WGroupWS)){
+ FOR_ALL_NODES_ON_LLIST(lnode, scr->mplex.mx_list, tmp){
+ if(lnode->st->reg==reg){
+ onmxlist=TRUE;
+ }else if(OBJ_IS(lnode->st->reg, WGroupWS)){
+ others=TRUE;
+ break;
+ }
+ }
+
+ if(onmxlist && !others){
+ warn(TR("Only workspace may not be destroyed/detached."));
+ return NULL;
+ }
}
- if(!onmxlist)
- return TRUE;
-
- warn(TR("Only workspace may not be destroyed."));
-
- return FALSE;
+ return reg;
}
-static bool screen_may_destroy(WScreen *scr)
+static bool screen_may_dispose(WScreen *scr)
{
warn(TR("Screens may not be destroyed."));
return FALSE;
}
-WPHolder *screen_get_rescue_pholder_for(WScreen *scr, WRegion *mgd)
-{
-#warning "TODO: better special case handling for groups"
-
- return (WPHolder*)mplex_get_rescue_pholder_for(&(scr->mplex), mgd);
-}
-
/*}}}*/
{region_inactivated,
screen_inactivated},
- {(DynFun*)region_managed_may_destroy,
- (DynFun*)screen_managed_may_destroy},
+ {(DynFun*)region_managed_disposeroot,
+ (DynFun*)screen_managed_disposeroot},
- {(DynFun*)region_may_destroy,
- (DynFun*)screen_may_destroy},
+ {(DynFun*)region_may_dispose,
+ (DynFun*)screen_may_dispose},
{mplex_managed_changed,
screen_managed_changed},
{(DynFun*)region_fitrep,
(DynFun*)screen_fitrep},
- {(DynFun*)region_get_rescue_pholder_for,
- (DynFun*)screen_get_rescue_pholder_for},
-
END_DYNFUNTAB
};