@@ -11,9 +11,12 @@ const Tooltips = imports.ui.tooltips;
1111const Settings = imports . ui . settings ;
1212const ModalDialog = imports . ui . modalDialog ;
1313const Pango = imports . gi . Pango ;
14+ const Cinnamon = imports . gi . Cinnamon ;
1415
1516const MIN_SWITCH_INTERVAL_MS = 220 ;
1617
18+ const ICON_SIZE = 16 ; // TODO: size according to the size of the applet (or panel)
19+
1720class WorkspaceButton {
1821 constructor ( index , applet ) {
1922 this . index = index ;
@@ -82,6 +85,41 @@ class WorkspaceGraph extends WorkspaceButton {
8285
8386 this . graphArea . set_size ( 1 , 1 ) ;
8487 this . graphArea . connect ( 'repaint' , Lang . bind ( this , this . onRepaint ) ) ;
88+
89+ this . window_icons = { } ;
90+ }
91+
92+ getIconForMetaWindow ( metaWindow ) {
93+ let metaWindowId = metaWindow . get_id ( ) ;
94+
95+ if ( this . window_icons [ metaWindowId ] )
96+ return this . window_icons [ metaWindowId ] ;
97+
98+ let iconActor = null ;
99+ let app = null ;
100+
101+ if ( metaWindow . _expoApp ) {
102+ app = metaWindow . _expoApp ;
103+ } else {
104+ let tracker = Cinnamon . WindowTracker . get_default ( ) ;
105+ app = tracker . get_window_app ( metaWindow ) ;
106+ metaWindow . _expoApp = app ;
107+ }
108+
109+ if ( app ) {
110+ iconActor = app . create_icon_texture_for_window ( ICON_SIZE , metaWindow ) ;
111+ }
112+
113+ if ( ! iconActor ) {
114+ iconActor = new St . Icon ( {
115+ icon_name : 'applications-other' ,
116+ icon_type : St . IconType . FULLCOLOR ,
117+ icon_size : ICON_SIZE
118+ } ) ;
119+ }
120+
121+ this . window_icons [ metaWindowId ] = iconActor ;
122+ return this . window_icons [ metaWindowId ] ;
85123 }
86124
87125 getSizeAdjustment ( actor , vertical ) {
@@ -153,10 +191,19 @@ class WorkspaceGraph extends WorkspaceButton {
153191
154192 Clutter . cairo_set_source_color ( cr , windowBorderColor ) ;
155193 cr . rectangle ( scaled_rect . x , scaled_rect . y , scaled_rect . width , scaled_rect . height ) ;
194+
156195 cr . strokePreserve ( ) ;
157196
158197 Clutter . cairo_set_source_color ( cr , windowBackgroundColor ) ;
159198 cr . fill ( ) ;
199+
200+ //TODO: check settings for showing icon before
201+
202+ let icon = this . getIconForMetaWindow ( metaWindow ) ;
203+
204+ if ( icon ) {
205+ // TODO: draw icon in the frame
206+ }
160207 }
161208
162209 onRepaint ( area ) {
@@ -210,6 +257,11 @@ class WorkspaceGraph extends WorkspaceButton {
210257 else
211258 this . actor . remove_style_pseudo_class ( 'active' ) ;
212259 }
260+
261+ destroy ( ) {
262+ super . destroy ( ) ;
263+ this . window_icons = null ;
264+ }
213265}
214266
215267class SimpleButton extends WorkspaceButton {
0 commit comments