Example #1
0
/** Callback to kill a client after a confirm dialog. */
void KillClientHandler(ClientNode *np)
{

   Assert(np);

   if(np == activeClient) {
      FocusNextStacked(np);
   }

   GrabServer();
   JXKillClient(display, np->window);
   JXSync(display, True);
   UngrabServer();

   RemoveClient(np);

}
Example #2
0
/** Handle an unmap notify event. */
void HandleUnmapNotify(const XUnmapEvent *event)
{
   ClientNode *np;
   XEvent e;

   Assert(event);

   if(event->window != event->event) {
      /* Allow ICCCM synthetic UnmapNotify events through. */
      if (event->event != rootWindow || !event->send_event) {
         return;
      }
   }

   np = FindClientByWindow(event->window);
   if(np) {

      /* Grab the server to prevent the client from destroying the
       * window after we check for a DestroyNotify. */
      GrabServer();

      if(np->controller) {
         (np->controller)(1);
      }

      if(JXCheckTypedWindowEvent(display, np->window, DestroyNotify, &e)) {
         UpdateTime(&e);
         RemoveClient(np);
      } else if((np->state.status & STAT_MAPPED) || event->send_event) {
         if(!(np->state.status & STAT_HIDDEN)) {
            np->state.status &= ~STAT_MAPPED;
            JXUngrabButton(display, AnyButton, AnyModifier, np->window);
            GravitateClient(np, 1);
            JXReparentWindow(display, np->window, rootWindow, np->x, np->y);
            WriteState(np);
            JXRemoveFromSaveSet(display, np->window);
            RemoveClient(np);
         }
      }
      UngrabServer();

   }
}
Example #3
0
/** Handle a map request. */
void HandleMapRequest(const XMapEvent *event)
{
   ClientNode *np;
   Assert(event);
   if(CheckSwallowMap(event->window)) {
      return;
   }
   np = FindClientByWindow(event->window);
   if(!np) {
      GrabServer();
      np = AddClientWindow(event->window, 0, 1);
      if(np) {
         if(!(np->state.status & STAT_NOFOCUS)) {
            FocusClient(np);
         }
      } else {
         JXMapWindow(display, event->window);
      }
      UngrabServer();
   } else {
      if(!(np->state.status & STAT_MAPPED)) {
         UpdateState(np);
         np->state.status |= STAT_MAPPED;
         XMapWindow(display, np->window);
         if(np->parent != None) {
            XMapWindow(display, np->parent);
         }
         if(!(np->state.status & STAT_STICKY)) {
            np->state.desktop = currentDesktop;
         }
         if(!(np->state.status & STAT_NOFOCUS)) {
            FocusClient(np);
            RaiseClient(np);
         }
         WriteState(np);
         RequireTaskUpdate();
         RequirePagerUpdate();
      }
   }
   RequireRestack();
}
Example #4
0
File: main.c Project: kuailexs/jwm
/** Startup the various JWM components.
 * This is called after the X connection is opened.
 */
