Revert "link mute/volumeup/volumedown keys to respective amixer commands"
[notion/jeffpc.git] / mod_tiling / panehandle.c
blobba6defa6833d69589a5d4ae0f87bc5401d05f069
1 /*
2 * ion/mod_tiling/panehandle.c
4 * Copyright (c) Tuomo Valkonen 1999-2009.
6 * See the included file LICENSE for details.
7 */
9 #include <string.h>
11 #include <libtu/objp.h>
12 #include <libtu/minmax.h>
13 #include <ioncore/common.h>
14 #include <ioncore/global.h>
15 #include <ioncore/event.h>
16 #include <ioncore/gr.h>
17 #include <ioncore/regbind.h>
18 #include "panehandle.h"
19 #include "main.h"
22 /*{{{ Init/deinit */
25 static void panehandle_getbrush(WPaneHandle *pwin)
27 GrBrush *brush=gr_get_brush(pwin->wwin.win,
28 region_rootwin_of((WRegion*)pwin),
29 "pane");
31 if(brush!=NULL){
32 if(pwin->brush!=NULL)
33 grbrush_release(pwin->brush);
35 pwin->brush=brush;
37 grbrush_get_border_widths(brush, &(pwin->bdw));
38 grbrush_enable_transparency(brush, GR_TRANSPARENCY_YES);
43 bool panehandle_init(WPaneHandle *pwin, WWindow *parent, const WFitParams *fp)
45 pwin->brush=NULL;
46 pwin->bline=GR_BORDERLINE_NONE;
47 pwin->splitfloat=NULL;
49 if(!window_init(&(pwin->wwin), parent, fp, "WPanelHandle"))
50 return FALSE;
52 panehandle_getbrush(pwin);
54 if(pwin->brush==NULL){
55 GrBorderWidths bdw=GR_BORDER_WIDTHS_INIT;
56 memcpy(&(pwin->bdw), &bdw, sizeof(bdw));
59 window_select_input(&(pwin->wwin), IONCORE_EVENTMASK_NORMAL);
61 return TRUE;
65 WPaneHandle *create_panehandle(WWindow *parent, const WFitParams *fp)
67 CREATEOBJ_IMPL(WPaneHandle, panehandle, (p, parent, fp));
71 void panehandle_deinit(WPaneHandle *pwin)
73 assert(pwin->splitfloat==NULL);
75 if(pwin->brush!=NULL){
76 grbrush_release(pwin->brush);
77 pwin->brush=NULL;
80 window_deinit(&(pwin->wwin));
84 /*}}}*/
87 /*{{{ Drawing */
90 static void panehandle_updategr(WPaneHandle *pwin)
92 panehandle_getbrush(pwin);
93 region_updategr_default((WRegion*)pwin);
97 static void panehandle_draw(WPaneHandle *pwin, bool complete)
99 WRectangle g;
101 if(pwin->brush==NULL)
102 return;
104 g.x=0;
105 g.y=0;
106 g.w=REGION_GEOM(pwin).w;
107 g.h=REGION_GEOM(pwin).h;
109 grbrush_begin(pwin->brush, &g, (complete ? 0 : GRBRUSH_NO_CLEAR_OK));
111 grbrush_draw_borderline(pwin->brush, &g, pwin->bline);
113 grbrush_end(pwin->brush);
117 /*}}}*/
120 /*{{{ The class */
123 static DynFunTab panehandle_dynfuntab[]={
124 {region_updategr, panehandle_updategr},
125 {window_draw, panehandle_draw},
126 END_DYNFUNTAB,
130 IMPLCLASS(WPaneHandle, WWindow, panehandle_deinit, panehandle_dynfuntab);
133 /*}}}*/