Commit Graph

3206 Commits

Author SHA1 Message Date
Brett Nash ba4ae189ea Use -1.
SVN revision: 52182
2010-09-13 09:15:53 +00:00
Brett Nash e36847a0ab Xdnd callback (API Addition): Rationale below.
Essentially the problem is this: For drag and drop Ecore currently handles the
position update calls.  But usually the application wants to display some user
feedback - a window to display the drag selection for instance.

Now the way e17 does it is grab the mouse cursor movements and track them
itself.  However ecore is already doing this, it's already walking window
trees, calculating real positions, _and_ sending them in an X client message.
So it seems rather silly to duplicate the code in the user app to get the same
info.

We could possibly have added a new event, but then we need to deal the fact
the position update may arrive _After_ the item has been dropped.  Hilarity
ensures[1].

This callback is meant for purely the selection owner of the drag to use, so
it is a callback set, not an add.

[1] Segfaults probably.  Nothing funnier.

SVN revision: 52181
2010-09-13 09:15:50 +00:00
Brett Nash 310ee61355 Always return an x rander version (unset in this case).
SVN revision: 52180
2010-09-13 09:15:45 +00:00
Carsten Haitzler fae947f8ea do extra composite checks - need to do the lot to be useful.
SVN revision: 52121
2010-09-10 06:57:21 +00:00
Lucas De Marchi 325e08065d Fix priority dropping
Lowering priority was wrong. Some bugs:

1) You don't lower the priority by setting the scheduler policy to some
   of the real-time ones (SCHED_RR or SCHER_FIFO). If you do so, you are
   actually increasing the priority of the workers and your main thread
   you be preempted and stalled until the workers complete their job.
   Fortunately this will only happen if your programming is running as
   root, as normal users (without CAP_SYS_NICE) are unable to set
   priority to real-time values.

2) setpriority() and getpriority() are not part of pthread and you can't
   use the id returned by pthread. Manpage explicitly says so on
   pthread_self(3):
   "The  thread ID returned by pthread_self() is not the same thing as the
       kernel thread ID returned by a call to gettid(2)."

   Since glibc does not have a gettid, here we are using
   syscall(SYS_gettid)

This patch was tested with the program below. Compile and run:
   $ gcc p_hello2.c -o p_hello2 -lpthread
   $ ./p_hello2 10

You'll see that the main thread remains with its priority and threads
created by the main thread change their own niceness.

#include <errno.h>
#include <pthread.h>
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/resource.h>
#include <sys/syscall.h>
#include <sys/time.h>
#include <sys/types.h>

/* Lower priority of current thread.
 *
 * It's used by worker threads so they use up "bg cpu" as it was really intended
 * to work. If current thread is running with real-time priority, we decrease
 * our priority by 5. This is done in a portable way.  Otherwise we are
 * running with SCHED_OTHER policy and there's no portable way to set the nice
 * level on current thread. In Linux, it does work and it's the only one that is
 * implemented.
 */
static void
_ecore_thread_pri_drop(void)
{
   struct sched_param param;
   int pol, prio, ret;
   pid_t tid;
   pthread_t pthread_id;

   pthread_id = pthread_self();
   ret = pthread_getschedparam(pthread_id, &pol, &param);
   if (ret)
     {
        fprintf(stderr, "Unable to query sched parameters\n");
        return;
     }

   if (pol == SCHED_RR || pol == SCHED_FIFO)
     {
        prio = sched_get_priority_max(pol);
        param.sched_priority += 5;
        if (prio > 0 && param.sched_priority > prio)
           param.sched_priority = prio;

        pthread_setschedparam(pthread_id, pol, &param);
     }
#ifdef __linux__
   else
     {
        tid = syscall(SYS_gettid);
        errno = 0;
        prio = getpriority(PRIO_PROCESS, tid);
        if (errno == 0)
          {
             prio += 5;
             if (prio > 19)
                prio = 19;

             setpriority(PRIO_PROCESS, tid, prio);
          }
     }
 #endif
}

/*
 * p_hello.c -- a hello program (in pthread)
 */
#define MAX_THREAD 1000

typedef struct {
    int id;
} parm;

void *hello(void *arg)
{
    parm *p=(parm *)arg;
    pid_t tid;
    int prio;
    tid =  syscall(SYS_gettid);
    printf("[%d] Hello from node %d\n", tid, p->id);
    pthread_yield();

    printf("[%d] tid=%lu\n", tid);

    _ecore_thread_pri_drop();

    prio = getpriority(PRIO_PROCESS, tid);
    printf("[%d] New nice value: %d\n", tid, prio);
    return (NULL);
}

