efl/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_window_shape.c

305 lines
8.1 KiB
C
Raw Normal View History

/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#include "Ecore.h"
#include "ecore_x_private.h"
#include "Ecore_X.h"
/**
* @defgroup Ecore_X_Window_Shape X Window Shape Functions
*
* These functions use the shape extension of the X server to change
* shape of given windows.
*/
/**
* Sets the shape of the given window to that given by the pixmap @p mask.
* @param win The given window.
* @param mask A 2-bit depth pixmap that provides the new shape of the
* window.
* @ingroup Ecore_X_Window_Shape
*/
EAPI void
ecore_x_window_shape_mask_set(Ecore_X_Window win, Ecore_X_Pixmap mask)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
XShapeCombineMask(_ecore_x_disp, win, ShapeBounding, 0, 0, mask, ShapeSet);
}
EAPI void
ecore_x_window_shape_window_set(Ecore_X_Window win, Ecore_X_Window shape_win)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
XShapeCombineShape(_ecore_x_disp,
win,
ShapeBounding,
0,
0,
shape_win,
ShapeBounding,
ShapeSet);
}
EAPI void
ecore_x_window_shape_window_set_xy(Ecore_X_Window win,
Ecore_X_Window shape_win,
int x,
int y)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
XShapeCombineShape(_ecore_x_disp,
win,
ShapeBounding,
x,
y,
shape_win,
ShapeBounding,
ShapeSet);
}
EAPI void
ecore_x_window_shape_rectangle_set(Ecore_X_Window win,
int x,
int y,
int w,
int h)
{
XRectangle rect;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
rect.x = x;
rect.y = y;
rect.width = w;
rect.height = h;
XShapeCombineRectangles(_ecore_x_disp,
win,
ShapeBounding,
0,
0,
&rect,
1,
ShapeSet,
Unsorted);
}
EAPI void
ecore_x_window_shape_rectangles_set(Ecore_X_Window win,
Ecore_X_Rectangle *rects,
int num)
{
XRectangle *rect = NULL;
int i;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (num > 0)
{
rect = malloc(sizeof(XRectangle) * num);
if (rect)
for (i = 0; i < num; i++)
{
rect[i].x = rects[i].x;
rect[i].y = rects[i].y;
rect[i].width = rects[i].width;
rect[i].height = rects[i].height;
}
else
num = 0;
}
XShapeCombineRectangles(_ecore_x_disp,
win,
ShapeBounding,
0,
0,
rect,
num,
ShapeSet,
Unsorted);
if (rect)
free(rect);
}
EAPI void
ecore_x_window_shape_window_add(Ecore_X_Window win, Ecore_X_Window shape_win)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
XShapeCombineShape(_ecore_x_disp,
win,
ShapeBounding,
0,
0,
shape_win,
ShapeBounding,
ShapeUnion);
}
EAPI void
ecore_x_window_shape_window_add_xy(Ecore_X_Window win,
Ecore_X_Window shape_win,
int x,
int y)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
XShapeCombineShape(_ecore_x_disp,
win,
ShapeBounding,
x,
y,
shape_win,
ShapeBounding,
ShapeUnion);
}
EAPI void
ecore_x_window_shape_rectangle_add(Ecore_X_Window win,
int x,
int y,
int w,
int h)
{
XRectangle rect;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
rect.x = x;
rect.y = y;
rect.width = w;
rect.height = h;
XShapeCombineRectangles(_ecore_x_disp,
win,
ShapeBounding,
0,
0,
&rect,
1,
ShapeUnion,
Unsorted);
}
EAPI void
ecore_x_window_shape_rectangle_clip(Ecore_X_Window win,
int x,
int y,
int w,
int h)
{
XRectangle rect;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
rect.x = x;
rect.y = y;
rect.width = w;
rect.height = h;
XShapeCombineRectangles(_ecore_x_disp,
win,
ShapeBounding,
0,
0,
&rect,
1,
ShapeIntersect,
Unsorted);
}
EAPI void
ecore_x_window_shape_rectangles_add(Ecore_X_Window win,
Ecore_X_Rectangle *rects,
int num)
{
XRectangle *rect = NULL;
int i;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (num > 0)
{
rect = malloc(sizeof(XRectangle) * num);
if (rect)
for (i = 0; i < num; i++)
{
rect[i].x = rects[i].x;
rect[i].y = rects[i].y;
rect[i].width = rects[i].width;
rect[i].height = rects[i].height;
}
else
num = 0;
}
XShapeCombineRectangles(_ecore_x_disp,
win,
ShapeBounding,
0,
0,
rect,
num,
ShapeUnion,
Unsorted);
if (rect)
free(rect);
}
EAPI Ecore_X_Rectangle *
ecore_x_window_shape_rectangles_get(Ecore_X_Window win, int *num_ret)
{
XRectangle *rect;
Ecore_X_Rectangle *rects = NULL;
int i, num = 0, ord;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
rect = XShapeGetRectangles(_ecore_x_disp, win, ShapeBounding, &num, &ord);
if (rect)
{
rects = malloc(sizeof(Ecore_X_Rectangle) * num);
if (rects)
for (i = 0; i < num; i++)
{
rects[i].x = rect[i].x;
rects[i].y = rect[i].y;
rects[i].width = rect[i].width;
rects[i].height = rect[i].height;
}
XFree(rect);
}
if (num_ret)
*num_ret = num;
return rects;
}
EAPI void
ecore_x_window_shape_events_select(Ecore_X_Window win, int on)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (on)
XShapeSelectInput(_ecore_x_disp, win, ShapeNotifyMask);
else
XShapeSelectInput(_ecore_x_disp, win, 0);
}
e: 1. configure/build changes to allow cross-compiling painlessly 2. pager module namespace changes - this was still dirty afdter the namespace cleanup, so clean it up 3. add a powersave subsystem - doesnt have an "automatic" way to turn on and off right now, this i think is best provided by modules (that do things like monitor acpi status's (eg close lid of laptop), AC power status etc. etc. this allows e to nicely defer "power" expensive actions to avoid disk spinups etc. 4. move to use the new ecore poller system - discussed long ago as part of power management/saving issues. now it exists 5. add a canvas idle flush call that helsp cope with the new shm greedy software x11 engine stuff 6. use the new powersave subsystem where appropriate 7. fix non-zeroed/initted memory access in e_fm_main 8. fix mem leak for e menus 9. remove ipc handlers for changed/removed config values 10. use animaotr not timer for menu scrolls - then menu scrolls obey the fps config 11. fix up timer/poll happienss of cursor idle stuff 12. remove avoid damage from popups for now - causing problems 13. change battery and temp readouts to b e shorter so they fit 14. pager can emit signals on focus change for mini-windows now 15. temperature module now uses a slave process and uses stdin/out to talk to it and get output - this makes e smoother as in my expereicne i found getting the temp on my laptop actually took like 200ms so e "hang" for 200ms while reading the acpi files - so now the subprocess does it and just writesa back to e when it gets it. ecore: 1. add ecore_pollers. see the documentation on them in doxygen comments :) 2. fix timers to only go off when they have to - bug there that made e's select time out a LOT more than it needed to. defensive coding hid the problem. now fixed. e should be much more power friendly now. 3. formatting/niceness in ecore_exe stuff 4. some comments on comments with SIGIO ideas vs. select 5. add call to be able to add an idle enterer at the start of the list of them, not just the end (as has been the default) 6. fix ecore_evas to support auto evas idler calls after 0.5 secs of idle in all canvases - and to do it right 7. if argb destination - set the shape EVENT shape (to mask out events in transparent regions much like shape does withotu translucency) 8. in ecore_x add support for the event shape evas: 1. fix cache to work properly and not just always fill up (as it seemed to like to think cahce useage dropped below 0 when it didnt and thus just over-fill) 2. software x11 engine now ONLY uses shm segments - no ximages over the socket. this ximage hack was there to avoid the 2 round trips involved in setting up an shm image - now i mitigated that wih an shm image cache pool. it keeps shm images around and repurposes them for new update regions if appropriate. this means many fewer shm creates (about 1/100th the number) and since we recycle the memory less 0 memory page filling by the kernel - in the end, i recorded about a 10-20% speedup over the old software x11 engine. simple tests i have seen up to 120% speedups. idle flush now does something - it frees all the cached shm segments. it has a hard-coded limit of 4mb worth of shm segments (or 32 segments - whichever comes first) to keep around. once can never complain much about speedups methinks :). also evas will defer sync until the NEXT frame is written - this means evas can calculate the next frame of data while x dma's/copies the images to the screen at the same time (if you hve a dual core or multi-cpu machnike or your xserver is able to use DMA to copy image data to the screen/video ram then this should see a decent speedup). SVN revision: 33448
2008-01-10 23:33:57 -08:00
/**
* Sets the input shape of the given window to that given by the pixmap @p mask.
* @param win The given window.
* @param mask A 2-bit depth pixmap that provides the new input shape of the
* window.
* @ingroup Ecore_X_Window_Shape
*/
EAPI void
ecore_x_window_shape_input_mask_set(Ecore_X_Window win, Ecore_X_Pixmap mask)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
e: 1. configure/build changes to allow cross-compiling painlessly 2. pager module namespace changes - this was still dirty afdter the namespace cleanup, so clean it up 3. add a powersave subsystem - doesnt have an "automatic" way to turn on and off right now, this i think is best provided by modules (that do things like monitor acpi status's (eg close lid of laptop), AC power status etc. etc. this allows e to nicely defer "power" expensive actions to avoid disk spinups etc. 4. move to use the new ecore poller system - discussed long ago as part of power management/saving issues. now it exists 5. add a canvas idle flush call that helsp cope with the new shm greedy software x11 engine stuff 6. use the new powersave subsystem where appropriate 7. fix non-zeroed/initted memory access in e_fm_main 8. fix mem leak for e menus 9. remove ipc handlers for changed/removed config values 10. use animaotr not timer for menu scrolls - then menu scrolls obey the fps config 11. fix up timer/poll happienss of cursor idle stuff 12. remove avoid damage from popups for now - causing problems 13. change battery and temp readouts to b e shorter so they fit 14. pager can emit signals on focus change for mini-windows now 15. temperature module now uses a slave process and uses stdin/out to talk to it and get output - this makes e smoother as in my expereicne i found getting the temp on my laptop actually took like 200ms so e "hang" for 200ms while reading the acpi files - so now the subprocess does it and just writesa back to e when it gets it. ecore: 1. add ecore_pollers. see the documentation on them in doxygen comments :) 2. fix timers to only go off when they have to - bug there that made e's select time out a LOT more than it needed to. defensive coding hid the problem. now fixed. e should be much more power friendly now. 3. formatting/niceness in ecore_exe stuff 4. some comments on comments with SIGIO ideas vs. select 5. add call to be able to add an idle enterer at the start of the list of them, not just the end (as has been the default) 6. fix ecore_evas to support auto evas idler calls after 0.5 secs of idle in all canvases - and to do it right 7. if argb destination - set the shape EVENT shape (to mask out events in transparent regions much like shape does withotu translucency) 8. in ecore_x add support for the event shape evas: 1. fix cache to work properly and not just always fill up (as it seemed to like to think cahce useage dropped below 0 when it didnt and thus just over-fill) 2. software x11 engine now ONLY uses shm segments - no ximages over the socket. this ximage hack was there to avoid the 2 round trips involved in setting up an shm image - now i mitigated that wih an shm image cache pool. it keeps shm images around and repurposes them for new update regions if appropriate. this means many fewer shm creates (about 1/100th the number) and since we recycle the memory less 0 memory page filling by the kernel - in the end, i recorded about a 10-20% speedup over the old software x11 engine. simple tests i have seen up to 120% speedups. idle flush now does something - it frees all the cached shm segments. it has a hard-coded limit of 4mb worth of shm segments (or 32 segments - whichever comes first) to keep around. once can never complain much about speedups methinks :). also evas will defer sync until the NEXT frame is written - this means evas can calculate the next frame of data while x dma's/copies the images to the screen at the same time (if you hve a dual core or multi-cpu machnike or your xserver is able to use DMA to copy image data to the screen/video ram then this should see a decent speedup). SVN revision: 33448
2008-01-10 23:33:57 -08:00
#ifdef ShapeInput
XShapeCombineMask(_ecore_x_disp, win, ShapeInput, 0, 0, mask, ShapeSet);
#else
e: 1. configure/build changes to allow cross-compiling painlessly 2. pager module namespace changes - this was still dirty afdter the namespace cleanup, so clean it up 3. add a powersave subsystem - doesnt have an "automatic" way to turn on and off right now, this i think is best provided by modules (that do things like monitor acpi status's (eg close lid of laptop), AC power status etc. etc. this allows e to nicely defer "power" expensive actions to avoid disk spinups etc. 4. move to use the new ecore poller system - discussed long ago as part of power management/saving issues. now it exists 5. add a canvas idle flush call that helsp cope with the new shm greedy software x11 engine stuff 6. use the new powersave subsystem where appropriate 7. fix non-zeroed/initted memory access in e_fm_main 8. fix mem leak for e menus 9. remove ipc handlers for changed/removed config values 10. use animaotr not timer for menu scrolls - then menu scrolls obey the fps config 11. fix up timer/poll happienss of cursor idle stuff 12. remove avoid damage from popups for now - causing problems 13. change battery and temp readouts to b e shorter so they fit 14. pager can emit signals on focus change for mini-windows now 15. temperature module now uses a slave process and uses stdin/out to talk to it and get output - this makes e smoother as in my expereicne i found getting the temp on my laptop actually took like 200ms so e "hang" for 200ms while reading the acpi files - so now the subprocess does it and just writesa back to e when it gets it. ecore: 1. add ecore_pollers. see the documentation on them in doxygen comments :) 2. fix timers to only go off when they have to - bug there that made e's select time out a LOT more than it needed to. defensive coding hid the problem. now fixed. e should be much more power friendly now. 3. formatting/niceness in ecore_exe stuff 4. some comments on comments with SIGIO ideas vs. select 5. add call to be able to add an idle enterer at the start of the list of them, not just the end (as has been the default) 6. fix ecore_evas to support auto evas idler calls after 0.5 secs of idle in all canvases - and to do it right 7. if argb destination - set the shape EVENT shape (to mask out events in transparent regions much like shape does withotu translucency) 8. in ecore_x add support for the event shape evas: 1. fix cache to work properly and not just always fill up (as it seemed to like to think cahce useage dropped below 0 when it didnt and thus just over-fill) 2. software x11 engine now ONLY uses shm segments - no ximages over the socket. this ximage hack was there to avoid the 2 round trips involved in setting up an shm image - now i mitigated that wih an shm image cache pool. it keeps shm images around and repurposes them for new update regions if appropriate. this means many fewer shm creates (about 1/100th the number) and since we recycle the memory less 0 memory page filling by the kernel - in the end, i recorded about a 10-20% speedup over the old software x11 engine. simple tests i have seen up to 120% speedups. idle flush now does something - it frees all the cached shm segments. it has a hard-coded limit of 4mb worth of shm segments (or 32 segments - whichever comes first) to keep around. once can never complain much about speedups methinks :). also evas will defer sync until the NEXT frame is written - this means evas can calculate the next frame of data while x dma's/copies the images to the screen at the same time (if you hve a dual core or multi-cpu machnike or your xserver is able to use DMA to copy image data to the screen/video ram then this should see a decent speedup). SVN revision: 33448
2008-01-10 23:33:57 -08:00
XShapeCombineMask(_ecore_x_disp, win, ShapeBounding, 0, 0, mask, ShapeSet);
#endif
}