Exemple #1
0
static int
EventsProcess(XEvent ** evq_p, int *evq_n, int *evq_f)
{
   int                 i, n, count;
   XEvent             *evq;

   /* Fetch the entire event queue */
   n = EventsFetch(evq_p, evq_n);
   evq = *evq_p;

   if (EDebug(EDBUG_TYPE_EVENTS))
      Eprintf("EventsProcess-B %d\n", n);

   for (i = count = 0; i < n; i++)
     {
	if (evq[i].type == 0)
	   continue;

	if (EDebug(EDBUG_TYPE_EVENTS) > 1)
	   EventShow(evq + i);

	count++;
	HandleEvent(evq + i);
	evq[i].type = 0;
     }

   if (EDebug(EDBUG_TYPE_EVENTS))
      Eprintf("EventsProcess-E %d/%d\n", count, n);

   if (n > *evq_f)
      *evq_f = n;

   return count;
}
Exemple #2
0
static void
ClickGrabsSet(EWin * ewin)
{
   int                 set = 0;

   if ((Conf.focus.clickraises && !EwinListStackIsRaised(ewin)) ||
       (!ewin->state.active && !ewin->state.inhibit_focus))
      set = 1;

   if (set)
     {
	if (!ewin->state.click_grab_isset)
	  {
	     GrabButtonSet(AnyButton, AnyModifier, EwinGetClientConWin(ewin),
			   ButtonPressMask, ECSR_PGRAB, 1);
	     if (EDebug(EDBUG_TYPE_GRABS))
		Eprintf("%s: %#x set %s\n", __func__,
			EwinGetClientXwin(ewin), EwinGetTitle(ewin));
	     ewin->state.click_grab_isset = 1;
	  }
     }
   else
     {
	if (ewin->state.click_grab_isset)
	  {
	     GrabButtonRelease(AnyButton, AnyModifier,
			       EwinGetClientConWin(ewin));
	     if (EDebug(EDBUG_TYPE_GRABS))
		Eprintf("%s: %#x unset %s\n", __func__,
			EwinGetClientXwin(ewin), EwinGetTitle(ewin));
	     ewin->state.click_grab_isset = 0;
	  }
     }
}
Exemple #3
0
Window
ExtInitWinCreate(void)
{
   Ecore_X_Window      win_ex;	/* Hmmm.. */
   Window              win;
   Atom                a;

   if (EDebug(EDBUG_TYPE_SESSION))
      Eprintf("ExtInitWinCreate\n");

   a = EInternAtom("ENLIGHTENMENT_RESTART_SCREEN");
   ESync(0);

   if (fork())
     {
	/* Parent */
	EUngrabServer();

	for (;;)
	  {
	     if (EDebug(EDBUG_TYPE_SESSION))
		Eprintf("ExtInitWinCreate - parent\n");

	     /* Hack to give the child some space. Not foolproof. */
	     sleep(1);

	     if (ecore_x_window_prop_window_get
		 (WinGetXwin(VROOT), a, &win_ex, 1) > 0)
		break;
	  }

	win = win_ex;
	if (EDebug(EDBUG_TYPE_SESSION))
	   Eprintf("ExtInitWinCreate - parent - %#lx\n", win);

	return win;
     }

   /* Child - Create the init window */

   if (EDebug(EDBUG_TYPE_SESSION))
      Eprintf("ExtInitWinCreate - child\n");

   /* Clean up inherited stuff */

   SignalsRestore();

   EImageExit(0);
   EDisplayDisconnect();

   ExtInitWinMain();

   /* We will never get here */
   return None;
}
Exemple #4
0
void
FocusHandleEnter(EWin * ewin, XEvent * ev)
{
   Mode.mouse_over_ewin = ewin;

#if 0				/* FIXME - Remove? */
   if (ev->xcrossing.mode == NotifyUngrab &&
       ev->xcrossing.detail == NotifyNonlinearVirtual)
     {
	if (EDebug(1))
	   Eprintf("%s: Previously ignored: focused: %s, enter: %s\n", __func__,
		   EoGetNameSafe(Mode.focuswin), EoGetNameSafe(ewin));
     }
#endif

   if ((int)ev->xcrossing.serial - focus_request < 0)
     {
	/* This event was caused by a request older than the latest
	 * focus assignment request - ignore */
	if (EDebug(EDBUG_TYPE_FOCUS))
	   Eprintf("%s: Ignore serial < %#x\n", __func__, focus_request);
	return;
     }

   if (!ewin)
     {
	/* Entering root may mean entering this screen */
	FocusToEWin(NULL, FOCUS_DESK_ENTER);
	return;
     }

   switch (Conf.focus.mode)
     {
     default:
     case MODE_FOCUS_CLICK:
	break;
     case MODE_FOCUS_SLOPPY:
	if (FocusEwinValid(ewin, 1, 0, 0))
	   FocusToEWin(ewin, FOCUS_ENTER);
	break;
     case MODE_FOCUS_POINTER:
	if (FocusEwinValid(ewin, 1, 0, 0))
	   FocusToEWin(ewin, FOCUS_ENTER);
	else
	   FocusToEWin(NULL, FOCUS_NONE);
	break;
     }
}
Exemple #5
0
static void
callback_save_complete(SmcConn smc_conn __UNUSED__,
		       SmPointer client_data __UNUSED__)
{
   if (EDebug(EDBUG_TYPE_SESSION))
      Eprintf("callback_save_complete\n");
}
Exemple #6
0
static void
ExtInitInput(int available)
{
   int                 i, j, nd;
   XDeviceInfo        *dvi, *dvis;
   char               *p;

   if (!available)
      return;

   if (!EDebug(EDBUG_TYPE_VERBOSE))
      return;

   dvis = XListInputDevices(disp, &nd);
   Eprintf("Dev  id nc use name\n");
   for (i = 0; i < nd; i++)
     {
	dvi = dvis + i;
	Eprintf(" %2d %#3lx  %d  %d %-32s", i,
		dvi->id, dvi->num_classes, dvi->use, dvi->name);
	p = (char *)dvi->inputclassinfo;
	for (j = 0; j < dvi->num_classes; j++)
	  {
	     XAnyClassPtr        pcany = (XAnyClassPtr) p;

	     printf("  %#3lx %3d", pcany->class, pcany->length);
	     p += pcany->length;
	  }
	printf("\n");

     }
   XFreeDeviceList(dvis);
}
Exemple #7
0
int
GrabPointerSet(Win win, unsigned int csr, int confine __UNUSED__)
{
   int                 rc;

#if USE_XI2
   EXIEventMask        em;

   EXIMaskSetup(&em, DEV_PTR,
		ButtonPressMask | ButtonReleaseMask | PointerMotionMask);
   rc = XIGrabDevice(disp, DEV_PTR, WinGetXwin(win), CurrentTime, ECsrGet(csr),
		     GrabModeAsync, GrabModeAsync, False, &em.em);
#else
   EX_Window           confine_to = (confine) ? WinGetXwin(VROOT) : NoXID;

   rc = XGrabPointer(disp, WinGetXwin(win), False,
		     ButtonPressMask | ButtonReleaseMask | PointerMotionMask |
		     ButtonMotionMask | EnterWindowMask | LeaveWindowMask,
		     GrabModeAsync, GrabModeAsync, confine_to, ECsrGet(csr),
		     CurrentTime);
#endif

   Mode.grabs.pointer_grab_window = WinGetXwin(win);
   Mode.grabs.pointer_grab_active = 1;

   if (EDebug(EDBUG_TYPE_GRABS))
      Eprintf("%s: %#x, rc=%d\n", __func__, Mode.grabs.pointer_grab_window, rc);

   return rc;
}
Exemple #8
0
void
EExit(int exitcode)
{
    int                 i;

    if (EDebug(EDBUG_TYPE_SESSION))
        Eprintf("%s: %d\n", __func__, exitcode);

    if (disp)
    {
        EUngrabServer();
        GrabPointerRelease();
        XAllowEvents(disp, AsyncBoth, CurrentTime);

        /* XSetInputFocus(disp, NoXID, RevertToParent, CurrentTime); */
        /* I think this is a better way to release the grabs: (felix) */
        XSetInputFocus(disp, PointerRoot, RevertToPointerRoot, CurrentTime);
        ESelectInput(VROOT, 0);
        EDisplayClose();
    }

    if (Mode.wm.master)
    {
        for (i = 0; i < Mode.wm.child_count; i++)
            kill(Mode.wm.children[i], SIGINT);
    }
    else
    {
        exitcode = 0;
    }

    exit(exitcode);
}
Exemple #9
0
Fichier : x.c Projet : Limsik/e17
void
EventCallbacksProcess(Win win, XEvent * ev)
{
   EventCallbackList  *ecl;
   EventCallbackItem  *eci;
   int                 i;

   if (!win)
      return;

   win->in_use = 1;
   ecl = &win->cbl;
   eci = ecl->lst;
   for (i = 0; i < ecl->num; i++, eci++)
     {
	if (EDebug(EDBUG_TYPE_DISPATCH))
	   Eprintf("EventDispatch: type=%d win=%#lx func=%p prm=%p\n",
		   ev->type, ev->xany.window, eci->func, eci->prm);
	eci->func(win, ev, eci->prm);
	if (win->do_del)
	  {
	     EXidDestroy(win);
	     return;
	  }
     }
   win->in_use = 0;
}
Exemple #10
0
static void
ExtQuery(const EServerExt * ext)
{
   int                 available;
   EServerExtData     *exd = ExtData + ext->ix;

   available = XQueryExtension(disp, ext->name, &(exd->major_op),
			       &(exd->event_base), &(exd->error_base));

   if (available)
     {
	Mode.server.extensions |= 1 << ext->ix;

	ext->query_ver(disp, &(exd->major), &(exd->minor));

	if (EDebug(EDBUG_TYPE_VERBOSE))
	   Eprintf("Extension %-15s version %d.%d -"
		   " req/evt/err base = %3d/%3d/%3d\n", ext->name,
		   exd->major, exd->minor,
		   exd->major_op, exd->event_base, exd->error_base);
     }

   if (ext->init)
      ext->init(available);
}
Exemple #11
0
static void
ExtInitSync(int available)
{
   int                 i, num;
   XSyncSystemCounter *xssc;

   if (!available)
      return;

   xssc = XSyncListSystemCounters(disp, &num);
   for (i = 0; i < num; i++)
     {
	if (!strcmp(xssc[i].name, "SERVERTIME"))
	   Mode.display.server_time = xssc[i].counter;
	if (EDebug(EDBUG_TYPE_VERBOSE))
	   Eprintf(" Sync counter %2d: %10s %#lx %#x:%#x\n", i,
		   xssc[i].name, xssc[i].counter,
		   XSyncValueHigh32(xssc[i].resolution),
		   XSyncValueLow32(xssc[i].resolution));
     }
   XSyncFreeSystemCounterList(xssc);

   if (Mode.display.server_time == None)
      Conf.movres.enable_sync_request = 0;
}
Exemple #12
0
static void
callback_die(SmcConn smc_conn __UNUSED__, SmPointer client_data __UNUSED__)
{
   if (EDebug(EDBUG_TYPE_SESSION))
      Eprintf("callback_die\n");

   SessionExit(EEXIT_EXIT, NULL);
}
Exemple #13
0
static void
callback_shutdown_cancelled(SmcConn smc_conn, SmPointer client_data __UNUSED__)
{
   if (EDebug(EDBUG_TYPE_SESSION))
      Eprintf("callback_shutdown_cancelled\n");

   SmcSaveYourselfDone(smc_conn, False);
}
Exemple #14
0
static void
ice_io_error_handler(IceConn connection __UNUSED__)
{
   if (EDebug(EDBUG_TYPE_SESSION))
      Eprintf("ice_io_error_handler\n");

   /* The less we do here the better - the default handler does an
    * exit(1) instead of closing the losing connection. */
}
Exemple #15
0
static void
callback_save_yourself(SmcConn smc_conn, SmPointer client_data __UNUSED__,
		       int save_style __UNUSED__, Bool shutdown __UNUSED__,
		       int interact_style __UNUSED__, Bool fast __UNUSED__)
{
   if (EDebug(EDBUG_TYPE_SESSION))
      Eprintf("callback_save_yourself\n");

   SmcRequestSaveYourselfPhase2(smc_conn, callback_save_yourself2, NULL);
}
Exemple #16
0
static void
ExtInitRR(int available)
{
   Rotation            rot;

   if (!available)
      return;

   /* Listen for RandR events */
   XRRSelectInput(disp, WinGetXwin(VROOT), RRScreenChangeNotifyMask);
   XRRRotations(disp, Dpy.screen, &rot);
   Mode.screen.rotation = rot;

#if 0				/* Debug */
   if (EDebug(EDBUG_TYPE_VERBOSE))
     {
	XRRScreenResources *psr;
	XRRCrtcInfo        *pci;
	XRROutputInfo      *poi;
	int                 i;

	psr = XRRGetScreenResources(disp, WinGetXwin(VROOT));
	if (!psr)
	   return;

	Eprintf("CRTC  ID      X,Y         WxH     mode   rot   nout\n");
	for (i = 0; i < psr->ncrtc; i++)
	  {
	     pci = XRRGetCrtcInfo(disp, psr, psr->crtcs[i]);
	     if (!pci)
		break;
	     Eprintf("%3d  %#04lx  %4d,%4d   %4ux%4u  %#04lx %4d %5d\n",
		     i, psr->crtcs[i],
		     pci->x, pci->y, pci->width, pci->height,
		     pci->mode, pci->rotation, pci->noutput);
	     XRRFreeCrtcInfo(pci);
	  }

	Eprintf("OUTP  ID  Name            WxH     crtc  ncrtc nclon nmode\n");
	for (i = 0; i < psr->noutput; i++)
	  {
	     poi = XRRGetOutputInfo(disp, psr, psr->outputs[i]);
	     if (!poi)
		break;
	     Eprintf("%3d  %#04lx %-8s     %4lux%4lu  %#04lx %4d %5d %5d\n",
		     i, psr->outputs[i],
		     poi->name, poi->mm_width, poi->mm_height,
		     poi->crtc, poi->ncrtc, poi->nclone, poi->nmode);
	     XRRFreeOutputInfo(poi);
	  }

	XRRFreeScreenResources(psr);
     }
#endif
}
Exemple #17
0
void
ExtInitWinKill(void)
{
   if (!disp || init_win_ext == None)
      return;

   if (EDebug(EDBUG_TYPE_SESSION))
      Eprintf("Kill init window %#lx\n", init_win_ext);
   XUnmapWindow(disp, init_win_ext);
   init_win_ext = None;
}
void
GrabPointerRelease(void)
{
   XUngrabPointer(disp, CurrentTime);

   if (EDebug(EDBUG_TYPE_GRABS))
      Eprintf("GrabPointerRelease: %#lx\n", Mode.grabs.pointer_grab_window);

   Mode.grabs.pointer_grab_active = 0;
   Mode.grabs.pointer_grab_window = None;
}
Exemple #19
0
/* This function is usually exclusively devoted to saving data.
 * However, E sometimes wants to save state and exit immediately afterwards
 * so that the SM will restart it in a different theme. Therefore, we include
 * a suicide clause at the end.
 */