void Startup(void)
{

   /* This order is important. */

   /* First we grab the server to prevent clients from changing things
    * while we're still loading. */
   GrabServer();

   StartupSettings();
   StartupScreens();

   StartupGroups();
   StartupColors();
   StartupIcons();
   StartupBackgrounds();
   StartupFonts();
   StartupCursors();

   StartupPager();
   StartupClock();
   StartupTaskBar();
   StartupTrayButtons();
   StartupDesktops();
   StartupHints();
   StartupDock();
   StartupTray();
   StartupKeys();
   StartupBorders();
   StartupPlacement();
   StartupClients();

#  ifndef DISABLE_CONFIRM
      StartupDialogs();
#  endif
   StartupPopup();

   StartupRootMenu();

   SetDefaultCursor(rootWindow);
   ReadCurrentDesktop();
   JXFlush(display);

   RequireRestack();

   /* Allow clients to do their thing. */
   JXSync(display, True);
   UngrabServer();

   StartupSwallow();

   DrawTray();

   /* Send expose events. */
   ExposeCurrentDesktop();

   /* Draw the background (if backgrounds are used). */
   LoadBackground(currentDesktop);

   /* Run any startup commands. */
   StartupCommands();

}
Example #5
0
File: main.c Project: kuailexs/jwm
/** Prepare the connection. */
void StartupConnection(void)
{

   XSetWindowAttributes attr;
#ifdef USE_SHAPE
   int shapeError;
#endif
#ifdef USE_XRENDER
   int renderEvent;
   int renderError;
#endif
   struct sigaction sa;
   char name[32];
   Window win;
   XEvent event;
   int revert;

   initializing = 1;
   OpenConnection();

#if 0
   XSynchronize(display, True);
#endif

   /* Create the supporting window used to verify JWM is running. */
   supportingWindow = JXCreateSimpleWindow(display, rootWindow,
                                           0, 0, 1, 1, 0, 0, 0);

   /* Get the atom used for the window manager selection. */
   snprintf(name, 32, "WM_S%d", rootScreen);
   managerSelection = JXInternAtom(display, name, False);

   /* Get the current window manager and take the selection. */
   GrabServer();
   win = JXGetSelectionOwner(display, managerSelection);
   if(win != None) {
      JXSelectInput(display, win, StructureNotifyMask);
   }
   JXSetSelectionOwner(display, managerSelection,
                       supportingWindow, CurrentTime);
   UngrabServer();

   /* Wait for the current selection owner to give up the selection. */
   if(win != None) {
      /* Note that we need to wait for the current selection owner
       * to exit before we can expect to select SubstructureRedirectMask. */
      XIfEvent(display, &event, SelectionReleased, (XPointer)&win);
      JXSync(display, False);
   }

   event.xclient.display = display;
   event.xclient.type = ClientMessage;
   event.xclient.window = rootWindow;
   event.xclient.message_type = JXInternAtom(display, managerProperty, False);
   event.xclient.format = 32;
   event.xclient.data.l[0] = CurrentTime;
   event.xclient.data.l[1] = managerSelection;
   event.xclient.data.l[2] = supportingWindow;
   event.xclient.data.l[3] = 2;
   event.xclient.data.l[4] = 0;
   JXSendEvent(display, rootWindow, False, StructureNotifyMask, &event);
   JXSync(display, False);

   JXSetErrorHandler(ErrorHandler);

   clientContext = XUniqueContext();
   frameContext = XUniqueContext();

   /* Set the events we want for the root window.
    * Note that asking for SubstructureRedirect will fail
    * if another window manager is already running.
    */
   attr.event_mask
      = SubstructureRedirectMask
      | SubstructureNotifyMask
      | StructureNotifyMask
      | PropertyChangeMask
      | ColormapChangeMask
      | ButtonPressMask
      | ButtonReleaseMask
      | PointerMotionMask | PointerMotionHintMask;
   JXChangeWindowAttributes(display, rootWindow, CWEventMask, &attr);

   memset(&sa, 0, sizeof(sa));
   sa.sa_flags = 0;
   sa.sa_handler = HandleExit;
   sigaction(SIGTERM, &sa, NULL);
   sigaction(SIGINT, &sa, NULL);
   sigaction(SIGHUP, &sa, NULL);

   sa.sa_flags = SA_NOCLDWAIT;
   sa.sa_handler = SIG_DFL;
   sigaction(SIGCHLD, &sa, NULL);

#ifdef USE_SHAPE
   haveShape = JXShapeQueryExtension(display, &shapeEvent, &shapeError);
   if (haveShape) {
      Debug("shape extension enabled");
   } else {
      Debug("shape extension disabled");
   }
#endif

#ifdef USE_XRENDER
   haveRender = JXRenderQueryExtension(display, &renderEvent, &renderError);
   if(haveRender) {
      Debug("render extension enabled");
   } else {
      Debug("render extension disabled");
   }
#endif

   /* Make sure we have input focus. */
   win = None;
   JXGetInputFocus(display, &win, &revert);
   if(win == None) {
      JXSetInputFocus(display, rootWindow, RevertToParent, CurrentTime);
   }

   initializing = 0;

}
Example #6
0
void SetWSBackground()
{
  unsigned char back_changed= 0;
  
  if(TheScreen.BackPixmap[TheScreen.desktop.ActiveWorkSpace]!=None)
    {
      /* To set the root pixmap and properties pointing to it XGrabServer
	 must be called to make sure that we don't leak the pixmap if
	 somebody else is setting it at the same time. */
      /* use our private wraparound GrabServer instead! */
      GrabServer (disp);
      
      /* ++++++++++++++++  FIXME ++++++++++++++++++++++++++ 
	 Is necessary in this case to kill the old pixmap or will it
	 destroy the pixmaps in the TheScreen.BackPixmap array ???
	 This is how i suppouse the pixmap is removed : */
/* comment by arc: this seems too agressive to me, if the user starts a 
   program setting this property he probably knows what he is doing.
   we definitely shouldn't kill clients without user interaction! */
/*
      XGetWindowProperty (disp, TheScreen.root,
			  XIntermAtom ("ESETROOT_PMAP_ID", FALSE),
			  0L, 1L, False, XA_PIXMAP,
			  &type, &format, &nitems, &bytes_after,
			  &data_esetroot);
      
      if (type == XA_PIXMAP) {
	if (format == 32 && nitems == 4)
	  XKillClient(disp, *((Pixmap*)data_esetroot));
	XFree (data_esetroot);
      }
*/    
	 
      /* Some aplications, like transparent terminals, need this properties
	 to be set to get and update the background pixmap */
      XChangeProperty (disp, TheScreen.root,
		       XInternAtom (disp, "ESETROOT_PMAP_ID", 0), XA_PIXMAP,
		       32, PropModeReplace,
		       (unsigned char *) \
		       &(TheScreen.BackPixmap[TheScreen.desktop.ActiveWorkSpace]),
		       1);
      XChangeProperty (disp, TheScreen.root,
		       XInternAtom (disp, "_XROOTPMAP_ID", 0), XA_PIXMAP,
		       32, PropModeReplace,
		       (unsigned char *) \
		       &(TheScreen.BackPixmap[TheScreen.desktop.ActiveWorkSpace]),
		       1);
      XSetWindowBackgroundPixmap(disp,TheScreen.root,
				 TheScreen.BackPixmap\
				 [TheScreen.desktop.ActiveWorkSpace]);
      
      back_changed= 1;
      UngrabServer (disp);
      XFlush (disp);
    }
  else if (TheScreen.SetBackground [TheScreen.desktop.ActiveWorkSpace])
    {
      XSetWindowBackground(disp,TheScreen.root,
			   TheScreen.Background\
                           [TheScreen.desktop.ActiveWorkSpace]);
      back_changed= 1;
    }
  if (back_changed)
    XClearWindow(disp,TheScreen.root);

  if(ScreenCommandPID>0){              /* terminate previous ScreenCommand */
    kill(ScreenCommandPID,SIGTERM);
    ScreenCommandPID=0;
  }
  if(TheScreen.BackCommand[TheScreen.desktop.ActiveWorkSpace])
    ScreenCommandPID=MySystem(TheScreen.BackCommand
                              [TheScreen.desktop.ActiveWorkSpace]);
  else ScreenCommandPID=0;
}