void main(int argc, char* argv[]) {
    int n,i;
    pthread_t *threads;
    pthread_attr_t pthread_custom_attr;
    parm *p;

    pid_t tid;
    int prio;

    if (argc != 2)
    {
        printf ("Usage: %s n\n  where n is no. of threads\n",argv[0]);
        exit(1);
    }

    n=atoi(argv[1]);

    if ((n < 1) || (n > MAX_THREAD)) {
        printf ("The no of thread should between 1 and %d.\n",MAX_THREAD);
        exit(1);
    }

    threads = (pthread_t *)malloc(n * sizeof(*threads));
    pthread_attr_init(&pthread_custom_attr);

    p = (parm *)malloc(n * sizeof(parm));
    /* Start up thread */

    tid = syscall(SYS_gettid);
    for (i=0; i<n; i++) {
        prio = getpriority(PRIO_PROCESS, tid);
        printf("[%d] root thread nice value: %d\n", tid, prio);

        p[i].id=i;
        pthread_create(&threads[i], &pthread_custom_attr, hello, (void *)(p+i));
    }

    /* Synchronize the completion of each thread. */

    for (i=0; i<n; i++) {
        pthread_join(threads[i],NULL);
    }
    free(p);
}



SVN revision: 52039
2010-09-09 11:48:31 +00:00
Lucas De Marchi be1b6d32ef Fix common misspellings
Following misspellings were fixed:

alledgedly->allegedly
cant->can't
carefull->careful
consistant->consistent
currenly->currently
dependancy->dependency
descripters->descriptors
doesnt->doesn't
dosen't->doesn't
existant->existent
exmaple->example
inbetween->between
independant->independent
isnt->isn't
mroe->more
neccessary->necessary
occured->occurred
occurence->occurrence
parrallel->parallel
particualr->particular
preceeding->preceding
recieved->received
recieves->receives
seperate->separate
substraction->subtraction
succesfully->successfully
successfull->successful
sucess->success
supress->suppress
usefull->useful
witht->with



SVN revision: 51986
2010-09-08 11:23:42 +00:00
Brett Nash 4bf9ee3df3 Merge branch 'elmdnd'
Conflicts:
	trunk/TMP/st/elementary/.gitignore

SVN revision: 51935
2010-09-07 06:56:16 +00:00
Cedric BAIL d098e05951 * ecore: fix error detection of ecore_pipe_add.
SVN revision: 51926
2010-09-06 16:36:44 +00:00
Christopher Michael e2b4501a74 Prototypes for the missing ecore_x convert functions.
SVN revision: 51906
2010-09-05 15:40:36 +00:00
Carsten Haitzler 9049befccf make 1 func to set lower pri - fall back to setpriority on linux and
try it there only.



SVN revision: 51885
2010-09-04 14:32:50 +00:00
Carsten Haitzler 05cf40fc4d same - back to RR.
SVN revision: 51878
2010-09-04 05:40:38 +00:00
Carsten Haitzler 2c397940de rr->other
SVN revision: 51873
2010-09-04 00:54:53 +00:00
Cedric BAIL b3dd293384 * ecore: ecore_thread are not here to bring your computer down, so
reduce their priority too.


SVN revision: 51862
2010-09-03 13:39:53 +00:00
Vincent Torri 156952f938 fix include order for Windows
SVN revision: 51740
2010-08-30 05:49:18 +00:00
Carsten Haitzler 46a62d5460 leak--
SVN revision: 51702
2010-08-28 15:07:45 +00:00
Carsten Haitzler 6402642686 more leak--
SVN revision: 51701
2010-08-28 14:56:14 +00:00
Carsten Haitzler 061f22552e fix leak of fb fd in error event.
SVN revision: 51700
2010-08-28 14:51:56 +00:00
Mike Blumenkrantz 833c0d19a9 doxy clarification
SVN revision: 51694
2010-08-28 10:01:20 +00:00
Carsten Haitzler be93013208 technically xerrorhandlers have a return of an int - but its ignored
by xlib (explicitly in docs).



SVN revision: 51693
2010-08-28 04:28:15 +00:00
Nicholas Hughart 7afd0b7173 Add the following functions to Ecore_Con API:
ecore_con_server_name_get
ecore_con_server_port_get



SVN revision: 51670
2010-08-27 05:16:00 +00:00
Vincent Torri 2e625ed90e fix copy/paste
SVN revision: 51667
2010-08-26 22:39:42 +00:00
Lucas De Marchi 255b2cb870 Apply double_condition_check.cocci
The offending projects were:

 E16/e/src/backgrounds.c                 |   10 ++++------
 PROTO/eon/src/lib/layout/eon_stack.c    |    4 +---
 ecore/src/lib/ecore_win32/ecore_win32.c |    3 +--
 ecore/src/lib/ecore_wince/ecore_wince.c |    3 +--
 edje/src/lib/edje_edit.c                |    3 +--
 evas/src/lib/cache/evas_cache_image.c   |    2 +-
 exalt/src/lib/libexalt_private.c        |    2 +-


This patch assumes code in these places were insane and the fix is to remove
one condition check. Most likely this is not true, but there's no automatic fix
for that.

Looking at the patch, it seems that some places should use "x" and "y" vars but
used just one of them and therefore they were caught by coccinelle.




SVN revision: 51666
2010-08-26 20:45:09 +00:00
Lucas De Marchi d8002ff386 Revert and re-apply badnull patch
Revert previous patch generated by badnull.cocci script, and apply the new one.
The main difference is that assert and assert-like functions are not touched
anymore.




