Esempio n. 1
0
void KWM::close(Window w){
  static Atom a = 0;
  if (!a)
    a = XInternAtom(qt_xdisplay(), "WM_DELETE_WINDOW", False);
  static Atom ap = 0;
  if (!ap)
    ap = XInternAtom(qt_xdisplay(), "WM_PROTOCOLS", False);

  // clients with WM_DELETE_WINDOW protocol set are
  // closed via wm_delete_window ClientMessage.
  // Others are destroyed.
  Atom *p;
  int i,n;
  if (XGetWMProtocols(qt_xdisplay(), w, &p, &n)){
    for (i = 0; i < n; i++){
      if (p[i] == a){
	sendClientMessage(w, ap, a);
	XFree((char*)p);
	return;
      }
    }
    if (n>0)
      XFree(p);
  }
  // client will not react on wm_delete_window. We have no choice
  // but destroy his connection to the XServer.
  XKillClient(qt_xdisplay(), w);
}
Esempio n. 2
0
void KWM::setKWMDockModule(Window w){
  static Atom a = 0;
  if (!a)
    a = XInternAtom(qt_xdisplay(), "KWM_MODULE", False);
  setSimpleProperty(w, a, 2);
  sendClientMessage(qt_xrootwin(), a, (long) w);
}
static void sendDrop(Window target, Window source, Time timestamp)
{
  long data[5]= { 0, 0, 0, 0, 0 };
  data[2]= timestamp;
  fdebugf((stderr, "Send XdndDrop (output) source: 0x%lx target: 0x%lx\n", source, target));

  sendClientMessage(data, source, target, XdndDrop);
}
static void sendPosition(Window target, Window source, int rootX, int rootY, Time timestamp)
{
  long data[5]= { 0, 0, 0, 0, 0 };
  data[2]= (rootX << 16) | rootY;
  data[3]= timestamp;
  data[4]= XdndActionCopy;
  sendClientMessage(data, source, target, XdndPosition);
}
bool windowMenuCB(void *p,void* ud)
{
	menuItemStruct	*menu=(menuItemStruct*)ud;
	Window			winid=0;
	unsigned long	desktop=0;

	if(menu==NULL)
		return(true);
	winid=(Window)(menu->userData);
	desktop=(unsigned long)menu->subMenuCnt;
	possibleError="Can't switch desktop";
	sendClientMessage(mainwind->rootWindow,"_NET_CURRENT_DESKTOP",desktop,0,0,0,0);
	possibleError="Can't activate window";
	sendClientMessage(winid,"_NET_ACTIVE_WINDOW",0,0,0,0,0);
	updateWindowCnt=WINDOWREFRESH+100;
	updateWindowMenu();
	return(true);
}
Esempio n. 6
0
string
CwmTcl::
sendClientMessage(const string &name, int argc, const char **argv)
{
  string msg = name;

  for (int i = 1; i < argc; ++i)
    msg += " " + string(argv[i]);

  return sendClientMessage(msg);
}
bool windowDeskMenuCB(void *p,void* ud)
{
	menuItemStruct	*menu=(menuItemStruct*)ud;
	Window			winid=0;
	unsigned long	desktop=0;

	if(menu==NULL)
		return(true);
	winid=(Window)(menu->userData);
	possibleError="Can't activate window";
	sendClientMessage(winid,"_NET_ACTIVE_WINDOW",0,0,0,0,0);
	return(true);
}
Esempio n. 8
0
void sendUpdateInfo(Atom what)
{
    unsigned int i, nrootwins;
    Window dw1, dw2, *rootwins = 0;
    int screen_count = ScreenCount(fl_display);
    for (int s = 0; s < screen_count; s++) {
        Window root = RootWindow(fl_display, s);
        XQueryTree(fl_display, root, &dw1, &dw2, &rootwins, &nrootwins);
        for (i = 0; i < nrootwins; i++) {
            if (rootwins[i]!=RootWindow(fl_display, fl_screen)) {
                sendClientMessage(rootwins[i], what, 0);
            }
        }
    }
}
Esempio n. 9
0
void sendUpdateInfo() 
{
    unsigned int i, nrootwins;
    Window dw1, dw2, *rootwins = 0;
    int screen_count = ScreenCount(fl_display);
    extern Atom FLTKChangeSettings;
    for (int s = 0; s < screen_count; s++) {
        Window root = RootWindow(fl_display, s);
        XQueryTree(fl_display, root, &dw1, &dw2, &rootwins, &nrootwins);
        for (i = 0; i < nrootwins; i++) {
            if (rootwins[i]!=RootWindow(fl_display, fl_screen)) {
                sendClientMessage(rootwins[i], FLTKChangeSettings, 0);
            }
        }
    }
    XFlush(fl_display);
}
Esempio n. 10
0
bool openspy_mod_query(char *sendmodule, void *data,int len) {
	qrServerMsg *msg = (qrServerMsg *)data;
	qrServerList *listData;
	qrServerRules *rulesData;
	qrClientMsg *cmsg;
	switch(msg->msgID) {
		case EQRMsgID_GetServer:
			listData = (qrServerList *)msg->data;
			return findMatchingServers(listData,sendmodule);
		case EQRMsgID_GetServerRules:
			rulesData = (qrServerRules *)msg->data;
			findMatchingServers_GetRules(rulesData,sendmodule);
			return true;
		case EQRMsgID_ClientMessage:
			cmsg = (qrClientMsg *)msg->data;
			sendClientMessage(cmsg);
			return true;
	}
	return false;
}
static void sendEnter(Window target, Window source)
{
  long data[5]= { 0, 0, 0, 0, 0 };
  data[1] |= 0x0UL; /* just three data types */
  data[1] |= XdndVersion << 24; /* version num */

  if (0 != xdndOutTypes)
    {
      data[2]= xdndOutTypes[0];
      if (None != xdndOutTypes[1])
	{
	  data[3]= xdndOutTypes[1];
	  if (None != xdndOutTypes[2])
	    {
	      data[4]= xdndOutTypes[1];
	    }
	}
    }
  fdebugf((stderr, "Send XdndEnter (output) source: 0x%lx target: 0x%lx\n", source, target));
  sendClientMessage(data, source, target, XdndEnter);
}
/* Send a XdndSqueakLaunchAck essage back to the launch dropper if the filename
 * matches a dndInLaunchDrop event.
 */
