disp_x11.h 1008 Bytes
#ifndef __disp_x11_h__
#define __disp_x11_h__

#include "canvas_x11.h"
#include "../dispatcher.h"
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>

class disp_x11 : public dispatcher {
    private:
        int working;
        struct sembuf work;
        struct sembuf no_work;

    public:
        canvas_x11* a;

        disp_x11(event_source* w) : dispatcher(w) {
            working=semget(IPC_PRIVATE, 1, IPC_CREAT);
            work.sem_num=0;
            work.sem_op=-1;
            work.sem_flg=0;
            no_work.sem_num=0;
            no_work.sem_op=1;
            no_work.sem_flg=0;
        }
        disp_x11(disp_x11& d) : dispatcher(d) {}
        ~disp_x11() {
            semctl(working, 0, IPC_RMID, NULL);
        }

        void go(void);
        void trigger_event(event);
};

class disp_x11_factory : public dispatcher_factory {
    public:
        dispatcher* create(event_source* es) const {
            return new disp_x11(es);
        }
};

#endif // __disp_x11__