Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 4789 Details for
Bug 8508
contrib ebuild for the iDesk desktop icon program
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
idesk-glow-lock-0.3.diff
idesk-glow-lock-0.3.diff (text/plain), 14.54 KB, created by
Brad Cowan (RETIRED)
on 2002-10-18 02:28:00 UTC
(
hide
)
Description:
idesk-glow-lock-0.3.diff
Filename:
MIME Type:
Creator:
Brad Cowan (RETIRED)
Created:
2002-10-18 02:28:00 UTC
Size:
14.54 KB
patch
obsolete
>diff -u idesk-0.3/Desk.cc idesk-unified/Desk.cc >--- idesk-0.3/Desk.cc 2002-09-10 18:23:18.000000000 +1000 >+++ idesk-unified/Desk.cc 2002-10-14 18:40:30.000000000 +1000 >@@ -4,7 +4,9 @@ > Dpy = XOpenDisplay( NULL ); > Root = DefaultRootWindow( Dpy ); > Data = Imlib_init( Dpy ); >- >+ >+ SpareRoot = Imlib_create_image_from_drawable( Data, Root, 0, 0, 0, WidthOfScreen( DefaultScreenOfDisplay( Dpy ) ), HeightOfScreen( DefaultScreenOfDisplay( Dpy ) ) ); >+ > LoadOptions(); > LoadIcons(); > ArrangeIcons(); >@@ -12,6 +14,7 @@ > } > > Desk::~Desk() { >+ Imlib_kill_image( Data, SpareRoot ); > } > > >@@ -26,10 +29,17 @@ > printf("Can't find config file, or missing 'Config' table in the config file.\n"); > exit(-1); > } >+ delete Db; > > Font = XftFontOpen( Dpy, DefaultScreen(Dpy), XFT_FAMILY, XftTypeString, (char*)Config->Query("FontName").c_str(), XFT_SIZE, XftTypeDouble, (double)atoi(Config->Query("FontSize").c_str()), NULL ); > XftColorAllocName( Dpy, DefaultVisual(Dpy,DefaultScreen(Dpy)), DefaultColormap(Dpy,DefaultScreen(Dpy)), (char*)Config->Query("FontColor").c_str(), &Fore ); > if(!Font) { printf("Couldn't find font.\n"); exit(-1); } >+ >+ Transparency = atoi( (char*)Config->Query( "Transparency" ).c_str() ); >+ >+ if( !strcmp( ( char * )Config->Query( "Locked" ).c_str(), "true" ) ) LockDesk(); >+ else UnlockDesk(); >+ > delete Config; > } > >@@ -47,10 +57,18 @@ > for(int i=0; i<FileCount; i++) { > FileName = DirName + Files[i]->d_name; > IconDb = new Database(FileName); >- if(!(IconTb = IconDb->Query("Icon"))) continue; >- AddIcon( (char*)FileName.c_str(), (char*)IconTb->Query("Icon").c_str(), (char*)IconTb->Query("Caption").c_str(), (char*)IconTb->Query("Command").c_str(), atoi(IconTb->Query("X").c_str()), atoi(IconTb->Query("Y").c_str()) ); >+ if(!(IconTb = IconDb->Query("Icon"))) >+ { >+ free( Files[ i ] ); >+ delete IconDb; >+ continue; >+ } >+ AddIcon( (char*)FileName.c_str(), (char*)IconTb->Query("Icon").c_str(), (char*)IconTb->Query("Caption").c_str(), (char*)IconTb->Query("Command").c_str(), atoi(IconTb->Query("X").c_str()), atoi(IconTb->Query("Y").c_str()) ); >+ free( Files[ i ] ); > delete IconDb; >+ delete IconTb; > } >+ free( Files ); > } > > >@@ -76,13 +94,27 @@ > delete IconDb; > } > >+ >+ void Desk::LockDesk() { >+ Locked = true; >+ } >+ >+ >+ void Desk::UnlockDesk() { >+ Locked = false; >+ } >+ >+ >+ bool Desk::IsLocked() { >+ return Locked; >+ } > > void Desk::AddIcon( char *File, char *F, char *Caption, char *Command, int X, int Y ) { > Icon *I = new Icon( this, File, F, Caption, Command, X, Y ); > Icons.push_back( I ); > } > >- >+ > void Desk::ArrangeIcons() { > int MaxW = 0; > int IconX, IconY = 20; >@@ -150,14 +182,23 @@ > > for(;;) { > XNextEvent( Dpy, &Ev ); >+ >+ if( GetTransparency() ) >+ switch( Ev.type ) { >+ case EnterNotify: >+ case LeaveNotify: >+ if( Icon *I = FindIcon( Ev.xmotion.window ) ) { >+ I->TwiddleGlow(); >+ } break; >+ } >+ > switch( Ev.type ) { > > case ButtonPress: > if( Icon *I = FindIcon( Ev.xbutton.window ) ) { >- if( Ev.xbutton.button == Button1 ) I->Drag( &Ev ); >+ if( Ev.xbutton.button == Button1 ) I->Drag( &Ev ); > } break; >- >- >+ > case MotionNotify: > if( Icon *I = FindIcon( Ev.xmotion.window ) ) { > if( I->Dragging ) I->Drag( &Ev ); >@@ -183,3 +224,6 @@ > } > > >+ int Desk::GetTransparency( ) { >+ return( Transparency ); >+ } >diff -u idesk-0.3/Desk.h idesk-unified/Desk.h >--- idesk-0.3/Desk.h 2002-09-10 18:20:14.000000000 +1000 >+++ idesk-unified/Desk.h 2002-10-14 18:30:38.000000000 +1000 >@@ -20,6 +20,8 @@ > private: > Icon *FindIcon( Window Win ); > vector<Icon*> Icons; >+ int Transparency; >+ bool Locked; > > public: > Desk(); >@@ -28,15 +30,20 @@ > void LoadOptions(); > void LoadIcons(); > void AddIcon( char *File, char *F, char *Caption, char *Command, int X, int Y ); >+ void LockDesk(); >+ void UnlockDesk(); >+ bool IsLocked(); > void ArrangeIcons(); > void Execute( char *Command ); > void SaveIcons(); > void SaveIcon( Icon *I ); > void Loop(); >+ int GetTransparency( ); > > Display *Dpy; > Window Root; > ImlibData *Data; >+ ImlibImage *SpareRoot; > > XftFont *Font; > XftColor Fore; >diff -u idesk-0.3/Icon.cc idesk-unified/Icon.cc >--- idesk-0.3/Icon.cc 2002-09-10 18:24:42.000000000 +1000 >+++ idesk-unified/Icon.cc 2002-10-14 18:42:05.000000000 +1000 >@@ -1,74 +1,92 @@ > #include "Icon.h" > #include <iostream> > >- > Icon::Icon( Desk *Dsk, char *File, char *F, char *Cap, char *Com, int X, int Y ) { > XSetWindowAttributes Attr; > ImlibImage *Image; >+ >+ D = Dsk; >+ Command = strdup( Com ); >+ Caption = strdup( Cap ); >+ this->X = X; >+ this->Y = Y; >+ Dragged = Dragging = False; >+ strncpy(FileName, File, 128); >+ FreeAlpha = false; >+ >+ if( LoadPng( F ) == -1 ) { >+ Image = Imlib_load_image( D->Data, F ); >+ if(! Image ) { printf("Couldn't find image %s, bailing.\n", F ); exit(-1); } >+ rgb = Image->rgb_data; >+ alpha = Image->alpha_data; >+ alpha2 = Image->alpha_data; >+ Width = Image->rgb_width; >+ Height = Image->rgb_height; >+ } >+ Attr.override_redirect = True; >+ Attr.event_mask = SubstructureRedirectMask|SubstructureNotifyMask|ButtonPressMask|ButtonReleaseMask|PointerMotionMask|EnterWindowMask|LeaveWindowMask; >+ Win = XCreateWindow( D->Dpy, D->Root, 0, 0, Width, Height, 0, CopyFromParent, CopyFromParent, CopyFromParent, CWOverrideRedirect|CWEventMask, &Attr ); >+ XLowerWindow( D->Dpy, Win ); >+ >+ Attr.event_mask = SubstructureRedirectMask|SubstructureNotifyMask|ButtonPressMask|ButtonReleaseMask|PointerMotionMask|ExposureMask; >+ XftTextExtents8( D->Dpy, D->Font, (XftChar8*)Caption, strlen(Caption), &FontInfo ); >+ Text = XCreateWindow( D->Dpy, D->Root, 0, 0, FontInfo.width + 4, D->Font->height, 0, CopyFromParent, CopyFromParent, CopyFromParent, CWOverrideRedirect|CWEventMask, &Attr ); >+ Draw = XftDrawCreate( D->Dpy, Text, DefaultVisual(D->Dpy,DefaultScreen(D->Dpy)), DefaultColormap(D->Dpy,DefaultScreen(D->Dpy)) ); >+ XLowerWindow( D->Dpy, Text ); >+ } > >- D = Dsk; >- Command = Com; >- Caption = Cap; >- this->X = X; >- this->Y = Y; >- Dragged = Dragging = False; >- strncpy(FileName, File, 128); >- >- if( LoadPng( F ) == -1 ) { >- Image = Imlib_load_image( D->Data, F ); >- if(! Image ) { printf("Couldn't find image %s, bailing.\n", F ); exit(-1); } >- rgb = Image->rgb_data; >- alpha = Image->alpha_data; >- Width = Image->rgb_width; >- Height = Image->rgb_height; >- } >- Attr.override_redirect = True; >- Attr.event_mask = SubstructureRedirectMask|SubstructureNotifyMask|ButtonPressMask|ButtonReleaseMask|PointerMotionMask; >- Win = XCreateWindow( D->Dpy, D->Root, 0, 0, Width, Height, 0, CopyFromParent, CopyFromParent, CopyFromParent, CWOverrideRedirect|CWEventMask, &Attr ); >- XLowerWindow( D->Dpy, Win ); >- >- Attr.event_mask = SubstructureRedirectMask|SubstructureNotifyMask|ButtonPressMask|ButtonReleaseMask|PointerMotionMask|ExposureMask; >- XftTextExtents8( D->Dpy, D->Font, (XftChar8*)Caption, strlen(Caption), &FontInfo ); >- Text = XCreateWindow( D->Dpy, D->Root, 0, 0, FontInfo.width + 4, D->Font->height, 0, CopyFromParent, CopyFromParent, CopyFromParent, CWOverrideRedirect|CWEventMask, &Attr ); >- Draw = XftDrawCreate( D->Dpy, Text, DefaultVisual(D->Dpy,DefaultScreen(D->Dpy)), DefaultColormap(D->Dpy,DefaultScreen(D->Dpy)) ); >- XLowerWindow( D->Dpy, Text ); > >+ Icon::~Icon( ) { >+ free( Command ); >+ free( Caption ); >+ if( FreeAlpha ) { >+ free( alpha ); >+ free( alpha2 ); >+ } > } > > >- void Icon::Update( ) { >+ void Icon::RefreshIcon( ) { >+ ImlibImage *Bg; > unsigned char *bgrgb; >- ImlibImage *New, *Bg, *TextBg; >- int fX, fY, a, alevel; >- >- XUnmapWindow( D->Dpy, Win ); >- XUnmapWindow( D->Dpy, Text ); > >- fY = Y + Height + 4; >- fX = X + ( Width - FontInfo.width )/2; >- TextBg = Imlib_create_image_from_drawable( D->Data, D->Root, 0, fX, fY, FontInfo.width + 4, D->Font->height ); >- Imlib_apply_image( D->Data, TextBg, Text ); >- XMoveWindow( D->Dpy, Text, fX, fY ); >- >- Bg = Imlib_create_image_from_drawable( D->Data, D->Root, 0, X, Y, Width, Height ); >+ Bg = Imlib_crop_and_clone_image( D->Data, D->SpareRoot, X, Y, Width, Height ); > bgrgb = Bg->rgb_data; >- >+ > for( int i=0, a=0; i<(3*Width*Height); i+=3, a++) { >- alevel = alpha[a]; >+ int alevel = alpha[a]; > if( alevel == 0 ) { bgrgb[i] = bgrgb[i+2] = 255; bgrgb[i+1] = 0; continue; } > bgrgb[i+0] = (bgrgb[i+0] * (255-alevel))/255 + (rgb[i+0] * alevel)/255; > bgrgb[i+1] = (bgrgb[i+1] * (255-alevel))/255 + (rgb[i+1] * alevel)/255; > bgrgb[i+2] = (bgrgb[i+2] * (255-alevel))/255 + (rgb[i+2] * alevel)/255; > } >- >- New = Imlib_create_image_from_data( D->Data, bgrgb, Bg->alpha_data, Bg->rgb_width, Bg->rgb_height ); >+ > ImlibColor IClr={255,0,255,0}; >- Imlib_set_image_shape(D->Data, New, &IClr); >- Imlib_apply_image( D->Data, New, Win ); >+ Imlib_set_image_shape(D->Data, Bg, &IClr); >+ Imlib_apply_image( D->Data, Bg, Win ); > >+ Imlib_kill_image( D->Data, Bg ); >+ } >+ >+ >+ void Icon::Update( ) { >+ ImlibImage *TextBg; >+ int fX, fY; >+ >+ XUnmapWindow( D->Dpy, Win ); >+ XUnmapWindow( D->Dpy, Text ); >+ >+ fY = Y + Height + 4; >+ fX = X + ( Width - FontInfo.width )/2; >+ TextBg = Imlib_create_image_from_drawable( D->Data, D->Root, 0, fX, fY, FontInfo.width + 4, D->Font->height ); >+ Imlib_apply_image( D->Data, TextBg, Text ); >+ XMoveWindow( D->Dpy, Text, fX, fY ); >+ >+ RefreshIcon(); >+ > XMapWindow( D->Dpy, Win ); > XMapWindow( D->Dpy, Text ); >- >+ > UpdateText( ); > } > >@@ -79,17 +97,31 @@ > } > > >+ void Icon::TwiddleGlow( ) { >+ unsigned char *atemp; >+ atemp = alpha; >+ alpha = alpha2; >+ alpha2 = atemp; >+ RefreshIcon(); >+ } >+ >+ > void Icon::Drag( XEvent *Ev ) { > static int lX = 0, lY = 0, Time = 0; > int fX, fY; >+ >+ bool locked = D->IsLocked(); > > switch(Ev->type) { >+ > case ButtonPress: >+ if( locked ) break; > lX = Ev->xbutton.x_root; > lY = Ev->xbutton.y_root; > Dragging = True; > break; > case MotionNotify: >+ if( locked ) break; > Dragged = True; > X -= lX - Ev->xmotion.x_root; > Y -= lY - Ev->xmotion.y_root; >@@ -107,6 +139,7 @@ > case ButtonRelease: > if( Ev->xbutton.time - Time <= 200 ) { D->Execute( Command ); Time = 0; } > else Time = Ev->xbutton.time; >+ if( locked ) break; > if( Dragged ) { Update( ); D->SaveIcon(this); } > Dragging=False; > Dragged=False; >@@ -116,7 +149,7 @@ > > > int Icon::LoadPng( char *filename ) { >- unsigned char *ptr, *aptr, **lines, *line, r, g, b, a; >+ unsigned char *ptr, *aptr, *aptr2, **lines, *line, r, g, b, a; > png_structp pngdata; > png_infop pnginfo; > png_uint_32 w, h; >@@ -151,20 +184,23 @@ > rgb = (unsigned char *)malloc( Width * Height * 3 ); > if(! rgb ) { png_destroy_read_struct( &pngdata, NULL, NULL ); return -1; } > alpha = (unsigned char *)malloc( Width * Height ); >- if(! alpha ) { png_destroy_read_struct( &pngdata, NULL, NULL ); return -1; } >+ alpha2 = (unsigned char *)malloc( Width * Height ); >+ if( !alpha || !alpha2 ) { png_destroy_read_struct( &pngdata, NULL, NULL ); return -1; } >+ FreeAlpha = true; > > lines = (unsigned char **)malloc(Height * sizeof(unsigned char *)); >- if(! lines ) { delete(rgb); delete(alpha); png_destroy_read_struct( &pngdata, NULL, NULL ); return -1; } >+ if(! lines ) { delete(rgb); delete(alpha); delete(alpha2); png_destroy_read_struct( &pngdata, NULL, NULL ); return -1; } > for(int i=0; i< Height; i++) { > lines[i] = (unsigned char *)malloc( Width * (sizeof(unsigned char*)) * 4 ); >- if(! lines[i] ) { delete(rgb); delete(alpha); png_destroy_read_struct( &pngdata, NULL, NULL ); return -1; } >+ if(! lines[i] ) { delete(rgb); delete(alpha); delete(alpha2); png_destroy_read_struct( &pngdata, NULL, NULL ); return -1; } > } > > png_read_image( pngdata, lines ); > png_destroy_read_struct( &pngdata, &pnginfo, NULL ); > ptr = rgb; > aptr = alpha; >- >+ aptr2 = alpha2; >+ > for(int y = 0; y < Height; y++) { > line = lines[y]; > for (int x = 0; x < Width; x++) { >@@ -183,7 +219,19 @@ > *ptr++ = r; > *ptr++ = g; > *ptr++ = b; >- *aptr++ = a; >+ >+ // Transparency matrix. >+ if( ( a - D->GetTransparency() ) < 0 ) >+ { >+ *aptr++ = 0; >+ *aptr2++ = a; >+ } >+ else >+ { >+ *aptr++ = a - D->GetTransparency(); >+ *aptr2++ = a; >+ } >+ > } > } > >diff -u idesk-0.3/Icon.h idesk-unified/Icon.h >--- idesk-0.3/Icon.h 2002-09-04 22:14:57.000000000 +1000 >+++ idesk-unified/Icon.h 2002-10-14 18:30:38.000000000 +1000 >@@ -9,6 +9,7 @@ > Desk *D; > char *Command, *Caption; > XGlyphInfo FontInfo; >+ bool FreeAlpha; > > public: > Icon( Desk *Dsk, char *File, char *F, char *Cap, char *Com, int X, int Y ); >@@ -17,9 +18,11 @@ > Window Win, Text; > XftDraw *Draw; > char FileName[128]; >- unsigned char *rgb, *alpha; >+ unsigned char *rgb, *alpha, *alpha2; > int LoadPng( char *filename ); >- void Update( ), UpdateText( ); >+ void Update( ), RefreshIcon( ), UpdateText( ); >+ >+ void TwiddleGlow( ); > > void Drag( XEvent *Ev ); > bool Dragging, Dragged; >diff -u idesk-0.3/README idesk-unified/README >--- idesk-0.3/README 2002-09-10 18:30:53.000000000 +1000 >+++ idesk-unified/README 2002-10-14 18:30:38.000000000 +1000 >@@ -13,3 +13,20 @@ > and introduces a new directory based icon configuration. see > http://dramamine.darktech.org/~nikon/src/ for more info on setting > this up. >+ >+this copy has been patched to add transparancy mouseover support >+and lockable icons: please adjust your ~/.ideskrc to something >+like the following: >+ >+table Config >+ FontName: tahoma >+ FontSize: 8 >+ FontColor: #ffffff >+ PaddingX: 35 >+ PaddingY: 25 >+ Locked: true >+ Transparency: 150 >+end >+ >+Locked is boolean. Transparency is between 0 ( disabled ) and 255 >+( invisible without the mouse ). >\ No newline at end of file
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 8508
:
4276
|
4281
|
4282
|
4283
|
4788
| 4789 |
4790