static sqInt
display_dndReceived(char *fileName)
{
	int i;

	for (i = 0; i < numLaunchDrops; i++)
		if (launchDrops[i].fileName
		 && !strcmp(fileName, launchDrops[i].fileName)) {
			long data[5];
			memset(data, 0, sizeof(data));
			data[0] = stParent;
			sendClientMessage(data,
					  stParent,
					  launchDrops[i].sourceWindow,
					  XdndSqueakLaunchAck);
			XFree(launchDrops[i].fileName);
			launchDrops[i].fileName = 0;
			return 0;
		}
	return 1;
}
Esempio n. 13
0
void KWM::setWindowRegion(int desk, const QRect &region){
  static Atom a[32] = {0,0,0,0,0,0,0,0,
		       0,0,0,0,0,0,0,0,
		       0,0,0,0,0,0,0,0,
		       0,0,0,0,0,0,0,0};
  static Atom ac = 0;
  if (desk < 1 || desk > 32){
    kwm_error = TRUE;
    return;
  }
  if (!a[desk-1]){
    QString n;
    n.setNum(desk);
    n.prepend("KWM_WINDOW_REGION_");
    a[desk-1] = XInternAtom(qt_xdisplay(), n.data(), False);
  }
  setQRectProperty(qt_xrootwin(), a[desk-1], region);
  if (!ac)
      ac = XInternAtom(qt_xdisplay(), "KWM_WINDOW_REGION_CHANGED", False);
  sendClientMessage(qt_xrootwin(), ac, (long) desk); // inform the window manager
}
/* If the VM is running as a single instance and there is a pre-existing
 * instance then look for a pre-existing instance and if found send it a
 * drop event of the argument and if successful exit.  Otherwise return
 * and allow the normal start-up sequence to continue.
 */
