parent
0ec2d7f919
commit
4e0b46746a
34
src/E.h
34
src/E.h
|
@ -589,6 +589,7 @@ typedef struct _button Button;
|
|||
typedef struct _slideout Slideout;
|
||||
typedef struct _soundclass SoundClass;
|
||||
typedef struct _background Background;
|
||||
typedef struct _ecursor ECursor;
|
||||
|
||||
typedef struct _efont Efont;
|
||||
|
||||
|
@ -818,19 +819,6 @@ typedef struct _geometry
|
|||
}
|
||||
Geometry;
|
||||
|
||||
typedef struct _ecursor
|
||||
{
|
||||
char *name;
|
||||
#if 0 /* Not used */
|
||||
Imlib_Color fg, bg;
|
||||
#endif
|
||||
char *file;
|
||||
Cursor cursor;
|
||||
unsigned int ref_count;
|
||||
char inroot;
|
||||
}
|
||||
ECursor;
|
||||
|
||||
typedef struct _winpart
|
||||
{
|
||||
Geometry geom;
|
||||
|
@ -1922,10 +1910,22 @@ void CoordsShow(EWin * ewin);
|
|||
void CoordsHide(void);
|
||||
|
||||
/* cursors.c */
|
||||
ECursor *CreateECursor(char *name, char *image, int native_id,
|
||||
XColor * fg, XColor * bg);
|
||||
void ApplyECursor(Window win, ECursor * ec);
|
||||
void FreeECursor(ECursor * ec);
|
||||
#define ECSR_ROOT 0
|
||||
#define ECSR_GRAB 1
|
||||
#define ECSR_ACT_MOVE 2
|
||||
#define ECSR_ACT_RESIZE 3
|
||||
#define ECSR_COUNT 4
|
||||
void ECursorsInit(void);
|
||||
ECursor *ECursorCreate(const char *name, const char *image,
|
||||
int native_id, XColor * fg, XColor * bg);
|
||||
void ECursorApply(ECursor * ec, Window win);
|
||||
void ECursorDestroy(ECursor * ec);
|
||||
void ECursorIncRefcount(ECursor * ec);
|
||||
void ECursorDecRefcount(ECursor * ec);
|
||||
int ECursorGetRefcount(ECursor * ec);
|
||||
const char *ECursorGetName(ECursor * ec);
|
||||
Cursor ECsrGet(int which);
|
||||
void ECsrApply(int which, Window win);
|
||||
|
||||
/* desktops.c */
|
||||
void ChangeNumberOfDesktops(int quantity);
|
||||
|
|
|
@ -1692,7 +1692,7 @@ EwinBorderSetTo(EWin * ewin, Border * b)
|
|||
else
|
||||
{
|
||||
ewin->bits[i].win = ECreateWindow(ewin->win, -10, -10, 1, 1, 0);
|
||||
ApplyECursor(ewin->bits[i].win, b->part[i].ec);
|
||||
ECursorApply(b->part[i].ec, ewin->bits[i].win);
|
||||
EMapWindow(disp, ewin->bits[i].win);
|
||||
/*
|
||||
* KeyPressMask KeyReleaseMask ButtonPressMask
|
||||
|
@ -2272,7 +2272,7 @@ FreeBorder(Border * b)
|
|||
if (b->part[i].aclass)
|
||||
b->part[i].aclass->ref_count--;
|
||||
if (b->part[i].ec)
|
||||
b->part[i].ec->ref_count--;
|
||||
ECursorDecRefcount(b->part[i].ec);
|
||||
}
|
||||
|
||||
if (b->num_winparts > 0)
|
||||
|
@ -2354,7 +2354,7 @@ AddBorderPart(Border * b, ImageClass * iclass, ActionClass * aclass,
|
|||
|
||||
b->part[n - 1].ec = ec;
|
||||
if (ec)
|
||||
ec->ref_count++;
|
||||
ECursorIncRefcount(ec);
|
||||
|
||||
b->part[n - 1].ontop = ontop;
|
||||
b->part[n - 1].flags = flags;
|
||||
|
|
|
@ -2074,9 +2074,7 @@ Config_ECursor(FILE * ConfigFile)
|
|||
switch (ii1)
|
||||
{
|
||||
case CONFIG_CLOSE:
|
||||
ec = CreateECursor(name, file, native_id, &xclr, &xclr2);
|
||||
if (ec)
|
||||
AddItem(ec, ec->name, 0, LIST_TYPE_ECURSOR);
|
||||
ec = ECursorCreate(name, file, native_id, &xclr, &xclr2);
|
||||
if (name)
|
||||
Efree(name);
|
||||
if (file)
|
||||
|
|
|
@ -21,9 +21,25 @@
|
|||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#include "E.h"
|
||||
#include "X11/cursorfont.h"
|
||||
|
||||
struct _ecursor
|
||||
{
|
||||
char *name;
|
||||
#if 0 /* Not used */
|
||||
Imlib_Color fg, bg;
|
||||
#endif
|
||||
char *file;
|
||||
Cursor cursor;
|
||||
unsigned int ref_count;
|
||||
#if 0 /* Not used */
|
||||
char inroot;
|
||||
#endif
|
||||
};
|
||||
|
||||
ECursor *
|
||||
CreateECursor(char *name, char *image, int native_id, XColor * fg, XColor * bg)
|
||||
ECursorCreate(const char *name, const char *image, int native_id, XColor * fg,
|
||||
XColor * bg)
|
||||
{
|
||||
Cursor curs;
|
||||
Pixmap pmap, mask;
|
||||
|
@ -80,21 +96,43 @@ CreateECursor(char *name, char *image, int native_id, XColor * fg, XColor * bg)
|
|||
#endif
|
||||
ec->cursor = curs;
|
||||
ec->ref_count = 0;
|
||||
#if 0 /* Not used */
|
||||
ec->inroot = 0;
|
||||
#endif
|
||||
|
||||
AddItem(ec, ec->name, 0, LIST_TYPE_ECURSOR);
|
||||
|
||||
return ec;
|
||||
}
|
||||
|
||||
void
|
||||
ApplyECursor(Window win, ECursor * ec)
|
||||
ECursorApply(ECursor * ec, Window win)
|
||||
{
|
||||
if (!ec)
|
||||
return;
|
||||
XDefineCursor(disp, win, ec->cursor);
|
||||
#if 0 /* Not used */
|
||||
if (win == VRoot.win)
|
||||
ec->inroot = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
static Cursor
|
||||
ECursorGetByName(const char *name, unsigned int fallback)
|
||||
{
|
||||
ECursor *ec;
|
||||
|
||||
ec = FindItem(name, 0, LIST_FINDBY_NAME, LIST_TYPE_ECURSOR);
|
||||
if (!ec)
|
||||
return fallback;
|
||||
|
||||
ECursorIncRefcount(ec);
|
||||
|
||||
return ec->cursor;
|
||||
}
|
||||
|
||||
void
|
||||
FreeECursor(ECursor * ec)
|
||||
ECursorDestroy(ECursor * ec)
|
||||
{
|
||||
if (!ec)
|
||||
return;
|
||||
|
@ -114,3 +152,55 @@ FreeECursor(ECursor * ec)
|
|||
Efree(ec->file);
|
||||
Efree(ec);
|
||||
}
|
||||
|
||||
void
|
||||
ECursorIncRefcount(ECursor * ec)
|
||||
{
|
||||
if (ec)
|
||||
ec->ref_count++;
|
||||
}
|
||||
|
||||
void
|
||||
ECursorDecRefcount(ECursor * ec)
|
||||
{
|
||||
if (ec)
|
||||
ec->ref_count--;
|
||||
}
|
||||
|
||||
const char *
|
||||
ECursorGetName(ECursor * ec)
|
||||
{
|
||||
return (ec) ? ec->name : 0;
|
||||
}
|
||||
|
||||
int
|
||||
ECursorGetRefcount(ECursor * ec)
|
||||
{
|
||||
return (ec) ? ec->ref_count : 0;
|
||||
}
|
||||
|
||||
static Cursor ECsrs[ECSR_COUNT];
|
||||
|
||||
Cursor
|
||||
ECsrGet(int which)
|
||||
{
|
||||
return (which >= 0 && which < ECSR_COUNT) ? ECsrs[which] : None;
|
||||
}
|
||||
|
||||
void
|
||||
ECsrApply(int which, Window win)
|
||||
{
|
||||
XDefineCursor(disp, win, ECsrGet(which));
|
||||
}
|
||||
|
||||
/*
|
||||
* Set up some basic cursors
|
||||
*/
|
||||
void
|
||||
ECursorsInit(void)
|
||||
{
|
||||
ECsrs[ECSR_ROOT] = ECursorGetByName("DEFAULT", XC_arrow);
|
||||
ECsrs[ECSR_GRAB] = ECursorGetByName("GRAB", XC_circle);
|
||||
ECsrs[ECSR_ACT_MOVE] = ECursorGetByName("ACTION_MOVE", XC_X_cursor);
|
||||
ECsrs[ECSR_ACT_RESIZE] = ECursorGetByName("ACTION_RESIZE", XC_sizing);
|
||||
}
|
||||
|
|
|
@ -853,7 +853,7 @@ IPC_Cursor(const char *params, Client * c)
|
|||
ec = (ECursor *) FindItem(param1, 0, LIST_FINDBY_NAME,
|
||||
LIST_TYPE_ECURSOR);
|
||||
if (ec)
|
||||
FreeECursor(ec);
|
||||
ECursorDestroy(ec);
|
||||
}
|
||||
else if (!strcmp(param2, "modify"))
|
||||
{
|
||||
|
@ -866,7 +866,7 @@ IPC_Cursor(const char *params, Client * c)
|
|||
LIST_TYPE_ECURSOR);
|
||||
if (ec)
|
||||
Esnprintf(buf, sizeof(buf), "%u references remain",
|
||||
ec->ref_count);
|
||||
ECursorGetRefcount(ec));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1548,7 +1548,7 @@ IPC_ListClassMembers(const char *params, Client * c)
|
|||
for (i = 0; i < num; i++)
|
||||
{
|
||||
buf2[0] = 0;
|
||||
Esnprintf(buf2, sizeof(buf2), "%s\n", lst[i]->name);
|
||||
Esnprintf(buf2, sizeof(buf2), "%s\n", ECursorGetName(lst[i]));
|
||||
if (buf)
|
||||
buf = realloc(buf, strlen(buf) + strlen(buf2) + 1);
|
||||
else
|
||||
|
|
10
src/main.c
10
src/main.c
|
@ -53,7 +53,6 @@ int
|
|||
main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
ECursor *ec = NULL;
|
||||
struct utsname ubuf;
|
||||
char *str;
|
||||
|
||||
|
@ -304,13 +303,8 @@ main(int argc, char **argv)
|
|||
Mode.queue_up = DRAW_QUEUE_ENABLE;
|
||||
|
||||
/* of course, we have to set the cursors */
|
||||
ec = FindItem("DEFAULT", 0, LIST_FINDBY_NAME, LIST_TYPE_ECURSOR);
|
||||
if (ec)
|
||||
{
|
||||
ApplyECursor(VRoot.win, ec);
|
||||
ec->ref_count++;
|
||||
ec->inroot = 1;
|
||||
}
|
||||
ECursorsInit();
|
||||
ECsrApply(ECSR_ROOT, VRoot.win);
|
||||
|
||||
Mode.wm.startup = 0;
|
||||
Mode.wm.save_ok = Mode.wm.master;
|
||||
|
|
Loading…
Reference in New Issue