gboolean on_title_pressed(GtkWidget *title, GdkEventButton *event, WindowckPlugin *wckp) { if (!wckp->win->controlwindow) return FALSE; if (event->button == 1 && (wnck_window_get_window_type (wckp->win->controlwindow) != WNCK_WINDOW_DESKTOP)) { /* double/tripple click */ if (event->type == GDK_2BUTTON_PRESS || event->type == GDK_3BUTTON_PRESS) { toggle_maximize(wckp->win->controlwindow); } else /* left-click */ { wnck_window_activate(wckp->win->controlwindow, gtk_get_current_event_time()); } return TRUE; } if (event->button == 3) { /* right-click */ wnck_window_activate(wckp->win->controlwindow, gtk_get_current_event_time()); /* let the panel show the menu */ return TRUE; } return FALSE; }
static gboolean icon_clicked (GtkWidget *icon, GdkEventButton *event, WTApplet *wtapplet) { if (event->button != 1) return FALSE; WnckWindow *controlledwindow; if (wtapplet->prefs->only_maximized) { controlledwindow = wtapplet->umaxedwindow; } else { controlledwindow = wtapplet->activewindow; } // single click: if (controlledwindow) { wnck_window_activate(controlledwindow, gtk_get_current_event_time()); } // double click: if (event->type == GDK_2BUTTON_PRESS) { wnck_window_close(controlledwindow, gtk_get_current_event_time()); } return TRUE; }
int main(int argc, char **argv) { WnckScreen *screen; WnckWindow *active_window; GList *window_l; gdk_init(&argc, &argv); screen = wnck_screen_get_default(); sleep(5); wnck_screen_force_update(screen); active_window = wnck_screen_get_active_window(screen); for (window_l = wnck_screen_get_windows(screen); window_l != NULL; window_l = window_l->next) { WnckWindow *window = WNCK_WINDOW(window_l->data); if (strcmp(wnck_window_get_name(window), "Terminal") == 0) { wnck_window_activate(window, (guint32)time(NULL)); break; } // g_print("Name: '%s', PID: %d(%lu)%s\n", wnck_window_get_name(window), // wnck_window_get_pid(window), wnck_window_get_xid(window), // window == active_window ? " (active)" : ""); } return 0; }
static gboolean activate_window (GtkWidget *widget) { gint active; TaskItemPrivate *priv; g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE); g_return_val_if_fail (TASK_IS_ITEM (widget), FALSE); priv = TASK_ITEM (widget)->priv; g_return_val_if_fail (WNCK_IS_WINDOW (priv->window), FALSE); active = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "drag-true")); if (active) { WnckWindow *window; window = priv->window; if (WNCK_IS_WINDOW (window)) wnck_window_activate (window, time (NULL)); } g_object_set_data (G_OBJECT (widget), "drag-true", GINT_TO_POINTER (0)); return FALSE; }
static gboolean title_clicked (GtkWidget *title, GdkEventButton *event, WTApplet *wtapplet) { // only allow left and right mouse button //if (event->button != 1 && event->button != 3) return FALSE; WnckWindow *controlledwindow; if (wtapplet->prefs->only_maximized) { controlledwindow = wtapplet->umaxedwindow; } else { controlledwindow = wtapplet->activewindow; } if (!controlledwindow) return FALSE; // single click (left/right) if (event->button == 1) { // left-click wnck_window_activate(controlledwindow, gtk_get_current_event_time()); if (event->type==GDK_2BUTTON_PRESS || event->type==GDK_3BUTTON_PRESS) { // double/tripple click //if (event->type==GDK_2BUTTON_PRESS) { if (wnck_window_is_maximized(controlledwindow)) { wnck_window_unmaximize(controlledwindow); } else { wnck_window_maximize(controlledwindow); } } } else if (event->button == 3) { // right-click if (wtapplet->prefs->show_window_menu) { wnck_window_activate(controlledwindow, gtk_get_current_event_time()); GtkMenu *window_menu = GTK_MENU(wnck_action_menu_new(controlledwindow)); gtk_menu_popup(window_menu, NULL, NULL, NULL, NULL, event->button, gtk_get_current_event_time()); //TODO: somehow alter the panel action menu to also display the wnck_action_menu ! } else { return FALSE; } } else { return FALSE; } return TRUE; }
int c_focus(lua_State *lua) { int top = lua_gettop(lua); if (top != 0) { luaL_error(lua, "focus: %s", no_indata_expected_error); return 0; } WnckWindow *window = get_current_window(); if (window) { wnck_window_activate(window, GDK_CURRENT_TIME); } return 0; }
static void wnck_selector_activate_window (WnckWindow *window) { WnckWorkspace *workspace; guint32 timestamp; /* We're in an activate callback, so gtk_get_current_time() works... */ timestamp = gtk_get_current_event_time (); /* FIXME: THIS IS SICK AND WRONG AND BUGGY. See the end of * http://mail.gnome.org/archives/wm-spec-list/2005-July/msg00032.html * There should only be *one* activate call. */ workspace = wnck_window_get_workspace (window); if (workspace) wnck_workspace_activate (workspace, timestamp); wnck_window_activate (window, timestamp); }
guint32 raise_window(gpointer data) { guint32 status; GList* list; WnckWindow* window; WnckApplication* app; control_plugin_t* self = (control_plugin_t*) data; if (!self) return CTRL_INVALID_SELF; if (!self->vcwm.screen) return CTRL_INVALID_SCREEN; status = CTRL_WINDOW_NOT_FOUND; list = wnck_screen_get_windows(self->vcwm.screen); for (list; list != NULL; list = list->next) { window = WNCK_WINDOW(list->data); if (!window) continue; app = wnck_window_get_application(window); if (!app) continue; if (strcmp(wnck_application_get_name(app), "gedit") == 0) { wnck_window_activate(window, (guint32) time(NULL)); status = CTRL_SUCCESS; break; } } return status; }
static gboolean on_task_item_button_released (GtkWidget *widget, GdkEventButton *event, TaskItem *item) { WnckWindow *window; WnckScreen *screen; WnckWorkspace *workspace; TaskItemPrivate *priv; g_return_val_if_fail (TASK_IS_ITEM (item), TRUE); priv = item->priv; window = priv->window; g_return_val_if_fail (WNCK_IS_WINDOW (window), TRUE); screen = priv->screen; workspace = wnck_window_get_workspace (window); if (event->button == 1) { if (WNCK_IS_WORKSPACE (workspace) && workspace != wnck_screen_get_active_workspace (screen)) { wnck_workspace_activate (workspace, GDK_CURRENT_TIME); } if (wnck_window_is_active (window)) { wnck_window_minimize (window); } else { wnck_window_activate (window, GDK_CURRENT_TIME); } } return TRUE; }
gboolean on_title_pressed(GtkWidget *title, GdkEventButton *event, WindowckPlugin *wckp) { if (!wckp->win->controlwindow) return FALSE; if (event->button == 1 && (wnck_window_get_window_type (wckp->win->controlwindow) != WNCK_WINDOW_DESKTOP)) { /* double/tripple click */ if (event->type == GDK_2BUTTON_PRESS || event->type == GDK_3BUTTON_PRESS) { toggle_maximize(wckp->win->controlwindow); } else /* left-click */ { wnck_window_activate(wckp->win->controlwindow, gtk_get_current_event_time()); // WnckScreen *screen = wnck_screen_get_default (); // wnck_screen_force_update (screen); WnckWindow *active_window = wckp->win->controlwindow; if (!wnck_window_is_maximized(active_window)) return TRUE; GdkDisplay *gdkdisp = gdk_display_get_default (); // Gdk 3 // GdkDevice *mouse = gdk_device_manager_get_client_pointer(gdk_display_get_device_manager(gdkdisp)); GdkDevice *mouse = gdk_device_get_core_pointer(); Display *d = gdk_x11_display_get_xdisplay(gdkdisp); XEvent xev; Atom netMoveResize = XInternAtom(d, "_NET_WM_MOVERESIZE", FALSE); xev.xclient.type = ClientMessage; xev.xclient.message_type = netMoveResize; xev.xclient.display = d; xev.xclient.window = wnck_window_get_xid(active_window); xev.xclient.format = 32; // Gdk 3 // int x, y; // gdk_device_get_position(mouse, NULL, &x, &y); // TODO: Provide a second argument to gdk_device_get_state gdouble xy[2]; gdk_device_get_state(mouse, NULL, xy, NULL); xev.xclient.data.l[0] = xy[0]; xev.xclient.data.l[1] = xy[1]; xev.xclient.data.l[2] = 8; // _NET_WM_MOVERESIZE_MOVE xev.xclient.data.l[3] = Button1; xev.xclient.data.l[4] = 0; XUngrabPointer(d, CurrentTime); XSendEvent(d, RootWindow(d, 0), FALSE, SubstructureRedirectMask | SubstructureNotifyMask, &xev); } return TRUE; } if (event->button == 3) { /* right-click */ wnck_window_activate(wckp->win->controlwindow, gtk_get_current_event_time()); /* let the panel show the menu */ return TRUE; } return FALSE; }
static void utterance_loop(int argc,char *argv[]) { int16 adbuf[4096]; int32 k, fr, ts, rem; char *hyp; cont_ad_t *cont; int count=0,i=1,flag; char word[256]; /* Initialize continuous listening module */ if ((cont = cont_ad_init (ad, ad_read)) == NULL) E_FATAL("cont_ad_init failed\n"); if (ad_start_rec (ad) < 0) E_FATAL("ad_start_rec failed\n"); if (cont_ad_calib (cont) < 0) E_FATAL("cont_ad_calib failed\n"); for (;;) { /* Indicate listening for next utterance */ printf ("READY....\n"); fflush (stdout); fflush (stderr); /* Await data for next utterance */ while ((k = cont_ad_read (cont, adbuf, 4096)) == 0) sleep_msec(200); if (k < 0) E_FATAL("cont_ad_read failed\n"); /* * Non-zero amount of data received; start recognition of new utterance. * NULL argument to uttproc_begin_utt => automatic generation of utterance-id. */ if (uttproc_begin_utt (NULL) < 0) E_FATAL("uttproc_begin_utt() failed\n"); uttproc_rawdata (adbuf, k, 0); printf ("Listening...\n"); fflush (stdout); /* Note timestamp for this first block of data */ ts = cont->read_ts; /* Decode utterance until end (marked by a "long" silence, >1sec) */ for (;;) { /* Read non-silence audio data, if any, from continuous listening module */ if ((k = cont_ad_read (cont, adbuf, 4096)) < 0) E_FATAL("cont_ad_read failed\n"); if (k == 0) { /* * No speech data available; check current timestamp with most recent * speech to see if more than 1 sec elapsed. If so, end of utterance. */ if ((cont->read_ts - ts) > DEFAULT_SAMPLES_PER_SEC) break; } else { /* New speech data received; note current timestamp */ ts = cont->read_ts; } /* * Decode whatever data was read above. NOTE: Non-blocking mode!! * rem = #frames remaining to be decoded upon return from the function. */ rem = uttproc_rawdata (adbuf, k, 0); /* If no work to be done, sleep a bit */ if ((rem == 0) && (k == 0)) sleep_msec (20); } /* * Utterance ended; flush any accumulated, unprocessed A/D data and stop * listening until current utterance completely decoded */ ad_stop_rec (ad); while (ad_read (ad, adbuf, 4096) >= 0); cont_ad_reset (cont); printf ("Stopped listening, please wait...\n"); fflush (stdout); #if 0 /* Power histogram dump (FYI) */ cont_ad_powhist_dump (stdout, cont); #endif /* Finish decoding, obtain and print result */ uttproc_end_utt (); if (uttproc_result (&fr, &hyp, 1) < 0) E_FATAL("uttproc_result failed\n"); /*obtaining the results*/ sscanf (hyp, "%s", word); printf ("%d: %s\n", fr,word); fflush (stdout); win=wnck_screen_get_active_window(scr); tmp=wnck_screen_get_windows(wnck_window_get_screen(win)); i=g_list_index(tmp,win);/*the place value of window in the list*/ printf("<<<<<<<<<<<<<<>>>>>>>>>>>>>>i:%d,%s\n\n\n",i,wnck_window_get_name(win)); count=0; while(tmp!=NULL) { printf("%d:%s\n\n",count,wnck_window_get_name(tmp->data)); tmp=tmp->next;count++; } /*comparison and action for DAKKU */ if(strcmp(word,"PADU")==0) g_spawn_command_line_async("totem --play",NULL); if(strcmp(word,"EMACS")==0) g_spawn_command_line_async("emacs",NULL); if(strcmp(word,"SAMAYAM")==0) g_spawn_command_line_async(DHVANISCRIPT,NULL); if(strcmp(word,"VALAPARATHU")==0) g_spawn_command_line_async("epiphany",NULL); if(strcmp(word,"EAZHUTHIDAM")==0) g_spawn_command_line_async("gedit",NULL); /*Minimizing current active window*/ if (strcmp (word, "CHURUKKU") == 0) wnck_window_minimize(win); /*Moving focus(active window)towards the left of the panel.The active window is changed to the next normal window on the left.effect of alt+tab key press*/ if(strcmp(word,"ADUTHATHU")==0) { win=wnck_screen_get_active_window(scr); tmp=wnck_screen_get_windows(wnck_window_get_screen(win)); while(tmp!=NULL)/*while traces the current active window through the list*/ { printf("tracing:current:%s\n\ntmp:%s\n\n",wnck_window_get_name(win),wnck_window_get_name(tmp->data)); if(tmp->data==win) { printf("BREAKED with tmp:%s\n",wnck_window_get_name(tmp->data)); break; } tmp=tmp->next; } if(tmp==NULL){printf("BULL SHIT GIVE A WINDOW IN THE LIST\n\n");}//exit(1);} if(tmp->next==NULL)/*shifting back to the first window by refreshing the list*/ tmp=wnck_screen_get_windows(wnck_window_get_screen(win)); else tmp=tmp->next; printf("cuow:%s\n\n",wnck_window_get_name(tmp->data)); while(tmp!=NULL) { printf("tmp in while:%s\n\n",wnck_window_get_name(tmp->data)); if(wnck_window_get_window_type(tmp->data)==WNCK_WINDOW_NORMAL) { wnck_window_activate(tmp->data,0); flag=1; break; } else tmp=tmp->next; } if(flag==0) { printf("FLAG==0 DETECTED:\n"); tmp=wnck_screen_get_windows(wnck_window_get_screen(win)); while(tmp!=NULL) { printf("tmp in last while:%s\n",wnck_window_get_name(tmp->data)); if(wnck_window_get_window_type(tmp->data)==WNCK_WINDOW_NORMAL) { wnck_window_activate(tmp->data,0); break; } else tmp=tmp->next; } } } if(strcmp(word,"VALUTHAKKU")==0) { if(wnck_window_get_window_type(win)!= WNCK_WINDOW_NORMAL) { if(wnck_window_get_window_type(wnck_screen_get_previously_active_window(scr))==WNCK_WINDOW_NORMAL) win=wnck_screen_get_previously_active_window(scr); } wnck_window_unminimize(win,0); } while(gtk_events_pending())/*gtk probing and refreshing the win and tmp*/ { gtk_main_iteration(); win=wnck_screen_get_active_window(scr); tmp=wnck_screen_get_windows(wnck_window_get_screen(win)); } /* Resume A/D recording for next utterance */ if (ad_start_rec (ad) < 0) E_FATAL("ad_start_rec failed\n"); } cont_ad_close (cont); }