static int
dndLaunchFile(char *filename)
{
	long data[5];
	char abspath[MAXPATHLEN+1];
	struct timeval start, now, timeout;
	time_t tnow;
	int pid = getpid();
	Window target;

	tnow = time(0);
	printf("dndLaunchFile(%s,%d) \"%s\" %s", filename, pid, defaultWindowLabel, ctime(&tnow));
	target = findWindowWithLabel(DefaultRootWindow(stDisplay), defaultWindowLabel);

	if (!target) {
		tnow = time(0);
		printf("dndLaunchFile(%s,%d) %s\tFAILED TO FIND WINDOW:\"%s\"\n", filename, pid, ctime(&tnow), defaultWindowLabel);
		return 0;
	}

	if (*filename == '/')
		strcpy(abspath,filename);
	else {
		/* For consistency with drops files should be relative to the image.
		 * For sanity creating streams drops should be absolute paths (i.e.
		 * primDropRequestFileHandle: doesn't know what the image path is and
		 * so interprets things relative to pwd, so give it an absolute path).
		 * So by default make the full path by prepending the image.
		 */
#if !defined(DROP_FILENAMES_RELATIVE_TO_PWD)
# define DROP_FILENAMES_RELATIVE_TO_PWD 0
#endif
#if DROP_FILENAMES_RELATIVE_TO_PWD
		getcwd(abspath,sizeof(abspath));
		abspath[strlen(abspath)] = '/';
		strcat(abspath,filename);
#else
		strcpy(abspath,imageName);
		strcpy(strrchr(abspath,'/')+1,filename);
#endif
	}

	/* Only drop if the file exists. */
    if (access(abspath, F_OK|R_OK)) {
		tnow = time(0);
		printf("dndLaunchFile(%s,%d) %s\tFAILED TO VALIDATE:\"%s\"\n", filename, pid, ctime(&tnow), abspath);
		return 0;
	}

	tnow = time(0);
	printf("dndLaunchFile(%s,%d) %s\tvalidated:\"%s\"\n", filename, pid, ctime(&tnow), abspath);

	/* Include the null in the filename so that we're immune to XGetWindowProp'
	 * answering the size in 32-bit units.
	 */
	XChangeProperty(stDisplay, stParent,
			XdndSqueakLaunchDrop, XA_ATOM, 8, PropModeReplace,
			(unsigned char *)abspath, strlen(abspath) + 1);

	memset(data, 0, sizeof(data));
	data[0] = stParent; /* => xdndDrop_sourceWindow */
	sendClientMessage(data, stParent, target, XdndSqueakLaunchDrop);

	/* How can there be 10 odd get event functions and yet none provide
	 * peek with timeout functionality?  X is sad.
	 */
	timeout.tv_sec = launchDropTimeoutMsecs / 1000;
	timeout.tv_usec = (launchDropTimeoutMsecs % 1000) * 1000;
	gettimeofday(&start, 0);
	timeradd(&start, &timeout, &timeout);

	do {
		XEvent evt;
		/* Don't spin hard; the dnd recipient needs cycles to receive and ack. */
		yieldCyclesToRecipient();
		if (XCheckIfEvent(stDisplay, &evt, isDropAck, 0)) {
			tnow = time(0);
			printf("dndLaunchFile(%s,%d) %s\tgot drop ack for:\"%s\"\n", filename, pid, ctime(&tnow), abspath);
			return 1;
		}
		gettimeofday(&now, 0);
	}
	while (timercmp(&now, &timeout, <));
	tnow = time(0);
	printf("dndLaunchFile(%s,%d) %s\t%ld msec DROP TIMEOUT FOR:\"%s\"\n", filename, pid, ctime(&tnow), launchDropTimeoutMsecs, abspath);
	return 0;
}
Esempio n. 15
0
void KWM::activateInternal(Window w){
  static Atom a = 0;
  if (!a)
    a = XInternAtom(qt_xdisplay(), "KWM_ACTIVATE_WINDOW", False);
  sendClientMessage(qt_xrootwin(), a, (long) w);
}
static void sendLeave(Window target, Window source)
{
  long data[5]= { 0, 0, 0, 0, 0 };
  fdebugf((stderr, "Send XdndLeave (output) source: 0x%lx target: 0x%lx\n", source, target));
  sendClientMessage(data, source, target, XdndLeave);
}
Esempio n. 17
0
void
clientSetFocus (ScreenInfo *screen_info, Client *c, guint32 timestamp, unsigned short flags)
{
    Client *c2;

    TRACE ("entering");

    c2 = NULL;
    if ((c) && !(flags & FOCUS_IGNORE_MODAL))
    {
        c2 = clientGetModalFor (c);

        if (c2)
        {
            c = c2;
        }
    }
    c2 = ((client_focus != c) ? client_focus : NULL);
    if ((c) && FLAG_TEST (c->xfwm_flags, XFWM_FLAG_VISIBLE))
    {
        TRACE ("setting focus to client \"%s\" (0x%lx) with timestamp %u", c->name, c->window, (unsigned int) timestamp);
        user_focus = c;
        if (FLAG_TEST(c->flags, CLIENT_FLAG_DEMANDS_ATTENTION))
        {
            TRACE ("un-setting WM_STATE_DEMANDS_ATTENTION flag on \"%s\" (0x%lx)", c->name, c->window);
            FLAG_UNSET (c->flags, CLIENT_FLAG_DEMANDS_ATTENTION);
            clientSetNetState (c);
        }
        if ((c == client_focus) && !(flags & FOCUS_FORCE))
        {
            TRACE ("client \"%s\" (0x%lx) is already focused, ignoring request", c->name, c->window);
            return;
        }
        if (!clientAcceptFocus (c))
        {
            TRACE ("SKIP_FOCUS set for client \"%s\" (0x%lx)", c->name, c->window);
            return;
        }
        if (FLAG_TEST (c->wm_flags, WM_FLAG_INPUT) || !(screen_info->params->focus_hint))
        {
            pending_focus = c;
            /*
             * When shaded, the client window is unmapped, so it can not be focused.
             * Instead, we focus the frame that is still mapped.
             */
            if (FLAG_TEST (c->flags, CLIENT_FLAG_SHADED))
            {
                XSetInputFocus (myScreenGetXDisplay (screen_info), c->frame, RevertToPointerRoot, timestamp);
            }
            else
            {
                XSetInputFocus (myScreenGetXDisplay (screen_info), c->window, RevertToPointerRoot, timestamp);
            }
        }
        else if (flags & FOCUS_TRANSITION)
        {
            /*
             * If we are relying only on the client application to take focus, we need to set the focus
             * explicitely on our own fallback window otherwise there is a race condition between the
             * application and the window manager. If the application does not take focus before the
             * the previously focused window is unmapped (when iconifying or closing for example), the focus
             * will be reverted to the root window and focus transition will fail.
             */
            clientFocusNone (screen_info, c2, timestamp);
        }

        if (FLAG_TEST(c->wm_flags, WM_FLAG_TAKEFOCUS))
        {
            pending_focus = c;
            sendClientMessage (c->screen_info, c->window, WM_TAKE_FOCUS, timestamp);
        }
    }
    else
    {
        TRACE ("setting focus to none");

        client_focus = NULL;
        clientFocusNone (screen_info, c2, timestamp);
        clientClearDelayedFocus ();
    }
}