The last Piast on Polish throne was Kazimierz (Casimir) the Great. He died in the seventies of XIV century I think.
You could have two people on mind: his father, Wladyslaw I Lokietek, or Waclaw III.
The story went like this. After Poland splitted into a number of duchies,
after several attempts of re-uniting it, mostly be Silesian dukes, Przemyslaw II of Major Poland was crowned in 1295. His domain was Major Poland, Pommerania (eastern part, Danzig and Stolp/Gdansk and Slupsk; he got it peacefully thanks to a deal with its last souvereign ruler that the one who shall live longer will get it), and Minor Poland (the same case). Minor Poland was however taken before coronation (as well as most of Silesian duchies) by Czechs (who also claimed Polish throne). Przemyslaw II, reknown for alleged murder of his first wife, a Meklemburgian, was later on married to a Brandenburgian marchgravine. That didn't stop Brandenburgians from raiding him during some party and killing him in year 1296. As Przemyslaw's only dotter, Ryksa (?) was married by Czech king, Waclaw II of Przemyslid dinasty, king of Bohemia was eventually crowned as king of Poland, owning (vassalised) Silesia, Major and Minor Poland, and eastern Pommerania. He died in year 1305. His son, Waclaw III, the last of Przemyslid dinasty, was never crowned king of Poland, because he was murdered a year later near Olomluniec. He did plan to exchange Pommerania for Misnia, but He didn't have time to do so.
Anyways, that was the time when earlier pretendents to the crown begane fighting again. Mostly it was between Henry of Glogow (Silesia) and Wladyslaw Lokietek of some puny duchy in Kujawy region. Eventually Wladyslaw Lokietek won, and owned Major Poland, Minor Poland and eastern Pommerania, but then the Brandenburgians attacked. The rest of the story I've written earlier.
The Czechs under Luxemburg dinasty continued to claim Polish throne until Casimir the Great agreed to pay them a large sum of money and resign from Silesia in exchange for resignation of their rights.