static void
callback_save_yourself2(SmcConn smc_conn, SmPointer client_data __UNUSED__)
{
   if (EDebug(EDBUG_TYPE_SESSION))
      Eprintf("callback_save_yourself2\n");

   set_save_props(smc_conn, Mode.wm.master);
   SmcSaveYourselfDone(smc_conn, True);
   if (restarting)
      EExit(0);
}
Exemple #20
0
void
ExtInitWinKill(void)
{
   if (!disp || init_win_ext == NoXID)
      return;

   if (EDebug(EDBUG_TYPE_SESSION))
      Eprintf("%s: %#x\n", __func__, init_win_ext);
   XUnmapWindow(disp, init_win_ext);
   init_win_ext = NoXID;
}
Exemple #21
0
void
GrabPointerRelease(void)
{
#if USE_XI2
   XIUngrabDevice(disp, DEV_PTR, CurrentTime);
#else
   XUngrabPointer(disp, CurrentTime);
#endif

   if (EDebug(EDBUG_TYPE_GRABS))
      Eprintf("%s: %#x\n", __func__, Mode.grabs.pointer_grab_window);

   Mode.grabs.pointer_grab_active = 0;
   Mode.grabs.pointer_grab_window = NoXID;
}
Exemple #22
0
void
FocusEnable(int on)
{
   if (on)
     {
	if (focus_inhibit > 0)
	   focus_inhibit--;
     }
   else
     {
	focus_inhibit++;
     }

   if (EDebug(EDBUG_TYPE_FOCUS))
      Eprintf("%s: inhibit=%d\n", __func__, focus_inhibit);
}
Exemple #23
0
Fichier : x.c Projet : Limsik/e17
void
EUnregisterWindow(Win win)
{
   if (!win)
      return;

   if (win->cbl.lst)
     {
	if (EDebug(1))
	   Eprintf("EUnregisterWindow(%#lx) Ignored (%d callbacks remain)\n",
		   win->xwin, win->cbl.num);
	return;
     }

   EXidDel(win);
}
Exemple #24
0
static void
ExtInitSS(int available)
{
   if (!available)
      return;

   if (EDebug(EDBUG_TYPE_VERBOSE))
     {
	XScreenSaverInfo   *xssi = XScreenSaverAllocInfo();

	XScreenSaverQueryInfo(disp, WinGetXwin(VROOT), xssi);
	Eprintf(" Screen saver window=%#lx\n", xssi->window);
	XFree(xssi);
     }
   XScreenSaverSelectInput(disp, WinGetXwin(VROOT),
			   ScreenSaverNotifyMask | ScreenSaverCycleMask);
}
Exemple #25
0
static void
EobjListShow(const char *txt, EobjList * ewl)
{
   int                 i;
   EObj               *eo;

   if (!EDebug(EDBUG_TYPE_STACKING))
      return;

   Eprintf("%s-%s:\n", ewl->name, txt);
   for (i = 0; i < ewl->nwins; i++)
     {
	eo = ewl->list[i];
	Eprintf(" %2d: %#10x %#10x %d %d %s\n", i, EobjGetXwin(eo),
		EobjGetCwin(eo), eo->desk->num, eo->ilayer, EobjGetName(eo));
     }
}
Exemple #26
0
int
SoundSampleGetData(const char *file, SoundSampleData * ssd)
{
   AFfilehandle        in_file;
   int                 in_format, in_width, bytes_per_frame, frame_count;
   int                 frames_read;

   in_file = afOpenFile(file, "r", NULL);
   if (!in_file)
      return -1;

   frame_count = afGetFrameCount(in_file, AF_DEFAULT_TRACK);
   ssd->channels = afGetChannels(in_file, AF_DEFAULT_TRACK);
   ssd->rate = (unsigned int)(afGetRate(in_file, AF_DEFAULT_TRACK) + .5);
   afGetSampleFormat(in_file, AF_DEFAULT_TRACK, &in_format, &in_width);
   ssd->bit_per_sample = in_width;
#ifdef WORDS_BIGENDIAN
   afSetVirtualByteOrder(in_file, AF_DEFAULT_TRACK, AF_BYTEORDER_BIGENDIAN);
#else
   afSetVirtualByteOrder(in_file, AF_DEFAULT_TRACK, AF_BYTEORDER_LITTLEENDIAN);
#endif
   if (EDebug(EDBUG_TYPE_SOUND))
      Eprintf("SoundSampleGetData chan=%d width=%d rate=%d\n", ssd->channels,
	      ssd->bit_per_sample, ssd->rate);

   bytes_per_frame = (ssd->bit_per_sample * ssd->channels) / 8;
   ssd->size = frame_count * bytes_per_frame;
   ssd->data = EMALLOC(unsigned char, ssd->size);

   frames_read =
      afReadFrames(in_file, AF_DEFAULT_TRACK, ssd->data, frame_count);

   afCloseFile(in_file);

   if (frames_read <= 0)
     {
	ssd->size = 0;
	_EFREE(ssd->data);
	return -1;
     }

   return 0;
}
Exemple #27
0
void
FocusToEWin(EWin * ewin, int why)
{
   if (EDebug(EDBUG_TYPE_FOCUS))
      Eprintf("%s(%d) %#x %s why=%d\n", __func__, focus_inhibit,
	      (ewin) ? EwinGetClientXwin(ewin) : 0,
	      (ewin) ? EwinGetTitle(ewin) : "None", why);

   switch (why)
     {
     case FOCUS_EWIN_NEW:
	if (!Conf.focus.all_new_windows_get_focus)
	   return;
	if (!FocusEwinValid(ewin, 0, 0, 0))
	   break;
	focus_pending_new = ewin;
	focus_pending_why = why;
	focus_pending_ewin = ewin;
	break;

     default:
	if (ewin && !FocusEwinValid(ewin, 0, why == FOCUS_CLICK, 0))
	   break;
	focus_pending_why = why;
	focus_pending_ewin = ewin;
	break;

     case FOCUS_EWIN_UNMAP:
	focus_pending_why = why;
	focus_pending_ewin = NULL;
	if (ewin == Mode.focuswin)
	  {
	     Mode.focuswin = NULL;
	     focus_is_set = 0;
	     if (!EoIsGone(ewin))
		FocusEwinSetActive(ewin, 0);
	  }
	if (ewin == focus_pending_new)
	   focus_pending_new = NULL;
	break;
     }
   focus_request = (int)NextRequest(disp) - 1;
}
Exemple #28
0
void
FocusHandleLeave(EWin * ewin, XEvent * ev)
{
   if ((int)ev->xcrossing.serial - focus_request < 0)
     {
	/* This event was caused by a request older than the latest
	 * focus assignment request - ignore */
	if (EDebug(EDBUG_TYPE_FOCUS))
	   Eprintf("%s: Ignore serial < %#x\n", __func__, focus_request);
	return;
     }

   /* Leaving root may mean entering other screen */
   if (!ewin)
     {
	if (ev->xcrossing.mode == NotifyNormal &&
	    ev->xcrossing.detail != NotifyInferior)
	   FocusToEWin(NULL, FOCUS_DESK_LEAVE);
     }
}
int
GrabPointerSet(Win win, unsigned int csr, int confine)
{
   int                 ret;
   Window              confine_to = (confine) ? WinGetXwin(VROOT) : None;

   ret = XGrabPointer(disp, WinGetXwin(win), False,
		      ButtonPressMask | ButtonReleaseMask | PointerMotionMask |
		      ButtonMotionMask | EnterWindowMask | LeaveWindowMask,
		      GrabModeAsync, GrabModeAsync, confine_to, ECsrGet(csr),
		      CurrentTime);

   Mode.grabs.pointer_grab_window = WinGetXwin(win);
   Mode.grabs.pointer_grab_active = 1;

   if (EDebug(EDBUG_TYPE_GRABS))
      Eprintf("GrabPointerSet: %#lx, ret=%d\n", Mode.grabs.pointer_grab_window,
	      ret);

   return ret;
}
const void         *
ModLoadSym(const char *lib, const char *sym, const char *name)
{
   char                buf[1024];
   void               *h;

   Esnprintf(buf, sizeof(buf), "%s/lib%s_%s.so", EDirLib(), lib, name);
   if (EDebug(1))
      Eprintf("ModLoad %s\n", buf);
   h = dlopen(buf, RTLD_NOW | RTLD_LOCAL);
   if (!h)
      Eprintf("*** ModLoad %s: %s\n", buf, dlerror());
   if (!h)
      return NULL;

   Esnprintf(buf, sizeof(buf), "%s_%s", sym, name);
   h = dlsym(h, buf);
   if (!h)
      Eprintf("*** ModLoad %s: %s\n", buf, dlerror());

   return h;
}