Bug#731216: xbattbar: reposition the bar on screen resize

2014-12-17 Thread Andrew Shadura
Hello,

On Wed, 30 Apr 2014 20:22:09 +0400
Dmitry E. Oboukhov un...@debian.org wrote:

 I haven't seen it yet (I've just applied Your patches and checked
 xbattbar).
 may be tonight :)

Well, and now we're in a deep freeze and the version in testing is
broken :(

-- 
Cheers,
  Andrew


signature.asc
Description: PGP signature


Bug#731216: xbattbar: reposition the bar on screen resize

2014-04-30 Thread Dmitry E. Oboukhov
Hi!

The patch doesn't work at my host (window hangs up).

PS:
I applied the other Your patch now.

On 10:08 Tue 03 Dec , Andrew Shadura wrote:
 Package: xbattbar
 Version: 1.4.4-1

 Hello,

 Attached is the patch which enables xbattbar to react to screen size
 changes. However, probably, the proper way would be not to place in to
 the edge of a root window, but to the edge of primary screen; that
 would require to use Xinerama API or XRandR.

 --
 Cheers,
 Andrew

 Subject: Resize bar when the root window size changes.
 From: Andrew Shadura andre...@debian.org

 --- a/xbattbar.c
 +++ b/xbattbar.c
 @@ -92,6 +92,7 @@ int bi_thick = BI_THICKNESS;/* t
 int bi_interval = PollingInterval;  /* interval of polling APM */

 Display *disp;
 +Window root;
 Window winbar;  /* bar indicator window */
 Window winstat = -1;/* battery status window */
 GC gcbar;
 @@ -163,21 +164,10 @@ Status AllocColor(char *name, unsigned l
 return(status);
 }

 -/*
 - * InitDisplay:
 - * create small window in top or bottom
 - */
 -void InitDisplay(void)
 +void ReshapeWindow(void)
 {
 -  Window root;
 int x,y;
 unsigned int border,depth;
 -  XSetWindowAttributes att;
 -
 -  if((disp = XOpenDisplay(NULL)) == NULL) {
 -  fprintf(stderr, xbattbar: can't open display.\n);
 -  _exit(1);
 -  }

 if(XGetGeometry(disp, DefaultRootWindow(disp), root, x, y,
 width, height, border, depth) == 0) {
 @@ -185,14 +175,6 @@ void InitDisplay(void)
 _exit(1);
 }

 -  if (!AllocColor(ONIN_C,onin) ||
 -   !AllocColor(OFFOUT_C,offout) ||
 -   !AllocColor(OFFIN_C,offin) ||
 -   !AllocColor(ONOUT_C,onout)) {
 -fprintf(stderr, xbattbar: can't allocate color resources\n);
 -_exit(1);
 -  }
 -
 switch (bi_direction) {
 case BI_Top: /* (0,0) - (width, bi_thick) */
 bi_width = width;
 @@ -218,6 +200,30 @@ void InitDisplay(void)
 bi_x = width - bi_thick;
 bi_y = 0;
 }
 +}
 +
 +/*
 + * InitDisplay:
 + * create small window in top or bottom
 + */
 +void InitDisplay(void)
 +{
 +  XSetWindowAttributes att;
 +
 +  if((disp = XOpenDisplay(NULL)) == NULL) {
 +  fprintf(stderr, xbattbar: can't open display.\n);
 +  _exit(1);
 +  }
 +
 +  if (!AllocColor(ONIN_C,onin) ||
 +   !AllocColor(OFFOUT_C,offout) ||
 +   !AllocColor(OFFIN_C,offin) ||
 +   !AllocColor(ONOUT_C,onout)) {
 +fprintf(stderr, xbattbar: can't allocate color resources\n);
 +_exit(1);
 +  }
 +
 +  ReshapeWindow();

 winbar = XCreateSimpleWindow(disp, DefaultRootWindow(disp),
 bi_x, bi_y, bi_width, bi_height,
 @@ -314,6 +320,7 @@ main(int argc, char **argv)
 signal(SIGALRM, (void *)(battery_check));
 battery_check();
 XSelectInput(disp, winbar, myEventMask);
 +  XSelectInput(disp, root, StructureNotifyMask);
 while (1) {
 XWindowEvent(disp, winbar, myEventMask, theEvent);
 switch (theEvent.type) {
 @@ -342,6 +349,12 @@ main(int argc, char **argv)
 xbattbar: unknown event (%d) captured\n,
 theEvent.type);
 }
 +XWindowEvent(disp, root, StructureNotifyMask, theEvent);
 +switch (theEvent.type) {
 +case ConfigureNotify:
 +  ReshapeWindow();
 +  XMoveResizeWindow(disp, winbar, bi_x, bi_y, bi_width, bi_height);
 +}
 }
 }
-- 

. ''`.   Dmitry E. Oboukhov
: :’  :   email: un...@debian.org jabber://un...@uvw.ru
`. `~’  GPGKey: 1024D / F8E26537 2006-11-21
  `- 1B23 D4F8 8EC0 D902 0555  E438 AB8C 00CF F8E2 6537


signature.asc
Description: Digital signature


Bug#731216: xbattbar: reposition the bar on screen resize

2014-04-30 Thread Andrew Shadura
Hi,

On Apr 30, 2014 4:53 PM, Dmitry E. Oboukhov un...@debian.org wrote:
 The patch doesn't work at my host (window hangs up).

Any idea why? I've had it applied since then and haven't encountered any
issues whatsoever.

-- 
Cheers,
  Andrew


Bug#731216: xbattbar: reposition the bar on screen resize

2014-04-30 Thread Dmitry E. Oboukhov

 On Apr 30, 2014 4:53 PM, Dmitry E. Oboukhov un...@debian.org wrote:
 The patch doesn't work at my host (window hangs up).

 Any idea why? I've had it applied since then and haven't encountered any 
 issues
 whatsoever.

I haven't seen it yet (I've just applied Your patches and checked
xbattbar).
may be tonight :)
-- 

. ''`.   Dmitry E. Oboukhov
: :’  :   email: un...@debian.org jabber://un...@uvw.ru
`. `~’  GPGKey: 1024D / F8E26537 2006-11-21
  `- 1B23 D4F8 8EC0 D902 0555  E438 AB8C 00CF F8E2 6537


signature.asc
Description: Digital signature


Bug#731216: xbattbar: reposition the bar on screen resize

2013-12-03 Thread Andrew Shadura
Package: xbattbar
Version: 1.4.4-1

Hello,

Attached is the patch which enables xbattbar to react to screen size
changes. However, probably, the proper way would be not to place in to
the edge of a root window, but to the edge of primary screen; that
would require to use Xinerama API or XRandR.

-- 
Cheers,
  Andrew
Subject: Resize bar when the root window size changes.
From: Andrew Shadura andre...@debian.org

--- a/xbattbar.c
+++ b/xbattbar.c
@@ -92,6 +92,7 @@ int bi_thick = BI_THICKNESS;/* t
 int bi_interval = PollingInterval;  /* interval of polling APM */
 
 Display *disp;
+Window root;
 Window winbar;  /* bar indicator window */
 Window winstat = -1;/* battery status window */
 GC gcbar;
@@ -163,21 +164,10 @@ Status AllocColor(char *name, unsigned l
   return(status);
 }
 
-/*
- * InitDisplay:
- * create small window in top or bottom
- */
-void InitDisplay(void)
+void ReshapeWindow(void)
 {
-  Window root;
   int x,y;
   unsigned int border,depth;
-  XSetWindowAttributes att;
-
-  if((disp = XOpenDisplay(NULL)) == NULL) {
-  fprintf(stderr, xbattbar: can't open display.\n);
-  _exit(1);
-  }
 
   if(XGetGeometry(disp, DefaultRootWindow(disp), root, x, y,
  width, height, border, depth) == 0) {
@@ -185,14 +175,6 @@ void InitDisplay(void)
 _exit(1);
   }
 
-  if (!AllocColor(ONIN_C,onin) ||
-   !AllocColor(OFFOUT_C,offout) ||
-   !AllocColor(OFFIN_C,offin) ||
-   !AllocColor(ONOUT_C,onout)) {
-fprintf(stderr, xbattbar: can't allocate color resources\n);
-_exit(1);
-  }
-
   switch (bi_direction) {
   case BI_Top: /* (0,0) - (width, bi_thick) */
 bi_width = width;
@@ -218,6 +200,30 @@ void InitDisplay(void)
 bi_x = width - bi_thick;
 bi_y = 0;
   }
+}
+
+/*
+ * InitDisplay:
+ * create small window in top or bottom
+ */
+void InitDisplay(void)
+{
+  XSetWindowAttributes att;
+
+  if((disp = XOpenDisplay(NULL)) == NULL) {
+  fprintf(stderr, xbattbar: can't open display.\n);
+  _exit(1);
+  }
+
+  if (!AllocColor(ONIN_C,onin) ||
+   !AllocColor(OFFOUT_C,offout) ||
+   !AllocColor(OFFIN_C,offin) ||
+   !AllocColor(ONOUT_C,onout)) {
+fprintf(stderr, xbattbar: can't allocate color resources\n);
+_exit(1);
+  }
+
+  ReshapeWindow();
 
   winbar = XCreateSimpleWindow(disp, DefaultRootWindow(disp),
   bi_x, bi_y, bi_width, bi_height,
@@ -314,6 +320,7 @@ main(int argc, char **argv)
   signal(SIGALRM, (void *)(battery_check));
   battery_check();
   XSelectInput(disp, winbar, myEventMask);
+  XSelectInput(disp, root, StructureNotifyMask);
   while (1) {
 XWindowEvent(disp, winbar, myEventMask, theEvent);
 switch (theEvent.type) {
@@ -342,6 +349,12 @@ main(int argc, char **argv)
 	  xbattbar: unknown event (%d) captured\n,
 	  theEvent.type);
 }
+XWindowEvent(disp, root, StructureNotifyMask, theEvent);
+switch (theEvent.type) {
+case ConfigureNotify:
+  ReshapeWindow();
+  XMoveResizeWindow(disp, winbar, bi_x, bi_y, bi_width, bi_height);
+}
   }
 }
 



signature.asc
Description: PGP signature