SVN revision: 51650
2010-08-26 01:34:13 +00:00
Carsten Haitzler 2aebc5b458 fix ecore_thread to use pthread correctly. should build on windows now
too.



SVN revision: 51621
2010-08-25 00:26:01 +00:00
Christopher Michael 51f2ed1d97 Add UNUSED where missing.
SVN revision: 51618
2010-08-24 23:29:24 +00:00
Carsten Haitzler 864fcb6c17 fix sync issue in 1 special event re-order case. booo!
SVN revision: 51609
2010-08-24 09:26:34 +00:00
Vincent Torri 7d75cc4a1d Remove the possibility to build ecore_config (which was deprecated anyway).
It will be raised from dead later, with a better API/code


SVN revision: 51599
2010-08-24 06:37:37 +00:00
Cedric BAIL 243d7c71ad * ecore: struct a b = { 0 }; doesn't mean memset.
SVN revision: 51571
2010-08-23 13:05:57 +00:00
Vincent Torri 426da862ae get the verbosity with the env variable CK_VERBOSITY. By default, nothing is changed.
Values for CK_VERBOSITY:
silent
minimal
normal (the default)
verbose

Ex. of use:

CK_VERBOSITY=verbose make check


SVN revision: 51534
2010-08-22 17:53:01 +00:00
Vincent Torri bb17bf9216 separate the Ecore_X test from the Ecore one
SVN revision: 51533
2010-08-22 17:38:51 +00:00
Vincent Torri 0d89124a68 * add more checks
* add comments about strange code


SVN revision: 51525
2010-08-22 17:14:05 +00:00
Lucas De Marchi 5a8a8c9014 Convert (hopefully) all comparisons to NULL
Apply badzero.cocci, badnull.coci and badnull2.cocci

This should convert all cases where there's a comparison to NULL to simpler
forms. This patch applies the following transformations:

code before patch               ||code after patch
===============================================================

return a == NULL;                 return !a;

return a != NULL;                 return !!a;

func(a == NULL);                  func(!a);

func(a != NULL);                  func(!!a);

b = a == NULL;                    b = !a;

b = a != NULL;                    b = !!a;

b = a == NULL ? c : d;            b = !a ? c : d;

b = a != NULL ? c : d;            b = a ? c : d;


other cases:

a == NULL                         !a
a != NULL                         a




SVN revision: 51487
2010-08-21 13:52:25 +00:00
Carsten Haitzler 3df7e6ebfc fix randr bug! -> tunix!
SVN revision: 51475
2010-08-21 02:37:20 +00:00
Carsten Haitzler 3e67489265 again - pass distcheck!
SVN revision: 51459
2010-08-20 02:48:54 +00:00
Christopher Michael f8d86f6d7c Remove blank line & fix formatting of function params.
SVN revision: 51397
2010-08-19 14:41:24 +00:00
Christopher Michael 3e61872e46 Add missing UNUSED.
SVN revision: 51396
2010-08-19 14:33:49 +00:00
Christopher Michael 4c30f8ec92 Handle missing case of POLICY_NONE.
SVN revision: 51395
2010-08-19 14:32:16 +00:00
Christopher Michael a154885a59 Add some missing UNUSED macros.
SVN revision: 51394
2010-08-19 14:29:05 +00:00
Cedric BAIL 3c305771c3 * ecore: add some information about Ecore_Thread.
SVN revision: 51389
2010-08-19 08:57:55 +00:00
Carsten Haitzler 67782a333f from t_unix <- add none enum for randr
SVN revision: 51387
2010-08-19 08:25:34 +00:00
Sebastian Dransfeld ff0f25ea7b Fix inline functions
Inline functions which are to be used in serveral files must be
completly written in the .x file.

SVN revision: 51361
2010-08-18 21:27:40 +00:00
Christopher Michael 1e8383c131 Fix 'suggest braces around empty body if statement'.
SVN revision: 51291
2010-08-18 16:28:36 +00:00
Christopher Michael b82186120a Fix 'unused variable'.
SVN revision: 51290
2010-08-18 16:26:20 +00:00
Mike Blumenkrantz 236d58f0de ecore_thread_pool -> ecore_thread_local
SVN revision: 51272
2010-08-18 08:56:44 +00:00
Vincent Torri aaffd2acac fix compilation without thread support
SVN revision: 51267
2010-08-17 19:21:47 +00:00
Vincent Torri 2c8b78f634 fix and format EXTRA_DIST
SVN revision: 51266
2010-08-17 19:01:20 +00:00
Cedric BAIL 59f3bf1eb6 * ecore: const Eina_Bool don't make any sense.
SVN revision: 51252
2010-08-17 14:48:21 +00:00
Lucas De Marchi 32a891e57e Don't return int in functions returning Eina_Bool
SVN revision: 51201
2010-08-16 12:03:49 +00:00
Carsten Haitzler e7667b11ad copy & paste fix.
SVN revision: 51171
2010-08-16 08:59:42 +00:00
Carsten Haitzler e286f48745 and now ecore is 1.0.0 ready too.
SVN revision: 51165
2010-08-16 08:17:24 +00:00