662
* The actual meat of occupation-changing; [re-]set the occupation for
654
666
ChangeOccupation(TwmWindow *tmp_win, int newoccupation)
658
670
int oldoccupation;
660
671
int changedoccupation;
662
673
if((newoccupation == 0)
663
|| /* in case the property has been broken by another client */
664
(newoccupation == tmp_win->occupation)) {
674
|| (newoccupation == tmp_win->occupation)) {
676
* occupation=0 we interpret as "leave it alone". == current,
677
* ditto. Go ahead and re-set the WM_OCCUPATION property though,
678
* in case it's been broken by another client.
667
682
XWindowAttributes winattrs;
685
/* Mask out the PropertyChange events while we change the prop */
669
686
XGetWindowAttributes(dpy, tmp_win->w, &winattrs);
670
687
eventMask = winattrs.your_event_mask;
671
688
XSelectInput(dpy, tmp_win->w, eventMask & ~PropertyChangeMask);
678
695
EwmhSet_NET_WM_DESKTOP(tmp_win);
698
/* Reset event mask */
680
699
XSelectInput(dpy, tmp_win->w, eventMask);
704
* OK, there's something to change. Stash the current state.
683
706
oldoccupation = tmp_win->occupation;
709
* Add it to IconManager in the new WS[en], remove from old. We have
710
* to do the rather odd dance because AddIconManager() loops through
711
* workspaces, and will add it to any workspaces it occupies (even if
712
* it's already there). RemoveIconManager() goes over the window's
713
* list of what icon managers it's on and removes it from any that
714
* don't match the current occupation, so it can just be told "here's
715
* where I should be".
684
717
tmp_win->occupation = newoccupation & ~oldoccupation;
685
718
AddIconManager(tmp_win);
686
719
tmp_win->occupation = newoccupation;
687
720
RemoveIconManager(tmp_win);
722
/* If it shouldn't be "here", vanish it */
689
723
if(tmp_win->vs && !OCCUPY(tmp_win, tmp_win->vs->wsw->currentwspc)) {
690
724
Vanish(tmp_win->vs, tmp_win);
693
728
* Try to find an(other) virtual screen which shows a workspace
694
729
* where the window has occupation, so that the window can be shown
743
* Loop over workspaces. Find the first one that it used to be in.
744
* If it's not there anymore, take it out of the WindowRegion there
745
* (RWFR() silently returns if we're not using WindowRegion's), and
746
* add it the WindowRegion in the first WS it now occupies.
748
* XXX I'm not sure this is entirely sensible; it seems like just
749
* unconditionally Remove/Place'ing would have the same effect?
707
751
for(ws = Scr->workSpaceMgr.workSpaceList; ws != NULL; ws = ws->next) {
708
752
int mask = 1 << ws->number;
709
753
if(oldoccupation & mask) {
766
* Now set the WM_OCCUPATION property. As up at the beginning in the
767
* no-change branch, mask out the PropertyChange events while we do
770
* XXX I should abstract that out into a function...
722
775
XWindowAttributes winattrs;
724
778
XGetWindowAttributes(dpy, tmp_win->w, &winattrs);
725
779
eventMask = winattrs.your_event_mask;
726
780
XSelectInput(dpy, tmp_win->w, eventMask & ~PropertyChangeMask);
732
782
len = GetPropertyFromMask(newoccupation, &namelist);
733
783
XChangeProperty(dpy, tmp_win->w, XA_WM_OCCUPATION, XA_STRING, 8,
734
784
PropModeReplace, (unsigned char *) namelist, len);
739
EwmhSet_NET_WM_DESKTOP(tmp_win);
787
EwmhSet_NET_WM_DESKTOP(tmp_win);
741
XSelectInput(dpy, tmp_win->w, eventMask);
790
XSelectInput(dpy, tmp_win->w, eventMask);
795
* Handle showing it up in the workspace map in the appropriate
798
* Note that this whole block messes with the {new,old}occupation
799
* vars. That's "safe" because they're no longer used for their
800
* original purposes, only for the WSmap changes, but it's still
801
* kinda fugly. Change to local vars at the drop of a hat with later
743
804
if(!WMapWindowMayBeAdded(tmp_win)) {
805
/* Not showing in the map, so pretend it's nowhere */
744
806
newoccupation = 0;
746
808
if(Scr->workSpaceMgr.noshowoccupyall) {
747
/* We can safely change new/oldoccupation here, it's only used
748
* for WMapAddToList()/WMapRemoveFromList() from here on.
810
* Don't show OccupyAll. Note that this means both OccupyAll
811
* window, AND windows manually set to occupy everything. We
812
* don't have to adjust newoccupation, because the above
813
* conditional would have caught it, so we only need to edit old.
750
/* if (newoccupation == fullOccupation)
751
newoccupation = 0; */
752
815
if(oldoccupation == fullOccupation) {
753
816
oldoccupation = 0;
820
/* Flip the ones that need flipping */
756
821
changedoccupation = oldoccupation ^ newoccupation;
757
822
for(ws = Scr->workSpaceMgr.workSpaceList; ws != NULL; ws = ws->next) {
758
823
int mask = 1 << ws->number;
759
824
if(changedoccupation & mask) {
760
825
if(newoccupation & mask) {
761
827
WMapAddToList(tmp_win, ws);
831
* Remove from WS. We have to take it out of saved focus
832
* if it were there. Maybe there are other places we
833
* might need to remove it from (warpring?)?
764
835
WMapRemoveFromList(tmp_win, ws);
765
836
if(Scr->SaveWorkspaceFocus && ws->save_focus == tmp_win) {
766
837
ws->save_focus = NULL;
832
918
WMgrAddToCurrentWorkSpaceAndWarp(VirtualScreen *vs, char *winname)
835
921
int newoccupation;
923
/* Find named window on this screen */
837
924
for(tw = Scr->FirstWindow; tw != NULL; tw = tw->next) {
838
925
if(match(winname, tw->full_name)) {
930
/* Didn't find it by name? Try by class */
843
932
for(tw = Scr->FirstWindow; tw != NULL; tw = tw->next) {
844
933
if(match(winname, tw->class.res_name)) {
849
for(tw = Scr->FirstWindow; tw != NULL; tw = tw->next) {
850
if(match(winname, tw->class.res_class)) {
939
for(tw = Scr->FirstWindow; tw != NULL; tw = tw->next) {
940
if(match(winname, tw->class.res_class)) {
946
/* Still didn't find? Beep at the user and bail. */
952
/* If WarpUnmapped isn't set and this isn't mapped, beep and bail */
860
953
if((! Scr->WarpUnmapped) && (! tw->mapped)) {
958
/* Move it here if it's not */
864
959
if(! OCCUPY(tw, vs->wsw->currentwspc)) {
865
960
newoccupation = tw->occupation | (1 << vs->wsw->currentwspc->number);
866
961
ChangeOccupation(tw, newoccupation);
964
/* If we get here, WarpUnmapped is set, so map it if we need to */
869
965
if(! tw->mapped) {
872
970
WarpToWindow(tw, Scr->RaiseOnWarp);